|
| AipsIO () |
| No file attached yet. More...
|
|
| AipsIO (const String &fileName, ByteIO::OpenOption=ByteIO::Old, uInt filebufSize=65536,/uInt filebufSize=1048576, */MultiFileBase *mfile=0) |
| Construct and open/create a file with the given name. More...
|
|
| AipsIO (ByteIO *) |
| Construct from a stream object derived from ByteIO. More...
|
|
| AipsIO (TypeIO *) |
| Construct from a stream object derived from TypeIO, thus from a stream on top of ByteIOn doing the possible conversions. More...
|
|
| ~AipsIO () |
| Close if not done yet. More...
|
|
void | open (const String &fileName, ByteIO::OpenOption=ByteIO::Old, uInt filebufSize=65536, MultiFileBase *mfile=0) |
| Open/create file (either a regular file or a MultiFileBase virtual file). More...
|
|
void | open (ByteIO *) |
| Open by connecting to the given byte stream. More...
|
|
void | open (TypeIO *) |
| Open by connecting to the given typed byte stream. More...
|
|
void | close () |
| Close file opened. More...
|
|
ByteIO::OpenOption | fileOption () const |
| Return the file option. More...
|
|
uInt | putstart (const String &objectType, uInt objectVersion) |
| Start putting an object. More...
|
|
uInt | putstart (const Char *objectType, uInt objectVersion) |
|
AipsIO & | operator<< (const Bool &value) |
| Put a single value. More...
|
|
AipsIO & | operator<< (const Char &value) |
|
AipsIO & | operator<< (const uChar &value) |
|
AipsIO & | operator<< (const short &value) |
|
AipsIO & | operator<< (const unsigned short &value) |
|
AipsIO & | operator<< (const int &value) |
|
AipsIO & | operator<< (const unsigned int &value) |
|
AipsIO & | operator<< (const Int64 &value) |
|
AipsIO & | operator<< (const uInt64 &value) |
|
AipsIO & | operator<< (const float &value) |
|
AipsIO & | operator<< (const double &value) |
|
AipsIO & | operator<< (const Complex &value) |
|
AipsIO & | operator<< (const DComplex &value) |
|
AipsIO & | operator<< (const String &value) |
|
AipsIO & | operator<< (const Char *value) |
|
AipsIO & | put (uInt nrval, const Bool *values, Bool putNR=True) |
| Put an array of values with the given number of values. More...
|
|
AipsIO & | put (uInt nrval, const Char *values, Bool putNR=True) |
|
AipsIO & | put (uInt nrval, const uChar *values, Bool putNR=True) |
|
AipsIO & | put (uInt nrval, const short *values, Bool putNR=True) |
|
AipsIO & | put (uInt nrval, const unsigned short *values, Bool putNR=True) |
|
AipsIO & | put (uInt nrval, const int *values, Bool putNR=True) |
|
AipsIO & | put (uInt nrval, const unsigned int *values, Bool putNR=True) |
|
AipsIO & | put (uInt nrval, const Int64 *values, Bool putNR=True) |
|
AipsIO & | put (uInt nrval, const uInt64 *values, Bool putNR=True) |
|
AipsIO & | put (uInt nrval, const float *values, Bool putNR=True) |
|
AipsIO & | put (uInt nrval, const double *values, Bool putNR=True) |
|
AipsIO & | put (uInt nrval, const Complex *values, Bool putNR=True) |
|
AipsIO & | put (uInt nrval, const DComplex *values, Bool putNR=True) |
|
AipsIO & | put (uInt nrval, const String *values, Bool putNR=True) |
|
template<typename T > |
AipsIO & | put (const vector< T > &vec) |
| Put a vector as an array of values For standard types it has the same result as put with putNR=True. More...
|
|
AipsIO & | put (const vector< Bool > &vec) |
|
uInt | putend () |
| End putting an object. More...
|
|
Int64 | getpos () |
| Get and set file-offset. More...
|
|
Int64 | setpos (Int64 offset) |
|
const String & | getNextType () |
| Get the type of the next object stored. More...
|
|
uInt | getstart (const String &objectType) |
| Start reading an object. More...
|
|
uInt | getstart (const Char *objectType) |
|
AipsIO & | operator>> (Bool &value) |
| Get a single value. More...
|
|
AipsIO & | operator>> (Char &value) |
|
AipsIO & | operator>> (uChar &value) |
|
AipsIO & | operator>> (short &value) |
|
AipsIO & | operator>> (unsigned short &value) |
|
AipsIO & | operator>> (int &value) |
|
AipsIO & | operator>> (unsigned int &value) |
|
AipsIO & | operator>> (Int64 &value) |
|
AipsIO & | operator>> (uInt64 &value) |
|
AipsIO & | operator>> (float &value) |
|
AipsIO & | operator>> (double &value) |
|
AipsIO & | operator>> (Complex &value) |
|
AipsIO & | operator>> (DComplex &value) |
|
AipsIO & | operator>> (String &value) |
|
AipsIO & | get (uInt nrval, Bool *values) |
| Read in nrval values into the user-supplied values buffer. More...
|
|
AipsIO & | get (uInt nrval, Char *values) |
|
AipsIO & | get (uInt nrval, uChar *values) |
|
AipsIO & | get (uInt nrval, short *values) |
|
AipsIO & | get (uInt nrval, unsigned short *values) |
|
AipsIO & | get (uInt nrval, int *values) |
|
AipsIO & | get (uInt nrval, unsigned int *values) |
|
AipsIO & | get (uInt nrval, Int64 *values) |
|
AipsIO & | get (uInt nrval, uInt64 *values) |
|
AipsIO & | get (uInt nrval, float *values) |
|
AipsIO & | get (uInt nrval, double *values) |
|
AipsIO & | get (uInt nrval, Complex *values) |
|
AipsIO & | get (uInt nrval, DComplex *values) |
|
AipsIO & | get (uInt nrval, String *values) |
|
template<typename T > |
AipsIO & | get (vector< T > &vec) |
| Get a vector as an array of values (similar to getnew). More...
|
|
AipsIO & | get (vector< Bool > &vec) |
|
AipsIO & | getnew (uInt &nrval, Bool *&values) |
| Read in values as written by the function put. More...
|
|
AipsIO & | getnew (uInt &nrval, Char *&values) |
|
AipsIO & | getnew (uInt &nrval, uChar *&values) |
|
AipsIO & | getnew (uInt &nrval, short *&values) |
|
AipsIO & | getnew (uInt &nrval, unsigned short *&values) |
|
AipsIO & | getnew (uInt &nrval, int *&values) |
|
AipsIO & | getnew (uInt &nrval, unsigned int *&values) |
|
AipsIO & | getnew (uInt &nrval, Int64 *&values) |
|
AipsIO & | getnew (uInt &nrval, uInt64 *&values) |
|
AipsIO & | getnew (uInt &nrval, float *&values) |
|
AipsIO & | getnew (uInt &nrval, double *&values) |
|
AipsIO & | getnew (uInt &nrval, Complex *&values) |
|
AipsIO & | getnew (uInt &nrval, DComplex *&values) |
|
AipsIO & | getnew (uInt &nrval, String *&values) |
|
uInt | getend () |
| End reading an object. More...
|
|
AipsIO is the object persistency mechanism of Casacore
Intended use:
Public interface
Review Status
- Reviewed By:
- ghunt
- Date Reviewed:
- 95Feb21
Etymology
AipsIO is simply the conventional shorthand for "AIPS++ input/output". Note that Casacore is the successor of the old AIPS++ project.
Synopsis
AipsIO is a class designed to do I/O for objects. It reads/writes the data using a class derived from TypeIO. For instance, class CanonicalIO can be used to read/write the data in canonical format.
The TypeIO class in its turn uses a class derived from ByteIO to determine where the data has to be written.
An object is written by writing all its data members. It will be preceeded by a header containing type and version. The I/O can be done via de overloaded << and >> operators to write or read a single item (e.g., an int or an object). These operators are already defined for all built-in data types and for Complex, DComplex, String, and Bool. Since each enumeration is a specific type, it is hard to handle them. Casting to Bool (which is also an enumerated type) is a possibility, but that assumes that each enumerated type has the same size (which is probably true for all compilers). Another possibility is to store it in an int when writing. Reading can be done the opposite way, although the ARM says that an int cannot be assigned to an enumerated type.
There are also functions put, get and getnew to write or read an array of values. These functions are defined for the same data types as << and >> (so one can write, for example, an array of Strings). AipsIO.put (nr, arr) writes nr values from the given array. AipsIO.get (nr, arr) reads nr values into the given user-supplied array. AipsIO.getnew (&nr, &arr) reads the number of values written into a new array allocated on the heap. It returns the nr of values read and a pointer to the array. The data must be read back in the same order as it was written.
The functions putstart(type,version)
and putend()
must be called before resp. after writing all values of the object. It stores the given type and version of the object. Similarly getstart(type)
and getend()
must be called. getstart checks the type and returns the version. By using the version the read function of the object can convert older versions of the object (which may still reside on disk) to the latest version. The function getNextType is available to get the type of the next object stored. This can be used to check the type or to open (i.e. issue a getstart) in the correct way.
When implementing a class, one should also define the operators << and >> for the class to allow users to write or read an object in this simple way (e.g., as io >> obj; to read an object). One has to define the friend functions:
AipsIO()
No file attached yet.
AipsIO & operator>>(Bool &value)
Get a single value.
AipsIO & operator<<(const Bool &value)
Put a single value.
since they cannot be stored in the class itself. The type of an object is usually passed as the class name.
ios <<....;
ios.putend ();
}
uInt putstart(const String &objectType, uInt objectVersion)
Start putting an object.
The functions getpos() and setpos(offset) can be used to get and set the offset in the file to a given point. They can be used to point to a position in the file where an object must be written or read. Obviously these functions are to be used by a storage manager and are not for public use. Someday they should be made private with a friend defined.
Example
MyClass myObject(...);
ios << myObject;
MyClass myObject2;
ios >> myObject2;
@ New
read/write; create file if not exist.
This example creates an object, writes it to AipsIO and reads it back into another object. The shift functions for MyClass could be defined as follows:
{
ios <<...;
ios.putend();
}
{
uInt version = ios.getstart (
"MyClass");
ios >>...;
ios.getend();
}
In this example the version is not used. In more complex objects it will probably be used when data members get added or changed in future versions of a software system.
Definition at line 168 of file AipsIO.h.