00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef __TDATAELEMENT_HH
00011 #define __TDATAELEMENT_HH
00012
00013 #include "Tglobals.h"
00014 #include "TStreamableObject.hh"
00015
00016 class TOutputObjectStream;
00017 class TOutputObjectFile;
00018 class TOutputObjectSocket;
00019 class TOutputObjectSharedMemory;
00020
00021 class TDataElement
00022 : public TStreamableObject
00023 {
00024
00025 private:
00026 Tvoid* theData;
00027 Telement_t theElementType;
00028 Tint theNumberOfPrimitives;
00029
00030 public:
00031 TDataElement( Telement_t type = tTypeUnknown, const Tstring& id = TunknownID );
00032 TDataElement( Tvoid* data, Telement_t type, const Tstring& id = TunknownID, Tint ndata = 1 );
00033 TDataElement( const TDataElement& right );
00034 ~TDataElement();
00035
00036 public:
00037 Tint Record( TOutputObjectStream* output );
00038 Tint GetRecordSize();
00039 Tvoid FillData( Tvoid* data, Telement_t elementtype, Tint ndata = 1 );
00040 Tvoid FillData( Tvoid* data, Tint ndata = 1 );
00041 Tvoid Clear();
00042 Tint Serialize( Tvoid* buffer );
00043
00044 public:
00045 Tint* GetIntData() const;
00046 Tstring* GetStringData() const;
00047 Tdouble* GetDoubleData() const;
00048 Tfloat* GetFloatData() const;
00049 TUshort* GetUnsignedShortData() const;
00050 Tshort* GetShortData() const;
00051 Tlong* GetLongData() const;
00052 TUlong* GetUnsignedLongData() const;
00053 TUint* GetUnsignedIntData() const;
00054
00055 public:
00056 Tvoid* GetData() const;
00057 Telement_t GetElementType() const;
00058 Tint GetNumberOfPrimitives() const;
00059 Tvoid SetData( Tvoid* data );
00060 Tvoid SetElementType( Telement_t elementtype );
00061 Tvoid SetNumberOfPrimitives( Tint nprimitives );
00062
00063 public:
00064 Tint StorePrimitives( Tint* buffer, Tint narray = 0 ) const;
00065 Tint StorePrimitives( Tstring* buffer, Tint narray = 0 ) const;
00066 Tint StorePrimitives( Tdouble* buffer, Tint narray = 0 ) const;
00067 Tint StorePrimitives( Tfloat* buffer, Tint narray = 0 ) const;
00068 Tint StorePrimitives( TUshort* buffer, Tint narray = 0 ) const;
00069 Tint StorePrimitives( Tshort* buffer, Tint narray = 0 ) const;
00070 Tint StorePrimitives( Tlong* buffer, Tint narray = 0 ) const;
00071 Tint StorePrimitives( TUlong* buffer, Tint narray = 0 ) const;
00072 Tint StorePrimitives( TUint* buffer, Tint narray = 0 ) const;
00073
00074 public:
00075 const TDataElement& operator=( const TDataElement& right );
00076 Tbool operator==( const TDataElement& right ) const;
00077 Tbool operator!=( const TDataElement& right ) const;
00078 friend Tostream& operator<<( Tostream& tos, const TDataElement& right );
00079
00080 private:
00081 Tvoid freeDataSpace();
00082 Tvoid allocateDataSpace( Tvoid* data );
00083 Tint record( TOutputObjectFile* ofile );
00084 Tint record( TOutputObjectSocket* osocket );
00085 Tint record( TOutputObjectSharedMemory* omemory );
00086
00087 };
00088
00089 inline Tvoid* TDataElement::GetData() const
00090 {
00091 return( theData );
00092 }
00093
00094 inline Tvoid TDataElement::SetData( Tvoid* data )
00095 {
00096 theData = data;
00097 return;
00098 }
00099
00100 inline Telement_t TDataElement::GetElementType() const
00101 {
00102 return( theElementType );
00103 }
00104
00105 inline Tvoid TDataElement::SetElementType( Telement_t elementtype )
00106 {
00107 theElementType = elementtype;
00108 return;
00109 }
00110
00111 inline Tint TDataElement::GetNumberOfPrimitives() const
00112 {
00113 return( theNumberOfPrimitives );
00114 }
00115
00116 inline Tvoid TDataElement::SetNumberOfPrimitives( Tint nprimitives )
00117 {
00118 theNumberOfPrimitives = nprimitives;
00119 return;
00120 }
00121
00122 inline Tint* TDataElement::GetIntData() const
00123 {
00124 return( (Tint*)theData );
00125 }
00126
00127 inline Tstring* TDataElement::GetStringData() const
00128 {
00129 return( (Tstring*)theData );
00130 }
00131
00132 inline Tdouble* TDataElement::GetDoubleData() const
00133 {
00134 return( (Tdouble*)theData );
00135 }
00136
00137 inline Tfloat* TDataElement::GetFloatData() const
00138 {
00139 return( (Tfloat*)theData );
00140 }
00141
00142 inline TUshort* TDataElement::GetUnsignedShortData() const
00143 {
00144 return( (TUshort*)theData );
00145 }
00146
00147 inline Tshort* TDataElement::GetShortData() const
00148 {
00149 return( (Tshort*)theData );
00150 }
00151
00152 inline Tlong* TDataElement::GetLongData() const
00153 {
00154 return( (Tlong*)theData );
00155 }
00156
00157 inline TUlong* TDataElement::GetUnsignedLongData() const
00158 {
00159 return( (TUlong*)theData );
00160 }
00161
00162 inline TUint* TDataElement::GetUnsignedIntData() const
00163 {
00164 return( (TUint*)theData );
00165 }
00166
00167 inline Tvoid TDataElement::FillData( Tvoid* data, Telement_t elementtype, Tint ndata )
00168 {
00169 freeDataSpace();
00170 theElementType = elementtype;
00171 theNumberOfPrimitives = ndata;
00172 allocateDataSpace( data );
00173 return;
00174 }
00175
00176 inline Tvoid TDataElement::FillData( Tvoid* data, Tint ndata )
00177 {
00178 return( FillData( data, theElementType, ndata ) );
00179 }
00180
00181 #endif