// ============================================================================ // $Id$ // $Name$ // ============================================================================ #include "TDataRecord.hh" #include "TOutputObjectStream.hh" #include "TOutputObjectFile.hh" TDataRecord::TDataRecord( Tint id, Tint capacity ) : TStreamableObject( tDataRecord, id ), TDataSectionList( capacity, tDefaultReallocationParameter ) {;} TDataRecord::~TDataRecord() {;} Tvoid TDataRecord::Print( Tostream& tos ) { Tstring head = "* Data Record, "; tos << head << "ID: " << theID; tos << Twspace << "Capacity: " << theCapacity; tos << Twspace << "Entry: " << theNumberOfEntries << Tendl; for ( Tint i = 0; i < theNumberOfEntries; i ++ ) theObjects[ i ] -> Print( tos ); return; } Tint TDataRecord::GetDataSize() { Tsize_t total = Tsizeof( *this ); for ( Tint i = 0; i < theNumberOfEntries; i ++ ) total += (Tsize_t)( theObjects[ i ] -> GetDataSize() ); return( (Tint)total ); } Tint TDataRecord::WriteData( TOutputObjectStream* output ) { Tstream_t streamtype = output -> GetStreamType(); Tsize_t size = 0; if ( streamtype == tFileStream ) { static const Tsize_t nmemb = 1; TOutputObjectFile* ofile = (TOutputObjectFile*)output; size += fwrite( this, Tsizeof(*this), nmemb, ofile -> GetFileStream() ); } else if ( streamtype == tSocketStream ) { //now implement .... //TOutputObjectSocket* osocket = (TOutputObjectSocket*)output; ; } else if ( streamtype == tSharedMemoryStream ) { ; } else { // // ; } for ( Tint i = 0; i < theNumberOfEntries; i ++ ) size += (Tsize_t)( theObjects[ i ] -> WriteData( output ) ); return( (Tint)size ); }