| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

DayaBay::RawFileName Class Reference

#include <RawRecord.h>

Inheritance diagram for DayaBay::RawFileName:

[legend]
Collaboration diagram for DayaBay::RawFileName:
[legend]
List of all members.

Public Member Functions

 RawFileName (unsigned int *buffer=0, unsigned int version=0, bool isOwner=false)
 RawFileName (DayaBay::RawRecord &record, bool adopt=false)
virtual ~RawFileName ()
char * appName () const
unsigned int appNameLength () const
char * fileName () const
unsigned int fileNameLength () const
virtual std::ostream & dump (std::ostream &str)
unsigned int type () const
unsigned int size () const
unsigned int version () const
bool isFileStart () const
bool isFileName () const
bool isMetadata () const
bool isRunParameters () const
bool isCalibrationParameters () const
bool isDataSeparator () const
bool isFileEnd () const
DayaBay::RawRecordclone () const
unsigned int * buffer () const
unsigned int bufferSize () const
bool isOwner () const
void setOwner (bool isOwner=true)
virtual bool isValid () const
unsigned int * getPointer (const unsigned int &line) const
unsigned int getValue (const unsigned int &line, const unsigned int &firstBit=0, const unsigned int &bitLength=32) const
char * getString (const unsigned int &line, const unsigned int &byteOffset=0) const

Static Public Member Functions

static unsigned int minimumSize ()
static DayaBay::RawRecordmakeNewRecord (unsigned int *buffer=0, unsigned int version=0, bool isOwner=false)

Detailed Description

Definition at line 63 of file RawRecord.h.


Constructor & Destructor Documentation

DayaBay::RawFileName::RawFileName ( unsigned int *  buffer = 0,
unsigned int  version = 0,
bool  isOwner = false 
)

Definition at line 231 of file RawRecord.cc.

00234   : RawRecord(buffer,version,isOwner)
00235 {
00236   // Default constructor
00237 }

DayaBay::RawFileName::RawFileName ( DayaBay::RawRecord record,
bool  adopt = false 
)

Definition at line 239 of file RawRecord.cc.

00241   : RawRecord(record,adopt)
00242 {
00243   // Construct from another RawRecord
00244   // If adopt==true, then take over ownership of the 
00245   // memory buffer (if the input record is the current owner)
00246 }

DayaBay::RawFileName::~RawFileName (  )  [virtual]

Definition at line 248 of file RawRecord.cc.

00249 {
00250   // Destructor
00251 }


Member Function Documentation

char * DayaBay::RawFileName::appName (  )  const

Definition at line 253 of file RawRecord.cc.

00254 {
00255   return this->getString(RecordFormat::FileName::appNameLine);
00256 }

unsigned int DayaBay::RawFileName::appNameLength (  )  const

Definition at line 258 of file RawRecord.cc.

00259 {
00260   return this->getValue(RecordFormat::FileName::appNameLengthLine);
00261 }

char * DayaBay::RawFileName::fileName (  )  const

Definition at line 263 of file RawRecord.cc.

00264 {
00265   // Add enough integer lines to account for app name string size
00266   unsigned int stringLineLength = this->appNameLength()*sizeof(char)
00267     +sizeof(unsigned int) - 1;
00268   stringLineLength /= sizeof(unsigned int);
00269   return this->getString(RecordFormat::FileName::appNameLine
00270                          +stringLineLength+1);
00271 }

unsigned int DayaBay::RawFileName::fileNameLength (  )  const

Definition at line 273 of file RawRecord.cc.

00274 {
00275   // Add enough integer lines to account for app name string size
00276   unsigned int stringLineLength = this->appNameLength()*sizeof(char)
00277     +sizeof(unsigned int) - 1;
00278   stringLineLength /= sizeof(unsigned int);
00279   return this->getValue(RecordFormat::FileName::appNameLine
00280                         +stringLineLength);
00281 }

std::ostream & DayaBay::RawFileName::dump ( std::ostream &  str  )  [virtual]

Reimplemented from DayaBay::RawRecord.

Definition at line 283 of file RawRecord.cc.

00283                                                    {
00284   // Print the record information
00285   str << "RawFileName {" << std::endl << "  ";
00286   this->RawRecord::dump(str);
00287   return str << "  appNameLength: " << this->appNameLength() << std::endl
00288              << "  appName: " << std::string(this->appName(),
00289                                              this->appNameLength()) << std::endl
00290              << "  fileNameLength: " << this->fileNameLength() << std::endl
00291              << "  fileName: " << std::string(this->fileName(),
00292                                               this->fileNameLength()) << " }" 
00293              << std::endl;
00294 }

