TDataElement.hh Source File

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

# TDataElement.hh

解説を見る。

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