casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Types | Public Member Functions | Private Types | Private Attributes
SDDBootStrap Class Reference

Class encapsulates user-options for a bootstrap block from an SDD file. More...

#include <SDDBootStrap.h>

List of all members.

Public Types

enum  TYPE_OF_SDD {
  DATA,
  RECORDS
}
enum  SDD_VERSION {
  ORIGINAL,
  CURRENT
}

Public Member Functions

 SDDBootStrap ()
 Default constructor : empty CURRENT version NOT attached to a file.
 SDDBootStrap (CountedPtr< fstream > streamPtr)
 create from an fstream ptr in CountedPtr<fstream>
 SDDBootStrap (const SDDBootStrap &other)
 from an existing SDDBootStrap, copies all values
 ~SDDBootStrap ()
SDDBootStrapoperator= (const SDDBootStrap &other)
 The assignment operator, does a full copy.
void attach (CountedPtr< fstream > newStreamPtr)
 Attach.
void write ()
 write it out, must already be attached
CountedPtr< fstream > & theStream ()
 Get the CountedPtr<fstream> in use here.
uInt nIndexRec () const
 These just return the values.
uInt nDataRec () const
uInt bytesPerRecord () const
uInt bytesPerEntry () const
uInt maxEntryUsed () const
uInt counter () const
uInt type () const
uInt version () const
uInt maxEntries () const
 Maximum index entries that can be used, based on the values in the bootstrap.
uInt entriesPerRecord () const
 the numebr of entries per record
void setNIndexRec (uInt newValue)
 Set things that are allowed to be set.
void setNDataRec (uInt newValue)
void setBytesPerEntry (uInt newValue)
void setVersion (SDD_VERSION newValue)
void setType (TYPE_OF_SDD newValue)
Bool setMaxEntryUsed (uInt newValue)
 this requires a sanity check to ensure it is less than maxEntries
Bool hasChanged ()
 This returns True if the bootstrap on disk differs from the one here.
void sync ()
 sync() re-reads the values from disk.

Private Types

enum  {
  N_INDEX_REC,
  N_DATA_REC,
  BYTES_PER_REC,
  BYTES_PER_ENTRY,
  MAX_ENTRY_USED,
  COUNTER,
  TYPE,
  VERSION
}
 this enum describes where things are in the bootstrap block for ORIGINAL version files, these are short (2-byte) unsigned integers for CURRENT version files, these are long (4-byte) unsigned integers all unused space is filled with zeros (both ORIGINAL and CURRECT). More...

Private Attributes

uInt nIndexRec_p
uInt nDataRec_p
uInt bytesPerRec_p
uInt bytesPerEntry_p
uInt maxEntryUsed_p
uInt counter_p
uInt type_p
uInt version_p
SDDBlockbs_p
CountedPtr< fstream > theFile_p

Detailed Description

Class encapsulates user-options for a bootstrap block from an SDD file.

Intended use:

Public interface

Prerequisite

Etymology

SDD is the Single Dish Data format used by UniPOPS. It is also the on-line data format at the NRAO 12-m. The bootstrap block is the first 512 bytes of an SDD file. It contains information that describes the file and allows the rest of the file to be read correctly. This class encapsulates that data.

Synopsis

This class encapsulates the SDD bootstrap block. It can be initialzed from a CountedPtr<fstream> object. In order to be written to disk it must be attached to a CountedPtr<fstream> object. The class correctly positions the fstream to the start of the file. The information in the bootstrap is retrieved via member functions. Most of the information in the bootstrap can be set. The class does basic sanity checking on the information in the bootstrap. It is expected that this class will be used with other SDD classes (most users will simply use SDDFile). The hasChanged() function checks the internal copy of the bootstrap block with the block on disk (if attached) and returns True if the file has changed (i.e. whats on disk does NOT match this object) and False if it has not changed.

Example

Create an SDDBootStrap from a file on disk. Print some information, set some values, write it out to the same file.

        fstream* file_ptr = new fstream("file_name", ios::nocreate);
        CountedPtr<fstream> file(file_ptr);
        SDDBootStrap bs(file);
        cout << "Number of index records : " << bs.nIndexRec() << endl;
        cout << "Number of data records : " << bs.nDataRec() << endl;
        cout << "Maximum index entry in use : " << bs.maxEntryUsed() << endl;
   
        // set some new values
        bs.setNDataRec(bs.nDataRec()+5);
        if (!bs.setMaxEntryUsed(bs.maxEntryUsed()+1)) {
           cout << "unable to set max entry used" << endl;
           // do something appropriate here
        }
   
        // write it out
        bs.write();

Motivation

The SDD file format is used by UniPOPS and the on-line data system at the NRAO 12-m. It is necessary to read this type of data directly into aips++. Specifically, a table storage manager can be written to make an SDD file look like a table. Underneath that storage manager are the SDD classes to encapsulate the data.

To Do

Definition at line 119 of file SDDBootStrap.h.


Member Enumeration Documentation

anonymous enum [private]

this enum describes where things are in the bootstrap block for ORIGINAL version files, these are short (2-byte) unsigned integers for CURRENT version files, these are long (4-byte) unsigned integers all unused space is filled with zeros (both ORIGINAL and CURRECT).

Enumerator:
N_INDEX_REC 
N_DATA_REC 
BYTES_PER_REC 
BYTES_PER_ENTRY 
MAX_ENTRY_USED 
COUNTER 

largest index entry in use

TYPE 

changes, wraps back to 0 at max unsigned 4-byte integer

