In file gdsdatum.h:

class gdsStorage : public gdsDataObject

Class to store a diagnostics data.

Inheritance:


Public Classes

enum filetype
file type for save and restore
LigoLW_XML
Ligo light-weight data format (XML based)
ASCII
Straight ASCII format

Public Fields

typedef data_storage_ptr gdsDataObjectPtr
(auto) pointer to a data object object
typedef std::vector <gdsDataObjectPtr> gdsObjectList
list of pointers to data objects
typedef gdsDataObject::gdsParameterList::iterator prm_iterator
iterator for paramters
typedef gdsDataObject::gdsParameterList::const_iterator const_prm_iterator
const iterator for paramters
typedef gdsObjectList::iterator data_iterator
iterator for data objects
typedef gdsObjectList::const_iterator const_data_iterator
const iterator for data objects
typedef std::set <objflag, std::less<objflag> > ioflags
set for describing the save/restore flags
static const ioflags ioEverything
set of all save/restore flags
static const ioflags ioExtended
set of all save/restore flags, except io_images
static const ioflags ioStandard
standard set of save/restore flags: io_parameters, io_results, io_settings
static const ioflags ioParamOnly
set of save/restore flags only including io_parameters
mutable recursivemutex mux
Mutex to protect storage object in MT environment */
string creator
Name of the great maker
string date
date of object creation
gdsObjectList objects
list of pointers to data objects

Public Methods

friend std::istream& operator >> (std::istream&, gdsStorage&)
Input operator.
friend std::ostream& operator << (std::ostream&, gdsStorage&)
Output operator.
gdsStorage ()
Default constructor.
virtual ~gdsStorage ()
Destructor.
gdsStorage (const string& Creator, const string& Date, const string& Comment = "")
Constructor.
explicit gdsStorage (string filename, ioflags restoreflags = ioExtended, filetype FileType = LigoLW_XML)
Constructor.
bool operator ! () const
Not operator.
virtual bool fsave (string filename, ioflags saveflags = ioStandard, filetype FileType = LigoLW_XML)
File save function.
virtual bool frestore (string filename, ioflags restoreflags = ioExtended, filetype FileType = LigoLW_XML)
File restore function.
string errmsg () const
File error function.
static bool isTempFile (const string& filename)
Temporary file query function.
static void registerTempFile (const string& filename)
Temporary file register function.
static void unregisterTempFile (const string& filename)
Temporary file unregister function.
virtual bool addParameter (const string& objname, gdsParameter& prm, bool copy = true)
Add a parameter.
virtual bool addParameter (gdsParameter& prm, bool copy = true)
Add a parameter.
virtual bool addData (gdsDataObject& dat, bool copy = true)
Add a data object.
virtual bool eraseParameter (const string& objname, const string& prmname)
Remove a parameter.
virtual bool eraseParameter (const string& prmname)
Remove a parameter.
virtual bool eraseData (const string& objname)
Remove a data object.
virtual gdsParameter* findParameter (const string& objname, const string& prmname) const
Find a parameter.
virtual gdsParameter* findParameter (const string& prmname) const
Find a parameter.
virtual gdsDataObject* findData (const string& objname) const
Find a data object.
virtual gdsDataObject* newChannel (const string& objname, tainsec_t start, double dt, bool cmplx = false, bool memmap = false)
Sets up a channel data object.
virtual float* allocateChannelMem (const string& objname, int length)
Allocates memory for channel data.
virtual void notifyChannelMem (const string& objname, bool error = false)
Notification of memory initialization.
gdsDataObject* lockData (const string& objname, bool write = false)
Lock data object.
gdsDataObject* trylockData (const string& objname, bool write = false)
Trylock data object.
void unlockData (gdsDataObject* dat)
Unlock data object.

Protected Classes

class tempnames : public std vector<string>
storage of temprary file names

Protected Fields

