00001
00036
00037 #ifndef __TDATAELEMENT_HH
00038 #define __TDATAELEMENT_HH
00039
00040 #include "Tglobals.h"
00041 #include "TStreamableObject.hh"
00042
00043 class TOutputObjectStream;
00044 class TOutputObjectFile;
00045 class TOutputObjectSocket;
00046 class TOutputObjectSharedMemory;
00047
00048
00068 class TDataElement
00069 : public TStreamableObject
00070 {
00071
00072 private:
00073 Tvoid* theData;
00074 Telement_t theElementType;
00075 Tint theNumberOfPrimitives;
00076
00077 public:
00078 TDataElement( Telement_t type = tTypeUnknown, const Tstring& id = TunknownID );
00079 TDataElement( Tvoid* data, Telement_t type, const Tstring& id = TunknownID, Tint ndata = 1 );
00080 TDataElement( const TDataElement& right );
00081 ~TDataElement();
00082
00083 public:
00084 Tint Record( TOutputObjectStream* output );
00085 Tint GetRecordSize();
00086 Tvoid FillData( Tvoid* data, Telement_t elementtype, Tint ndata = 1 );
00087 Tvoid FillData( Tvoid* data, Tint ndata = 1 );
00088 Tvoid Clear();
00089 Tint Serialize( Tvoid* buffer );
00090
00091 public:
00092 Tint* GetIntData() const;
00093 Tstring* GetStringData() const;
00094 Tdouble* GetDoubleData() const;
00095 Tfloat* GetFloatData() const;
00096 TUshort* GetUnsignedShortData() const;
00097 Tshort* GetShortData() const;
00098 Tlong* GetLongData() const;
00099 TUlong* GetUnsignedLongData() const;
00100 TUint* GetUnsignedIntData() const;
00101
00102 public:
00103 Tvoid* GetData() const;
00104 Telement_t GetElementType() const;
00105 Tint GetNumberOfPrimitives() const;
00106 Tvoid SetData( Tvoid* data );
00107 Tvoid SetElementType( Telement_t elementtype );
00108 Tvoid SetNumberOfPrimitives( Tint nprimitives );
00109
00110 public:
00111 Tint StorePrimitives( Tint* buffer, Tint narray = 0 ) const;
00112 Tint StorePrimitives( Tstring* buffer, Tint narray = 0 ) const;
00113 Tint StorePrimitives( Tdouble* buffer, Tint narray = 0 ) const;
00114 Tint StorePrimitives( Tfloat* buffer, Tint narray = 0 ) const;
00115 Tint StorePrimitives( TUshort* buffer, Tint narray = 0 ) const;
00116 Tint StorePrimitives( Tshort* buffer, Tint narray = 0 ) const;
00117 Tint StorePrimitives( Tlong* buffer, Tint narray = 0 ) const;
00118 Tint StorePrimitives( TUlong* buffer, Tint narray = 0 ) const;
00119 Tint StorePrimitives( TUint* buffer, Tint narray = 0 ) const;
00120 Tvoid StorePrimitive( Tint& buffer ) const;
00121 Tvoid StorePrimitive( Tstring& buffer ) const;
00122 Tvoid StorePrimitive( Tdouble& buffer ) const;
00123 Tvoid StorePrimitive( Tfloat& buffer ) const;
00124 Tvoid StorePrimitive( TUshort& buffer ) const;
00125 Tvoid StorePrimitive( Tshort& buffer ) const;
00126 Tvoid StorePrimitive( Tlong& buffer ) const;
00127 Tvoid StorePrimitive( TUlong& buffer ) const;
00128 Tvoid StorePrimitive( TUint& buffer ) const;
00129
00130 public:
00131 const TDataElement& operator=( const TDataElement& right );
00132 Tbool operator==( const TDataElement& right ) const;
00133 Tbool operator!=( const TDataElement& right ) const;
00134 friend Tostream& operator<<( Tostream& tos, const TDataElement& right );
00135
00136 private:
00137 Tvoid freeDataSpace();
00138 Tvoid allocateDataSpace( Tvoid* data );
00139 Tint record( TOutputObjectFile* ofile );
00140 Tint record( TOutputObjectSocket* osocket );
00141 Tint record( TOutputObjectSharedMemory* omemory );
00142
00143 };
00144
00145 inline Tvoid* TDataElement::GetData() const
00146 {
00147 return theData;
00148 }
00149
00150 inline Tvoid TDataElement::SetData( Tvoid* data )
00151 {
00152 theData = data;
00153 return;
00154 }
00155
00156 inline Telement_t TDataElement::GetElementType() const
00157 {
00158 return theElementType;
00159 }
00160
00161 inline Tvoid TDataElement::SetElementType( Telement_t elementtype )
00162 {
00163 theElementType = elementtype;
00164 return;
00165 }
00166
00167 inline Tint TDataElement::GetNumberOfPrimitives() const
00168 {
00169 return theNumberOfPrimitives;
00170 }
00171
00172 inline Tvoid TDataElement::SetNumberOfPrimitives( Tint nprimitives )
00173 {
00174 theNumberOfPrimitives = nprimitives;
00175 return;
00176 }
00177
00178 inline Tint* TDataElement::GetIntData() const
00179 {
00180 return (Tint*)theData;
00181 }
00182
00183 inline Tstring* TDataElement::GetStringData() const
00184 {
00185 return (Tstring*)theData;
00186 }
00187
00188 inline Tdouble* TDataElement::GetDoubleData() const
00189 {
00190 return (Tdouble*)theData;
00191 }
00192
00193 inline Tfloat* TDataElement::GetFloatData() const
00194 {
00195 return (Tfloat*)theData;
00196 }
00197
00198 inline TUshort* TDataElement::GetUnsignedShortData() const
00199 {
00200 return (TUshort*)theData;
00201 }
00202
00203 inline Tshort* TDataElement::GetShortData() const
00204 {
00205 return (Tshort*)theData;
00206 }
00207
00208 inline Tlong* TDataElement::GetLongData() const
00209 {
00210 return (Tlong*)theData;
00211 }
00212
00213 inline TUlong* TDataElement::GetUnsignedLongData() const
00214 {
00215 return (TUlong*)theData;
00216 }
00217
00218 inline TUint* TDataElement::GetUnsignedIntData() const
00219 {
00220 return (TUint*)theData;
00221 }
00222
00223 inline Tvoid TDataElement::FillData( Tvoid* data, Telement_t elementtype, Tint ndata )
00224 {
00225 freeDataSpace();
00226 theElementType = elementtype;
00227 theNumberOfPrimitives = ndata;
00228 allocateDataSpace( data );
00229 return;
00230 }
00231
00232 inline Tvoid TDataElement::FillData( Tvoid* data, Tint ndata )
00233 {
00234 return FillData( data, theElementType, ndata );
00235 }
00236
00237 #endif