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

TDataElement.hh

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

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