typedef std::map <string, stringcase> attrtype
attribute list of an XML tag
static mutex tempfilemux
mutex to access temporary file storage
static tempnames tempfiles
temporary file storage
bool XML_fini
XML termination flag
bool XML_init
XML initialization flag;
int XML_Skip
skip level: if >0 XML elements are skipped
string XML_Key
XML key
string XML_Key2
XML 2nd key
gdsParameter* XML_Param
pointer to current parameter object for XML read
gdsDataObject* XML_Obj
pointer to current data object for XML read
bool XML_fast
determines if fast decoding of is present
string XML_Error
XML error string

Protected Methods

void fwriteXML (std::ostream& os)
write XML header
bool fwriteBinary (std::ostream& os)
write binary data
int ffixRef (int XML_Length)
fix self references
virtual void startElement (const string& elName, const attrtype& atts)
XML start element handler
virtual void endElement (const string& elName)
XML end element handler
virtual void textHandler (std::stringstream& text)
XML text element handler

Inherited from gdsDataObject:

Public Classes

enum objflag
parameterObj
global diganostics test parameters
settingsObj
the user settings of a diagnostics test
resultObj
results of a diganotics test
rawdataObj
the raw data of a diagnostics test
imageObj
the plots of a diagnostics test

Public Fields

typedef std::vector <gdsParameterPtr> gdsParameterList
gdsParameterList parameters
gdsDataReference link
bool error

Public Methods

gdsDataObject& operator= (const gdsDataObject& dat)
virtual bool assignDatum(const gdsDatum& dat)
static objflag gdsObjectFlag(const string& oflag)
static string gdsObjectFlagName(objflag oflag)
string getType() const
objflag getFlag() const
void setType(const string& otype)
void setFlag(objflag oflag)
void setFlag(const string& oflag)
bool isRef() const

Inherited from gdsNamedDatum:

Public Fields

string unit
int level

Inherited from gdsNamedStorage:

Public Fields

string name
string comment

Public Methods

bool operator == (const gdsNamedStorage& x) const
bool operator == (const string& x) const
bool operator != (const string& x) const
bool operator != (const gdsNamedStorage& x) const
bool operator <= (const gdsNamedStorage& x) const
bool operator < (const gdsNamedStorage& x) const
bool operator < (const string& x) const
bool operator >= (const gdsNamedStorage& x) const
bool operator > (const gdsNamedStorage& x) const

Inherited from gdsDatum:

Public Classes

enum encodingtype
ascii
ascii
binary
binary
uuencode
uuencoding
base64
base64 encoding

Public Fields

typedef std::vector <int> dimension_t
gdsDataType datatype
dimension_t dimension
void* value
encodingtype encoding

Public Methods

static bool encode(std::ostream& os, const char* val, int len, encodingtype ctype = base64, int indent = 0)
static bool decode(std::istream& is, char* val, int len, encodingtype ctype = base64)
static bool decode(const char* code, int codelen, char* val, int len, encodingtype ctype = base64)
static std::string codeName(encodingtype ctype)
static encodingtype code(std::string name)
bool resize(int dim1, int dim2 = 0, int dim3 = 0, int dim4 = 0)
int elSize() const
int elNumber() const
int size() const
int readValues(const string& txt)
void lock(bool writeaccess = false) const
bool trylock(bool writeaccess = false) const
void unlock() const

Protected Fields

mutable readwritelock rwlock

Documentation

