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

In This Package:

DayaBay::RawFileEnd Class Reference

#include <RawRecord.h>

Inheritance diagram for DayaBay::RawFileEnd:

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

Public Member Functions

 RawFileEnd (unsigned int *buffer=0, unsigned int version=0, bool isOwner=false)
 RawFileEnd (DayaBay::RawRecord &record, bool adopt=false)
virtual ~RawFileEnd ()
unsigned int date () const
unsigned int time () const
unsigned int eventsInFile () const
unsigned int dataInFile () const
unsigned int eventsInRun () const
unsigned int dataInRun () const
unsigned int status () const
unsigned int end () 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 129 of file RawRecord.h.


Constructor & Destructor Documentation

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

Definition at line 548 of file RawRecord.cc.

00551   : RawRecord(buffer,version,isOwner)
00552 {
00553   // Default constructor
00554 }

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

Definition at line 556 of file RawRecord.cc.

00558   : RawRecord(record,adopt)
00559 {
00560   // Construct from another RawRecord
00561   // If adopt==true, then take over ownership of the 
00562   // memory buffer (if the input record is the current owner)
00563 }

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

Definition at line 565 of file RawRecord.cc.

00566 {
00567   // Destructor
00568 }


Member Function Documentation

unsigned int DayaBay::RawFileEnd::date (  )  const

Definition at line 570 of file RawRecord.cc.

00571 {
00572   return this->getValue(RecordFormat::FileEnd::dateLine);
00573 }

unsigned int DayaBay::RawFileEnd::time (  )  const

Definition at line 575 of file RawRecord.cc.

00576 {
00577   return this->getValue(RecordFormat::FileEnd::timeLine);
00578 }

unsigned int DayaBay::RawFileEnd::eventsInFile (  )  const

Definition at line 580 of file RawRecord.cc.

00581 {
00582   return this->getValue(RecordFormat::FileEnd::eventsInFileLine);
00583 }

unsigned int DayaBay::RawFileEnd::dataInFile (  )  const

Definition at line 585 of file RawRecord.cc.

00586 {
00587   return this->getValue(RecordFormat::FileEnd::dataInFileLine);
00588 }

unsigned int DayaBay::RawFileEnd::eventsInRun (  )  const

Definition at line 590 of file RawRecord.cc.

00591 {
00592   return this->getValue(RecordFormat::FileEnd::eventsInRunLine);
00593 }

unsigned int DayaBay::RawFileEnd::dataInRun (  )  const

Definition at line 595 of file RawRecord.cc.

00596 {
00597   return this->getValue(RecordFormat::FileEnd::dataInRunLine);
00598 }

unsigned int DayaBay::RawFileEnd::status (  )  const

Definition at line 600 of file RawRecord.cc.

00601 {
00602   return this->getValue(RecordFormat::FileEnd::statusLine);
00603 }

unsigned int DayaBay::RawFileEnd::end (  )  const

Definition at line 605 of file RawRecord.cc.

00606 {
00607   return this->getValue(RecordFormat::FileEnd::endLine);
00608 }

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

Reimplemented from DayaBay::RawRecord.

Definition at line 610 of file RawRecord.cc.

00610                                                   {
00611   // Print the record information
00612   str << "FileEnd {" << std::endl << "  ";
00613   this->RawRecord::dump(str);
00614   return str << "  date: " << this->date() << std::endl
00615              << "  time: " << this->time() << std::endl
00616              << "  eventsInFile: " << this->eventsInFile() << std::endl
00617              << "  dataInFile: " << this->dataInFile() << std::endl
00618              << "  eventsInRun: " << this->eventsInRun() << std::endl
00619              << "  dataInRun: " << this->dataInRun() << std::endl
00620              << "  status: " << this->status() << std::endl
00621              << "  end: " << std::hex << this->end() << std::dec << " }" 
00622              << std::endl;
00623 }

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