VERSION 

Definition at line 193 of file SDDBootStrap.h.

Enumerator:
ORIGINAL 
CURRENT 

Definition at line 126 of file SDDBootStrap.h.

Enumerator:
DATA 
RECORDS 

Definition at line 123 of file SDDBootStrap.h.


Constructor & Destructor Documentation

Default constructor : empty CURRENT version NOT attached to a file.

SDDBootStrap::SDDBootStrap ( CountedPtr< fstream >  streamPtr)

create from an fstream ptr in CountedPtr<fstream>

from an existing SDDBootStrap, copies all values


Member Function Documentation

void SDDBootStrap::attach ( CountedPtr< fstream >  newStreamPtr)

Attach.

uInt SDDBootStrap::bytesPerEntry ( ) const [inline]

Definition at line 155 of file SDDBootStrap.h.

References bytesPerEntry_p.

uInt SDDBootStrap::bytesPerRecord ( ) const [inline]

Definition at line 154 of file SDDBootStrap.h.

References bytesPerRec_p.

uInt SDDBootStrap::counter ( ) const [inline]

Definition at line 157 of file SDDBootStrap.h.

References counter_p.

uInt SDDBootStrap::entriesPerRecord ( ) const [inline]

the numebr of entries per record

Definition at line 167 of file SDDBootStrap.h.

References bytesPerEntry_p, and bytesPerRec_p.

This returns True if the bootstrap on disk differs from the one here.

It does not change the bootstrap on disk.

uInt SDDBootStrap::maxEntries ( ) const [inline]

Maximum index entries that can be used, based on the values in the bootstrap.

Definition at line 163 of file SDDBootStrap.h.

References bytesPerEntry_p, bytesPerRec_p, and nIndexRec_p.

Referenced by setMaxEntryUsed().

uInt SDDBootStrap::maxEntryUsed ( ) const [inline]

Definition at line 156 of file SDDBootStrap.h.

References maxEntryUsed_p.

uInt SDDBootStrap::nDataRec ( ) const [inline]

Definition at line 153 of file SDDBootStrap.h.

References nDataRec_p.

uInt SDDBootStrap::nIndexRec ( ) const [inline]

These just return the values.

Definition at line 152 of file SDDBootStrap.h.

References nIndexRec_p.

SDDBootStrap& SDDBootStrap::operator= ( const SDDBootStrap other)

The assignment operator, does a full copy.

void SDDBootStrap::setBytesPerEntry ( uInt  newValue) [inline]

Definition at line 173 of file SDDBootStrap.h.

References bytesPerEntry_p.

Bool SDDBootStrap::setMaxEntryUsed ( uInt  newValue) [inline]

this requires a sanity check to ensure it is less than maxEntries

Definition at line 211 of file SDDBootStrap.h.

References maxEntries(), and maxEntryUsed_p.

void SDDBootStrap::setNDataRec ( uInt  newValue) [inline]

Definition at line 172 of file SDDBootStrap.h.

References nDataRec_p.

void SDDBootStrap::setNIndexRec ( uInt  newValue) [inline]

Set things that are allowed to be set.

Definition at line 171 of file SDDBootStrap.h.

References nIndexRec_p.

void SDDBootStrap::setType ( TYPE_OF_SDD  newValue) [inline]

Definition at line 175 of file SDDBootStrap.h.

References type_p.

void SDDBootStrap::setVersion ( SDD_VERSION  newValue) [inline]

Definition at line 174 of file SDDBootStrap.h.

References version_p.

sync() re-reads the values from disk.

Any internal values will be forgotten.

CountedPtr<fstream>& SDDBootStrap::theStream ( ) [inline]

Get the CountedPtr<fstream> in use here.

Definition at line 149 of file SDDBootStrap.h.

References theFile_p.

uInt SDDBootStrap::type ( ) const [inline]

Definition at line 158 of file SDDBootStrap.h.

References type_p.

uInt SDDBootStrap::version ( ) const [inline]

Definition at line 159 of file SDDBootStrap.h.

References version_p.

write it out, must already be attached


Member Data Documentation

Definition at line 207 of file SDDBootStrap.h.

Definition at line 204 of file SDDBootStrap.h.

Referenced by bytesPerEntry(), entriesPerRecord(), maxEntries(), and setBytesPerEntry().

Definition at line 204 of file SDDBootStrap.h.

Referenced by bytesPerRecord(), entriesPerRecord(), and maxEntries().

uInt SDDBootStrap::counter_p [private]

Definition at line 204 of file SDDBootStrap.h.

Referenced by counter().

Definition at line 204 of file SDDBootStrap.h.

Referenced by maxEntryUsed(), and setMaxEntryUsed().

uInt SDDBootStrap::nDataRec_p [private]

Definition at line 204 of file SDDBootStrap.h.

Referenced by nDataRec(), and setNDataRec().

uInt SDDBootStrap::nIndexRec_p [private]

Definition at line 204 of file SDDBootStrap.h.

Referenced by maxEntries(), nIndexRec(), and setNIndexRec().

CountedPtr<fstream> SDDBootStrap::theFile_p [private]

Definition at line 208 of file SDDBootStrap.h.

Referenced by theStream().

uInt SDDBootStrap::type_p [private]

Definition at line 204 of file SDDBootStrap.h.

Referenced by setType(), and type().

uInt SDDBootStrap::version_p [private]

Definition at line 204 of file SDDBootStrap.h.

Referenced by setVersion(), and version().


The documentation for this class was generated from the following file: