casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
IncrStManAccessor.h
Go to the documentation of this file.
00001 //# IncrStManAccessor.h: Gives access to some IncrementalStMan functions
00002 //# Copyright (C) 1996,1999,2000,2001
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //#
00010 //# This library is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013 //# License for more details.
00014 //#
00015 //# You should have received a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be addressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 //#
00026 //# $Id: IncrStManAccessor.h 21295 2012-11-30 16:00:01Z gervandiepen $
00027 
00028 #ifndef TABLES_INCRSTMANACCESSOR_H
00029 #define TABLES_INCRSTMANACCESSOR_H
00030 
00031 //# Includes
00032 #include <casa/aips.h>
00033 #include <tables/Tables/DataManAccessor.h>
00034 #include <casa/iosfwd.h>
00035 
00036 namespace casa { //# NAMESPACE CASA - BEGIN
00037 
00038 //# Forward Declarations
00039 class ISMBase;
00040 class DataManager;
00041 class Table;
00042 class String;
00043 
00044 // <summary>
00045 // Give access to some IncrementalStMan functions
00046 // </summary>
00047 
00048 // <use visibility=export>
00049 
00050 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="" demos="">
00051 // </reviewed>
00052 
00053 // <prerequisite>
00054 //# Classes you should understand before using this one.
00055 // <li> <linkto class=IncrementalStMan>IncrementalStMan</linkto>
00056 // </prerequisite>
00057 
00058 // <synopsis>
00059 // The Table system has one or more storage managers underneath.
00060 // One of these possible storage managers is the
00061 // <linkto class=IncrementalStMan>IncrementalStMan</linkto>.
00062 // This storage manager uses a cache of buckets. The default
00063 // cache size is defined when the IncrementalStMan object was
00064 // constructed at the time the table was created.
00065 // <p>
00066 // Sometimes it can be useful to change the cache size. E.g. when
00067 // the table is accessed in a random way, the hit rate may drop
00068 // when the cache is too small. The class ROIncrStManAccessor makes
00069 // it possible to change the cache size in a temporary way.
00070 // <br>
00071 // Furthermore this class makes it possible to show the cache size
00072 // and to show the cache statistics.
00073 
00074 // <motivation>
00075 // In principle a pointer to IncrementalStMan could be used.
00076 // However, that would give access to all public functions.
00077 // Furthermore it could not distinguish between read/write and readonly
00078 // tables. 
00079 // </motivation>
00080 
00081 // <example>
00082 // This example shows how to set the cache size for
00083 // the incremental storage manager with the name "ISMExample". The cache
00084 // size is not persistent, i.e. when the same table is reopened
00085 // at a later time, this cache size is not remembered.
00086 // <srcblock>
00087 //  // Open a table.
00088 //  Table table("someName.data");
00089 //  // Set the cache size of its incremental storage manager ISMExample
00090 //  // to 5 buckets.
00091 //  ROIncrementalStManAccessor accessor(table, "ISMExample");
00092 //  accessor.setCacheSize (5);
00093 // </srcblock>
00094 // </example>
00095 
00096 //# <todo asof="$DATE:$">
00097 //# </todo>
00098 
00099 
00100 class ROIncrementalStManAccessor : public RODataManAccessor
00101 {
00102 public:
00103 
00104     // Construct the object for a data manager in the table given the name
00105     // of the data manager or the column.
00106     // An exception is thrown if the data manager type is not the incremental
00107     // storage manager.
00108     ROIncrementalStManAccessor (const Table& table, const String& name,
00109                                 Bool byColumn=False);
00110 
00111     virtual ~ROIncrementalStManAccessor();
00112 
00113     // Copy constructor (reference semantics).
00114     ROIncrementalStManAccessor (const ROIncrementalStManAccessor& that);
00115 
00116     // Assignment (reference semantics).
00117     ROIncrementalStManAccessor& operator=
00118                                  (const ROIncrementalStManAccessor& that);
00119 
00120     // Set the cache size (in buckets) to be used by the
00121     // storage manager.
00122     // The cache size given in this way is not persistent.
00123     // Only the cache size given to the constructors of the incremental
00124     // storage managers, is persistent.
00125     // If <src>canExceedNrBuckets=True</src>, the given cache size can be
00126     // larger than the nr of buckets in the file. In this way the cache can
00127     // be made large enough for a future file extnsion.
00128     // Otherwise, it is limited to the actual number of buckets. This is useful
00129     // if one wants the entire file to be cached.
00130     void setCacheSize (uInt aSize, Bool canExceedNrBuckets=True);
00131 
00132     // Get the cache size (in buckets).
00133     uInt cacheSize() const;
00134 
00135     // Clear the caches used by the hypercubes in this storage manager.
00136     // It will flush the caches as needed and remove all buckets from them
00137     // resulting in a possibly large drop in memory used.
00138     void clearCache();
00139 
00140 
00141 private:
00142     //# Declare the data members.
00143     ISMBase* dataManPtr_p;
00144 };
00145 
00146 
00147 
00148 } //# NAMESPACE CASA - END
00149 
00150 #endif