This class is used to store diagnostics data. A storage object contains a list of data objects which have both data and parameters associated with them. Additionally, a parameter can be stored in global context. Every data object is characterized by its name which must be unique. Every parameter is characterized by its name and an associated data object (if it isn't in global context). The paramter name has to be unique within its context.

MT safe: All public methods of the storage object are multi-thread safe and can be called from independently running tasks. Direct access to its public data member should be avoided and should always guared by the mutex of the storage object.

friend std::istream& operator >> (std::istream&, gdsStorage&)
This function reads the storage object from an input stream. The data objects and parameters which are read in are appended to the storage object.
Returns:
input stream
Parameters:
istream - input stream
gdsStorage - class

friend std::ostream& operator << (std::ostream&, gdsStorage&)
This function writes a storage object to an output stream following the LigoLW XML specification.
Returns:
input stream
Parameters:
ostream - output stream
gdsStorage - class

typedef data_storage_ptr gdsDataObjectPtr
(auto) pointer to a data object object

typedef std::vector <gdsDataObjectPtr> gdsObjectList
list of pointers to data objects

typedef gdsDataObject::gdsParameterList::iterator prm_iterator
iterator for paramters

typedef gdsDataObject::gdsParameterList::const_iterator const_prm_iterator
const iterator for paramters

typedef gdsObjectList::iterator data_iterator
iterator for data objects

typedef gdsObjectList::const_iterator const_data_iterator
const iterator for data objects

enum filetype
file type for save and restore

LigoLW_XML
Ligo light-weight data format (XML based)

ASCII
Straight ASCII format

typedef std::set <objflag, std::less<objflag> > ioflags
set for describing the save/restore flags

static const ioflags ioEverything
set of all save/restore flags

static const ioflags ioExtended
set of all save/restore flags, except io_images

static const ioflags ioStandard
standard set of save/restore flags: io_parameters, io_results, io_settings

static const ioflags ioParamOnly
set of save/restore flags only including io_parameters

mutable recursivemutex mux
Mutex to protect storage object in MT environment */

string creator
Name of the great maker

string date
date of object creation

gdsObjectList objects
list of pointers to data objects

gdsStorage()
Constructs an empty storage object.
Returns:
void

virtual ~gdsStorage()
Destructs the storage object.
Returns:
void

gdsStorage(const string& Creator, const string& Date, const string& Comment = "")
Constructs an empty storage object.
Returns:
void
Parameters:
Creator - name of the great maker
Date - data/time string
Comment - comment string for describing storage object

explicit gdsStorage(string filename, ioflags restoreflags = ioExtended, filetype FileType = LigoLW_XML)
Constructs a storage object and initializes it from a file.
Returns:
void
Parameters:
filename - name of the input file
restoreflags - specifies what to restore
filetype - specifies the filetype

bool operator ! () const
Returns true if storage object isn't yet initialized. This function can be used to test whether the construction from an input file was successful.
Returns:
true if not initialized

virtual bool fsave(string filename, ioflags saveflags = ioStandard, filetype FileType = LigoLW_XML)
Saves a storage object to a file.
Returns:
true if successful
Parameters:
filename - name of the output file
saveflags - specifies what to save
filetype - specifies the filetype

virtual bool frestore(string filename, ioflags restoreflags = ioExtended, filetype FileType = LigoLW_XML)
Reads in data objects and parameters from a file and appends them to the storage object. Use the corresponding constructor if teh storage object should be created newly.)
Returns:
true if successful
Parameters:
filename - name of the input file
restoreflags - specifies what to restore
filetype - specifies the filetype

string errmsg() const
Returns the error message if either fsave or frestore failed.
Returns:
error message or empty string

static bool isTempFile(const string& filename)
Tests wheather the given file name is a registred temporary file name.
Returns:
true if filename is a temporary file
Parameters:
filename - name of file

static void registerTempFile(const string& filename)
Temporary file register function.
Returns:
void
Parameters:
filename - name of file

static void unregisterTempFile(const string& filename)
Unregisters a temporary file name. The temporary file is deleted if this was the last reference to it.
Returns:
void
Parameters:
filename - name of file

virtual bool addParameter(const string& objname, gdsParameter& prm, bool copy = true)
Adds a parameter to the storage object. The parameter will be copied if copy is true, and stored with the associated data object (specified by its name). If the data object name is empty, i.e. equal to "", the parameter is stored in global context.
Returns:
true if successful
Parameters:
objname - name of data object
prm - parameter object
copy - copy object if true, otherwise transfer ownership

virtual bool addParameter(gdsParameter& prm, bool copy = true)
Adds a global parameter. The parameter will be copied if copy is true, and stored in global context.
Returns:
true if successful
Parameters:
prm - parameter object
copy - copy object if true, otherwise transfer ownership

virtual bool addData(gdsDataObject& dat, bool copy = true)
Adds a data object. The data object will be copied if copy is true and stored in global context.
Returns:
true if successful
Parameters:
dat - data object
copy - copy object if true, otherwise transfer ownership

