SDDBootStrap.h

Classes

SDDBootStrap -- Class encapsulates user-options for a bootstrap block from an SDD file (full description)

class SDDBootStrap

Types

enum TYPE_OF_SDD

DATA = 0
RECORDS = 1
normal data file

enum SDD_VERSION

ORIGINAL = 0
CURRENT = 1
used short integers, limited file size

enum

N_INDEX_REC = 0
N_DATA_REC = 1
Number of index records
BYTES_PER_REC = 2
Number of data records
BYTES_PER_ENTRY = 3
Number of bytes/records, must be 512
MAX_ENTRY_USED = 4
Number of bytes/index-entry
COUNTER = 5
Number (origin=1) of largest index entry in use
TYPE = 6
incremented by 1 whenever the file changes, wraps back to 0 at max unsigned 4-byte integer
VERSION = 7
either DATA or RECORDS

Interface

Public Members
SDDBootStrap()
SDDBootStrap(CountedPtr<fstream> streamPtr)
SDDBootStrap(const SDDBootStrap& other)
~SDDBootStrap()
SDDBootStrap& operator=(const SDDBootStrap& other)
void attach(CountedPtr<fstream> newStreamPtr)
void write()
CountedPtr<fstream>& theStream()
uInt nIndexRec() const
uInt nDataRec() const
uInt bytesPerRecord() const
uInt bytesPerEntry() const
uInt maxEntryUsed() const
uInt counter() const
uInt type() const
uInt version() const
uInt maxEntries() const
uInt entriesPerRecord() const
void setNIndexRec(uInt newValue)
void setNDataRec(uInt newValue)
void setBytesPerEntry(uInt newValue)
void setVersion(SDD_VERSION newValue)
void setType(TYPE_OF_SDD newValue)
Bool setMaxEntryUsed(uInt newValue)
Bool hasChanged()
void sync()

Description

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 object. In order to be written to disk it must be attached to a CountedPtr 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

Member Description

enum TYPE_OF_SDD

enum SDD_VERSION

SDDBootStrap()

Default constructor : empty CURRENT version NOT attached to a file

SDDBootStrap(CountedPtr<fstream> streamPtr)

create from an fstream ptr in CountedPtr

SDDBootStrap(const SDDBootStrap& other)

from an existing SDDBootStrap, copies all values

~SDDBootStrap()

SDDBootStrap& operator=(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 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. It does not change the bootstrap on disk.

void sync()

sync() re-reads the values from disk. Any internal values will be forgotten.

enum

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).