unsigned int DayaBay::RawRecord::type (  )  const [inherited]

Definition at line 40 of file RawRecord.cc.

00041 {
00042   // Return the type of this RawRecord
00043   return this->getValue(RecordFormat::Record::typeLine);
00044 }

unsigned int DayaBay::RawRecord::size (  )  const [inherited]

Definition at line 46 of file RawRecord.cc.

00047 {
00048   // Return the size of this record, in integer segments
00049   return this->getValue(RecordFormat::Record::sizeLine);
00050 }

unsigned int DayaBay::RawRecord::version (  )  const [inherited]

Definition at line 52 of file RawRecord.cc.

00053 {
00054   // Version of this record
00055   return m_version;
00056 }

unsigned int DayaBay::RawRecord::minimumSize (  )  [static, inherited]

Definition at line 34 of file RawRecord.cc.

00035 {
00036   // Minimum size for all raw records.
00037   return RecordFormat::Record::minimumSize;
00038 }

bool DayaBay::RawRecord::isFileStart (  )  const [inherited]

Definition at line 58 of file RawRecord.cc.

00059 {
00060   // Is this a file start record?
00061   return (this->type()==RecordFormat::FileStart::type);
00062 }

bool DayaBay::RawRecord::isFileName (  )  const [inherited]

Definition at line 64 of file RawRecord.cc.

00065 {
00066   // Is this a file name record?
00067   return (this->type()==RecordFormat::FileName::type);
00068 }

bool DayaBay::RawRecord::isMetadata (  )  const [inherited]

Definition at line 70 of file RawRecord.cc.

00071 {
00072   // Is this a metadata record?
00073   return (this->type()==RecordFormat::Metadata::type);
00074 }

bool DayaBay::RawRecord::isRunParameters (  )  const [inherited]

Definition at line 76 of file RawRecord.cc.

00077 {
00078   // Is this a run parameters record?
00079   return (this->type()==RecordFormat::RunParameters::type);
00080 }

bool DayaBay::RawRecord::isCalibrationParameters (  )  const [inherited]

Definition at line 82 of file RawRecord.cc.

00083 {
00084   // Is this a calibration parameters record?
00085   return (this->type()==RecordFormat::CalibrationParameters::type);
00086 }

bool DayaBay::RawRecord::isDataSeparator (  )  const [inherited]

Definition at line 88 of file RawRecord.cc.

00089 {
00090   // Is this a data separator record?
00091   return (this->type()==RecordFormat::DataSeparator::type);
00092 }

bool DayaBay::RawRecord::isFileEnd (  )  const [inherited]

Definition at line 94 of file RawRecord.cc.

00095 {
00096   // Is this a file end record?
00097   return (this->type()==RecordFormat::FileEnd::type);
00098 }

DayaBay::RawRecord * DayaBay::RawRecord::clone (  )  const [inherited]

Definition at line 100 of file RawRecord.cc.

00101 {
00102   // Make a full copy of this record
00103   unsigned int* newBuffer = 0;
00104   if(this->buffer()){
00105     unsigned int size = this->size();
00106     if( this->isDataSeparator() ){ 
00107       // Add additional lines for data block contents
00108       DayaBay::RawDataSeparator dataSeparator(this->buffer(), this->version());
00109       size += (dataSeparator.blockSize() + sizeof(unsigned int)-1)
00110               / sizeof(unsigned int);
00111     }
00112     if( size>0 ){
00113       memcpy( newBuffer, this->buffer(), size*sizeof(unsigned int) );
00114       if(!newBuffer) return 0;
00115     }
00116   }
00117   return DayaBay::RawRecord::makeNewRecord(newBuffer, m_version, 
00118                                            true /*isOwner*/);
00119 }

DayaBay::RawRecord * DayaBay::RawRecord::makeNewRecord ( unsigned int *  buffer = 0,
unsigned int  version = 0,
bool  isOwner = false 
) [static, inherited]

Definition at line 129 of file RawRecord.cc.