virtual bool eraseParameter(const string& objname, const string& prmname)
Removes a parameter object from its asscoiated data object. If the data object name is empty, i.e. equal to "", the parameter is removed from global context.
Returns:
true if successful
Parameters:
objname - name of data object
prmname - name of parameter

virtual bool eraseParameter(const string& prmname)
Removes a global parameter object. The specified parameter is removed from its global context.
Returns:
true if successful
Parameters:
prmname - name of parameter

virtual bool eraseData(const string& objname)
Removes a data object. The specified data object is removed from its global context.
Returns:
true if successful
Parameters:
objname - name of data object

virtual gdsParameter* findParameter(const string& objname, const string& prmname) const
Finds a parameter by its name and the name of its associated data object.
Returns:
pointer to parameter, or 0 if not found
Parameters:
prmname - name of parameter
objname - name of data object

virtual gdsParameter* findParameter(const string& prmname) const
Finds a globale parameter by its name.
Returns:
pointer to parameter, or 0 if not found
Parameters:
prmname - name of parameter

virtual gdsDataObject* findData(const string& objname) const
Finds a data object by its name.
Returns:
pointer to data object, or 0 if not found
Parameters:
objname - name of data object

virtual gdsDataObject* newChannel(const string& objname, tainsec_t start, double dt, bool cmplx = false, bool memmap = false)
Sets up a new data object for channel data. The newly created data object is either of type float or complex<float>. It contains no data, it uses a memory mapped file by default.
Returns:
pointer to data object, or 0 if not failed
Parameters:
name - name of channel data object
start - time of first data point (GPS nsec)
dt - spacing of data points (sec)
cmplx - true if time series is down-converted

virtual float* allocateChannelMem(const string& objname, int length)
Allocates memory for new channel data. The allocated memory has to filled by the caller; and if finished, the caller has to call the notifyChannelMem method to inform the data object to make the new data available for read. A second allocation of memory for the same channel returns only after the notification of the first allocation was seen.
Returns:
pointer to newly allocated data array
Parameters:
name - name of channel data object
len - number of data points

virtual void notifyChannelMem(const string& objname, bool error = false)
Notifies the data object that the newly allocated memory for channel data is initialized.
Returns:
void
Parameters:
name - name of channel data object
error - can be used to set the error flag

gdsDataObject* lockData(const string& objname, bool write = false)
Locks the data object to make sure that it isn't changed while accessing.
Returns:
pointer to data object, 0 if failed
Parameters:
name - name of data object
write - if true locks for exclusive use

gdsDataObject* trylockData(const string& objname, bool write = false)
Tries to lock a data object for exclusive use (write==true), or for shared use (write==false).
Returns:
pointer to data object, 0 if failed
Parameters:
name - name of data object
write - if true locks for exclusive use

void unlockData(gdsDataObject* dat)
Unlocks the data object after use.
Returns:
void
Parameters:
dat - pointer to data object

class tempnames: public std vector<string>
storage of temprary file names

typedef std::map <string, stringcase> attrtype
attribute list of an XML tag

static mutex tempfilemux
mutex to access temporary file storage

static tempnames tempfiles
temporary file storage

bool XML_fini
XML termination flag

bool XML_init
XML initialization flag;

int XML_Skip
skip level: if >0 XML elements are skipped

string XML_Key
XML key

string XML_Key2
XML 2nd key

gdsParameter* XML_Param
pointer to current parameter object for XML read

gdsDataObject* XML_Obj
pointer to current data object for XML read

bool XML_fast
determines if fast decoding of is present

string XML_Error
XML error string

void fwriteXML(std::ostream& os)
write XML header

bool fwriteBinary(std::ostream& os)
write binary data

int ffixRef(int XML_Length)
fix self references

virtual void startElement(const string& elName, const attrtype& atts)
XML start element handler

virtual void endElement(const string& elName)
XML end element handler

virtual void textHandler(std::stringstream& text)
XML text element handler


Direct child classes:
diagStorage
Author:
DS, November 98
See Also:
Diagnostics storage API

alphabetic index hierarchy of classes


Please send questions and comments to sigg_d@ligo-wa.caltech.edu


generated by doc++