TDataElement.hh Source File

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

# TDataElement.hh

解説を見る。

    00001 // =====================================================================
    00002 //  $Id: TDataElement.hh,v 1.3 2003/08/20 21:49:02 goiwai Exp $
    00003 //  $Name: CLDAQ-1-08-00 $
    00004 //
    00005 //  $Log: TDataElement.hh,v $
    00006 //  Revision 1.3  2003/08/20 21:49:02  goiwai
    00007 //  TDataElementクラスにStorePrimitive()メソッドを追加しました.
    00008 //  StorePrimitives()という似たようなメソッドもありますが,こちらは,1つ以上
    00009 //  プリミティブデータを取得するメソッドであるのに対して,この
    00010 //  StorePrimitive()メソッドは1つのデータのみ取得します.
    00011 //
    00012 //    type data;
    00013 //    element.StorePrimitives( &data );
    00014 //    // ----
    00015 //    type data;
    00016 //    element.StorePrimitive( data );
    00017 //
    00018 //  上のふたつの処理は同じ動作をします.
    00019 //  型は内部で解決される(その分遅い)ので,特に気にする必要はありません.
    00020 //
    00021 //  Revision 1.2  2003/07/30 16:17:51  goiwai
    00022 //  ファイルにコミットログをつけることにしました.
    00023 //
    00024 // =====================================================================
    00025 #ifndef __TDATAELEMENT_HH
    00026 #define __TDATAELEMENT_HH
    00027
    00028 #include "Tglobals.h"
    00029 #include "TStreamableObject.hh"
    00030
    00031 class TOutputObjectStream;
    00032 class TOutputObjectFile;
    00033 class TOutputObjectSocket;
    00034 class TOutputObjectSharedMemory;
    00035
    00036 class TDataElement
    00037   : public TStreamableObject
    00038 {
    00039
    00040   private:
    00041     Tvoid* theData;
    00042     Telement_t theElementType;
    00043     Tint theNumberOfPrimitives;
    00044
    00045   public:
    00046     TDataElement( Telement_t type = tTypeUnknown, const Tstring& id = TunknownID );
    00047     TDataElement( Tvoid* data, Telement_t type, const Tstring& id = TunknownID, Tint ndata = 1 );
    00048     TDataElement( const TDataElement& right );
    00049     ~TDataElement();
    00050
    00051   public:
    00052     Tint Record( TOutputObjectStream* output );
    00053     Tint GetRecordSize();
    00054     Tvoid FillData( Tvoid* data, Telement_t elementtype, Tint ndata = 1 );
    00055     Tvoid FillData( Tvoid* data, Tint ndata = 1 );
    00056     Tvoid Clear();
    00057     Tint Serialize( Tvoid* buffer );
    00058
    00059   public:
    00060     Tint* GetIntData() const;
    00061     Tstring* GetStringData() const;
    00062     Tdouble* GetDoubleData() const;
    00063     Tfloat* GetFloatData() const;
    00064     TUshort* GetUnsignedShortData() const;
    00065     Tshort* GetShortData() const;
    00066     Tlong* GetLongData() const;
    00067     TUlong* GetUnsignedLongData() const;
    00068     TUint* GetUnsignedIntData() const;
    00069
    00070   public:
    00071     Tvoid* GetData() const;
    00072     Telement_t GetElementType() const;
    00073     Tint GetNumberOfPrimitives() const;
    00074     Tvoid SetData( Tvoid* data );
    00075     Tvoid SetElementType( Telement_t elementtype );
    00076     Tvoid SetNumberOfPrimitives( Tint nprimitives );
    00077
    00078   public:
    00079     Tint StorePrimitives( Tint* buffer, Tint narray = 0 ) const;
    00080     Tint StorePrimitives( Tstring* buffer, Tint narray = 0 ) const;
    00081     Tint StorePrimitives( Tdouble* buffer, Tint narray = 0 ) const;
    00082     Tint StorePrimitives( Tfloat* buffer, Tint narray = 0 ) const;
    00083     Tint StorePrimitives( TUshort* buffer, Tint narray = 0 ) const;
    00084     Tint StorePrimitives( Tshort* buffer, Tint narray = 0 ) const;
    00085     Tint StorePrimitives( Tlong* buffer, Tint narray = 0 ) const;
    00086     Tint StorePrimitives( TUlong* buffer, Tint narray = 0 ) const;
    00087     Tint StorePrimitives( TUint* buffer, Tint narray = 0 ) const;
    00088     Tvoid StorePrimitive( Tint& buffer ) const;
    00089     Tvoid StorePrimitive( Tstring& buffer ) const;
    00090     Tvoid StorePrimitive( Tdouble& buffer ) const;
    00091     Tvoid StorePrimitive( Tfloat& buffer ) const;
    00092     Tvoid StorePrimitive( TUshort& buffer ) const;
    00093     Tvoid StorePrimitive( Tshort& buffer ) const;
    00094     Tvoid StorePrimitive( Tlong& buffer ) const;
    00095     Tvoid StorePrimitive( TUlong& buffer ) const;
    00096     Tvoid StorePrimitive( TUint& buffer ) const;
    00097
    00098   public:
    00099     const TDataElement& operator=( const TDataElement& right );
    00100     Tbool operator==( const TDataElement& right ) const;
    00101     Tbool operator!=( const TDataElement& right ) const;
    00102     friend Tostream& operator<<( Tostream& tos, const TDataElement& right );
    00103
    00104   private:
    00105     Tvoid freeDataSpace();
    00106     Tvoid allocateDataSpace( Tvoid* data );
    00107     Tint record( TOutputObjectFile* ofile );
    00108     Tint record( TOutputObjectSocket* osocket );
    00109     Tint record( TOutputObjectSharedMemory* omemory );
    00110
    00111 };
    00112
    00113 inline Tvoid* TDataElement::GetData() const
    00114 {
    00115   return( theData );
    00116 }
    00117
    00118 inline Tvoid TDataElement::SetData( Tvoid* data )
    00119 {
    00120   theData = data;
    00121   return;
    00122 }
    00123
    00124 inline Telement_t TDataElement::GetElementType() const
    00125 {
    00126   return( theElementType );
    00127 }
    00128
    00129 inline Tvoid TDataElement::SetElementType( Telement_t elementtype )
    00130 {
    00131   theElementType = elementtype;
    00132   return;
    00133 }
    00134
    00135 inline Tint TDataElement::GetNumberOfPrimitives() const
    00136 {
    00137   return( theNumberOfPrimitives );
    00138 }
    00139
    00140 inline Tvoid TDataElement::SetNumberOfPrimitives( Tint nprimitives )
    00141 {
    00142   theNumberOfPrimitives = nprimitives;
    00143   return;
    00144 }
    00145
    00146 inline Tint* TDataElement::GetIntData() const
    00147 {
    00148   return( (Tint*)theData );
    00149 }
    00150
    00151 inline Tstring* TDataElement::GetStringData() const
    00152 {
    00153   return( (Tstring*)theData );
    00154 }
    00155
    00156 inline Tdouble* TDataElement::GetDoubleData() const
    00157 {
    00158   return( (Tdouble*)theData );
    00159 }
    00160
    00161 inline Tfloat* TDataElement::GetFloatData() const
    00162 {
    00163   return( (Tfloat*)theData );
    00164 }
    00165
    00166 inline TUshort* TDataElement::GetUnsignedShortData() const
    00167 {
    00168   return( (TUshort*)theData );
    00169 }
    00170
    00171 inline Tshort* TDataElement::GetShortData() const
    00172 {
    00173   return( (Tshort*)theData );
    00174 }
    00175
    00176 inline Tlong* TDataElement::GetLongData() const
    00177 {
    00178   return( (Tlong*)theData );
    00179 }
    00180
    00181 inline TUlong* TDataElement::GetUnsignedLongData() const
    00182 {
    00183   return( (TUlong*)theData );
    00184 }
    00185
    00186 inline TUint* TDataElement::GetUnsignedIntData() const
    00187 {
    00188   return( (TUint*)theData );
    00189 }
    00190
    00191 inline Tvoid TDataElement::FillData( Tvoid* data, Telement_t elementtype, Tint ndata )
    00192 {
    00193   freeDataSpace();
    00194   theElementType = elementtype;
    00195   theNumberOfPrimitives = ndata;
    00196   allocateDataSpace( data );
    00197   return;
    00198 }
    00199
    00200 inline Tvoid TDataElement::FillData( Tvoid* data, Tint ndata )
    00201 {
    00202   return( FillData( data, theElementType, ndata ) );
    00203 }
    00204
    00205 #endif