00132                                                                             {
00133   // Make a new record.  Automatically set the correct class type
00134   // using the type() defined in the raw record.
00135   // 
00136   // The caller is responsible for deleting the returned record.
00137   
00138   DayaBay::RawRecord* newRecord = 0;
00139   // Convert to the proper record type
00140   DayaBay::RawRecord rawRecord(buffer,version);
00141   if( rawRecord.isFileStart() ){
00142     newRecord = new DayaBay::RawFileStart(buffer, version, isOwner);
00143   }else if( rawRecord.isFileName() ){
00144     newRecord = new DayaBay::RawFileName(buffer, version, isOwner);
00145   }else if( rawRecord.isMetadata() ){
00146     newRecord = new DayaBay::RawMetadata(buffer, version, isOwner);
00147   }else if( rawRecord.isRunParameters() ){
00148     newRecord = new DayaBay::RawRunParameters(buffer, version, isOwner);
00149   }else if( rawRecord.isCalibrationParameters() ){
00150     newRecord = new DayaBay::RawCalibrationParameters(buffer, version, isOwner);
00151   }else if( rawRecord.isDataSeparator() ){
00152     newRecord = new DayaBay::RawDataSeparator(buffer, version, isOwner);
00153   }else if( rawRecord.isFileEnd() ){
00154     newRecord = new DayaBay::RawFileEnd(buffer, version, isOwner);
00155   }else{
00156     newRecord = new DayaBay::RawRecord(buffer, version, isOwner);
00157   }
00158   return newRecord;
00159 }

unsigned int * DayaBay::RawBuffer::buffer (  )  const [inherited]

Definition at line 52 of file RawBuffer.cc.

00053 {
00054   // Return the pointer to the internal memory buffer
00055   return m_buffer;
00056 }

unsigned int DayaBay::RawBuffer::bufferSize (  )  const [inherited]

Definition at line 58 of file RawBuffer.cc.

00059 {
00060   // Return the allocated size of the internal memory buffer, if known
00061   return m_bufferSize;
00062 }

bool DayaBay::RawBuffer::isOwner (  )  const [inherited]

Definition at line 64 of file RawBuffer.cc.

00065 {
00066   // Does this RawBuffer own this memory buffer?
00067   return m_isOwner;
00068 }

void DayaBay::RawBuffer::setOwner ( bool  isOwner = true  )  [inherited]

Definition at line 70 of file RawBuffer.cc.

00070                                                     {
00071   m_isOwner = isOwner;
00072 }

bool DayaBay::RawBuffer::isValid (  )  const [virtual, inherited]

Definition at line 74 of file RawBuffer.cc.

00075 {
00076   // Does this RawBuffer contain data?
00077   return (m_buffer != 0);
00078 }

unsigned int * DayaBay::RawBuffer::getPointer ( const unsigned int &  line  )  const [inherited]

Definition at line 80 of file RawBuffer.cc.

00081 {
00082   // Return a pointer to a specific line in the data block
00083   if(m_bufferSize>0 && line>=m_bufferSize) return 0;
00084   return (m_buffer + line);
00085 }

unsigned int DayaBay::RawBuffer::getValue ( const unsigned int &  line,
const unsigned int &  firstBit = 0,
const unsigned int &  bitLength = 32 
) const [inherited]

Definition at line 87 of file RawBuffer.cc.

00090 {
00091   // Read a value from the memory buffer
00092   // line = line number in the memory block (line = integer length)
00093   // firstBit = first bit to read (max=31)
00094   // bitLength =  length of bits to read (max=32)
00095   if(bitLength>32 || firstBit>31) return 0;
00096   unsigned int* pointer = this->getPointer(line);
00097   if(!pointer) return 0;
00098   // Catch request for full line
00099   if(firstBit==0 && bitLength==32) return *pointer;
00100   // Prepare bit mask
00101   unsigned int oneBit = 0x1;
00102   unsigned int mask = 0;
00103   for(unsigned int shift=0; shift<bitLength; shift++) 
00104     mask += (oneBit << shift);
00105   // Shift value, mask, and return
00106   return (*pointer >> firstBit) & mask;
00107 }

char * DayaBay::RawBuffer::getString ( const unsigned int &  line,
const unsigned int &  byteOffset = 0 
) const [inherited]

Definition at line 109 of file RawBuffer.cc.

00111 {
00112   // Return a char pointer to a specific byte in the data block
00113   // line = line number in the memory block (line = integer length)
00114   // byteOffset = offset if string starts at an uneven byte position (max=3)
00115   if(byteOffset>3) return 0;
00116   unsigned int* pointer = this->getPointer(line);
00117   if(!pointer) return 0;
00118   return (char*)(pointer + byteOffset);
00119 }


The documentation for this class was generated from the following files:
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Mon Apr 11 20:07:28 2011 for RawData by doxygen 1.4.7