メインページ   モジュール   名前空間一覧   クラス階層   アルファベット順一覧   構成   ファイル一覧   構成メンバ   ファイルメンバ   関連ページ    

TDataElement.hh

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

CLDAQ - a Class Library for Data AcQuisition (Version 1.12.0)
Go IWAI <goiwai@users.sourceforge.jp>