00001
00060
00061 #ifndef CLDAQ__TDATAELEMENT_HH
00062 #define CLDAQ__TDATAELEMENT_HH
00063
00064 #include "Tglobals.h"
00065 #include "TStreamableObject.hh"
00066
00067 class TOutputObjectStream;
00068 class TOutputObjectFile;
00069 class TOutputObjectSocket;
00070 class TOutputObjectSharedMemory;
00071
00072
00092 class TDataElement
00093 : public TStreamableObject
00094 {
00095
00096 private:
00097 Tvoid* theData;
00098 Telement_t theElementType;
00099 Tint theNumberOfPrimitives;
00100
00101 public:
00102 TDataElement( Telement_t type = tTypeUnknown, const Tstring& id = TunknownID );
00103 TDataElement( Tvoid* data, Telement_t type, const Tstring& id = TunknownID, Tint ndata = 1 );
00104 TDataElement( const TDataElement& right );
00105 ~TDataElement();
00106
00107 public:
00108 Tint Record( TOutputObjectStream* output );
00109 Tint GetRecordSize();
00110 Tvoid FillData( Tvoid* data, Telement_t elementtype, Tint ndata = 1 );
00111 Tvoid FillData( Tvoid* data, Tint ndata = 1 );
00112 Tvoid Clear();
00113 Tint Serialize( const Tvoid* buffer );
00114 Tint Deserialize( const Tvoid* buffer );
00115
00117 Tint Size() const;
00118
00119 public:
00120 Tint* GetIntData() const;
00121 Tstring* GetStringData() const;
00122 Tdouble* GetDoubleData() const;
00123 Tfloat* GetFloatData() const;
00124 TUshort* GetUnsignedShortData() const;
00125 Tshort* GetShortData() const;
00126 Tlong* GetLongData() const;
00127 TUlong* GetUnsignedLongData() const;
00128 TUint* GetUnsignedIntData() const;
00129
00130 public:
00131 Tvoid* GetData() const;
00132 Telement_t GetElementType() const;
00133 Tint GetNumberOfPrimitives() const;
00134 Tvoid SetData( Tvoid* data );
00135 Tvoid SetElementType( Telement_t elementtype );
00136 Tvoid SetNumberOfPrimitives( Tint nprimitives );
00137
00138 public:
00139 Tint StorePrimitives( Tint* buffer, Tint narray = 0 ) const;
00140 Tint StorePrimitives( Tstring* buffer, Tint narray = 0 ) const;
00141 Tint StorePrimitives( Tdouble* buffer, Tint narray = 0 ) const;
00142 Tint StorePrimitives( Tfloat* buffer, Tint narray = 0 ) const;
00143 Tint StorePrimitives( TUshort* buffer, Tint narray = 0 ) const;
00144 Tint StorePrimitives( Tshort* buffer, Tint narray = 0 ) const;
00145 Tint StorePrimitives( Tlong* buffer, Tint narray = 0 ) const;
00146 Tint StorePrimitives( TUlong* buffer, Tint narray = 0 ) const;
00147 Tint StorePrimitives( TUint* buffer, Tint narray = 0 ) const;
00148 Tvoid StorePrimitive( Tint& buffer ) const;
00149 Tvoid StorePrimitive( Tstring& buffer ) const;
00150 Tvoid StorePrimitive( Tdouble& buffer ) const;
00151 Tvoid StorePrimitive( Tfloat& buffer ) const;
00152 Tvoid StorePrimitive( TUshort& buffer ) const;
00153 Tvoid StorePrimitive( Tshort& buffer ) const;
00154 Tvoid StorePrimitive( Tlong& buffer ) const;
00155 Tvoid StorePrimitive( TUlong& buffer ) const;
00156 Tvoid StorePrimitive( TUint& buffer ) const;
00157
00158 public:
00159 const TDataElement& operator=( const TDataElement& right );
00160 Tbool operator==( const TDataElement& right ) const;
00161 Tbool operator!=( const TDataElement& right ) const;
00162 Tbool operator==( const Tstring& right ) const;
00163 Tbool operator!=( const Tstring& right ) const;
00164 friend Tostream& operator<<( Tostream& tos, const TDataElement& right );
00165
00166 private:
00167 Tvoid freeDataSpace();
00168 Tvoid allocateDataSpace( Tvoid* data );
00169 Tint record( TOutputObjectFile* ofile );
00170 Tint record( TOutputObjectSocket* osocket );
00171 Tint record( TOutputObjectSharedMemory* omemory );
00172
00173 #ifdef __CLDAQ_ROOT_DLL
00174 ClassDef(TDataElement,0)
00175 #endif
00176
00177 };
00178
00179 inline Tvoid* TDataElement::GetData() const
00180 {
00181 return theData;
00182 }
00183
00184 inline Tvoid TDataElement::SetData( Tvoid* data )
00185 {
00186 theData = data;
00187 return;
00188 }
00189
00190 inline Telement_t TDataElement::GetElementType() const
00191 {
00192 return theElementType;
00193 }
00194
00195 inline Tvoid TDataElement::SetElementType( Telement_t elementtype )
00196 {
00197 theElementType = elementtype;
00198 return;
00199 }
00200
00201 inline Tint TDataElement::GetNumberOfPrimitives() const
00202 {
00203 return theNumberOfPrimitives;
00204 }
00205
00206 inline Tvoid TDataElement::SetNumberOfPrimitives( Tint nprimitives )
00207 {
00208 theNumberOfPrimitives = nprimitives;
00209 return;
00210 }
00211
00212 inline Tint* TDataElement::GetIntData() const
00213 {
00214 return (Tint*)theData;
00215 }
00216
00217 inline Tstring* TDataElement::GetStringData() const
00218 {
00219 return (Tstring*)theData;
00220 }
00221
00222 inline Tdouble* TDataElement::GetDoubleData() const
00223 {
00224 return (Tdouble*)theData;
00225 }
00226
00227 inline Tfloat* TDataElement::GetFloatData() const
00228 {
00229 return (Tfloat*)theData;
00230 }
00231
00232 inline TUshort* TDataElement::GetUnsignedShortData() const
00233 {
00234 return (TUshort*)theData;
00235 }
00236
00237 inline Tshort* TDataElement::GetShortData() const
00238 {
00239 return (Tshort*)theData;
00240 }
00241
00242 inline Tlong* TDataElement::GetLongData() const
00243 {
00244 return (Tlong*)theData;
00245 }
00246
00247 inline TUlong* TDataElement::GetUnsignedLongData() const
00248 {
00249 return (TUlong*)theData;
00250 }
00251
00252 inline TUint* TDataElement::GetUnsignedIntData() const
00253 {
00254 return (TUint*)theData;
00255 }
00256
00257 inline Tvoid TDataElement::FillData( Tvoid* data, Telement_t elementtype, Tint ndata )
00258 {
00259 freeDataSpace();
00260 theElementType = elementtype;
00261 theNumberOfPrimitives = ndata;
00262 allocateDataSpace( data );
00263 return;
00264 }
00265
00266 inline Tvoid TDataElement::FillData( Tvoid* data, Tint ndata )
00267 {
00268 return FillData( data, theElementType, ndata );
00269 }
00270
00271 inline Tint TDataElement::Size() const
00272 {
00273 return GetNumberOfPrimitives();
00274 }
00275
00276 #endif