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

In This Package:

DayaBay::RawDataSeparator Class Reference

#include <RawRecord.h>

Inheritance diagram for DayaBay::RawDataSeparator:

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

Public Member Functions

 RawDataSeparator (unsigned int *buffer=0, unsigned int version=0, bool isOwner=false)
 RawDataSeparator (DayaBay::RawRecord &record, bool adopt=false)
virtual ~RawDataSeparator ()
unsigned int blockNumber () const
unsigned int blockSize () const
DayaBay::RawDatadata () 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 117 of file RawRecord.h.


Constructor & Destructor Documentation

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

Definition at line 499 of file RawRecord.cc.

00502   : RawRecord(buffer,version,isOwner)
00503 {
00504   // Default constructor
00505 }

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

Definition at line 507 of file RawRecord.cc.

00509   : RawRecord(record,adopt)
00510 {
00511   // Construct from another RawRecord
00512   // If adopt==true, then take over ownership of the 
00513   // memory buffer (if the input record is the current owner)
00514 }

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

Definition at line 516 of file RawRecord.cc.

00517 {
00518   // Destructor
00519 }


Member Function Documentation

unsigned int DayaBay::RawDataSeparator::blockNumber (  )  const

Definition at line 521 of file RawRecord.cc.

00522 {
00523   return this->getValue(RecordFormat::DataSeparator::blockNumberLine);
00524 }

unsigned int DayaBay::RawDataSeparator::blockSize (  )  const

Definition at line 526 of file RawRecord.cc.

00527 {
00528   return this->getValue(RecordFormat::DataSeparator::blockSizeLine);
00529 }

DayaBay::RawData * DayaBay::RawDataSeparator::data (  )  const

Definition at line 531 of file RawRecord.cc.

00532 {
00533   return DayaBay::RawData::makeNewData(
00534                this->getPointer(RecordFormat::DataSeparator::dataLine));
00535 }

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

Reimplemented from DayaBay::RawRecord.

Definition at line 537 of file RawRecord.cc.

00537                                                         {
00538   // Print the record information
00539   str << "DataSeparator {" << std::endl << "  ";
00540   this->RawRecord::dump(str);
00541   return str << "  blockNumber: " << this->blockNumber() << std::endl
00542              << "  blockSize: " << this->blockSize() << " }" << std::endl;
00543 }

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:29 2011 for RawData by doxygen 1.4.7