00001 // ===================================================================== 00024 // ===================================================================== 00025 #ifndef CLDAQ__TSOFTWAREDATAFILEMODULE_HH 00026 #define CLDAQ__TSOFTWAREDATAFILEMODULE_HH 00027 00028 #include "Tglobals.h" 00029 #include "TSoftwareModule.hh" 00030 00031 class TDataSegment; 00032 class TDataElement; 00033 00034 00054 class TSoftwareDataFileModule 00055 : public TSoftwareModule 00056 { 00057 00058 private: 00059 enum { tDefaultBufferLength = 1048576 }; 00060 00061 private: 00062 Tstring theFileName; 00063 Tstring theSeparater; 00064 TdoubleList theChannel; 00065 Tint theBufferLength; 00066 Tint theNumberOfLine; 00067 TstringList theCommentStringList; 00068 Tifstream theInputFileStream; 00069 00070 public: 00071 TSoftwareDataFileModule( const Tstring& filename, Tint nchannel ); 00072 TSoftwareDataFileModule( const Tstring& filename, const TstringList& comment, Tint nchannel ); 00073 TSoftwareDataFileModule( const Tstring& filename, const Tstring& separater, Tint nchannel ); 00074 TSoftwareDataFileModule( const Tstring& filename, const TstringList& comment, const Tstring& separater, Tint nchannel ); 00075 TSoftwareDataFileModule( const TSoftwareDataFileModule& right ); 00076 ~TSoftwareDataFileModule(); 00077 00078 public: 00079 Tint Clear(); 00080 Tint Update(); 00081 Tint Initialize(); 00082 00083 public: 00084 Tvoid FillData( TDataElement& element, Tint channel ); 00085 00086 public: 00087 const TSoftwareDataFileModule& operator=( const TSoftwareDataFileModule& right ); 00088 Tbool operator==( const TSoftwareDataFileModule& right ) const; 00089 Tbool operator!=( const TSoftwareDataFileModule& right ) const; 00090 00091 public: 00092 const Tstring& GetFileName() const; 00093 const Tstring& GetSeparater() const; 00094 const TdoubleList& GetChannel() const; 00095 Tint GetBufferLength() const; 00096 const TstringList& GetCommentStringList() const; 00097 Tint GetNumberOfLine() const; 00098 Tifstream& GetInputFileStream(); 00099 Tvoid SetFileName( const Tstring& fname ); 00100 Tvoid SetSeparater( const Tstring& separater ); 00101 Tvoid SetChannel( const TdoubleList& channels ); 00102 Tvoid SetBufferLength( Tint buflen ); 00103 Tvoid SetCommentStringList( const TstringList& commentlist ); 00104 Tvoid SetNumberOfLine( Tint nline ); 00105 00106 private: 00107 const Tstring& eraseComment( Tstring& readline ) const; 00108 TdoubleList divideLine( Tstring readline ) const; 00109 Tint getNumberOfLine() const; 00110 00111 }; 00112 00113 inline const Tstring& TSoftwareDataFileModule::GetFileName() const 00114 { 00115 return theFileName; 00116 } 00117 00118 inline const Tstring& TSoftwareDataFileModule::GetSeparater() const 00119 { 00120 return theSeparater; 00121 } 00122 00123 inline const TdoubleList& TSoftwareDataFileModule::GetChannel() const 00124 { 00125 return theChannel; 00126 } 00127 00128 inline Tint TSoftwareDataFileModule::GetBufferLength() const 00129 { 00130 return theBufferLength; 00131 } 00132 00133 inline const TstringList& TSoftwareDataFileModule::GetCommentStringList() const 00134 { 00135 return theCommentStringList; 00136 } 00137 00138 inline Tint TSoftwareDataFileModule::GetNumberOfLine() const 00139 { 00140 return theNumberOfLine; 00141 } 00142 00143 inline Tifstream& TSoftwareDataFileModule::GetInputFileStream() 00144 { 00145 return theInputFileStream; 00146 } 00147 00148 inline Tvoid TSoftwareDataFileModule::SetFileName( const Tstring& fname ) 00149 { 00150 theFileName = fname; 00151 return; 00152 } 00153 00154 inline Tvoid TSoftwareDataFileModule::SetSeparater( const Tstring& separater ) 00155 { 00156 theSeparater = separater; 00157 return; 00158 } 00159 00160 inline Tvoid TSoftwareDataFileModule::SetChannel( const TdoubleList& channels ) 00161 { 00162 theChannel = channels; 00163 return; 00164 } 00165 00166 inline Tvoid TSoftwareDataFileModule::SetBufferLength( Tint buflen ) 00167 { 00168 theBufferLength = buflen; 00169 return; 00170 } 00171 00172 inline Tvoid TSoftwareDataFileModule::SetCommentStringList( const TstringList& commentlist ) 00173 { 00174 theCommentStringList = commentlist; 00175 return; 00176 } 00177 00178 inline Tvoid TSoftwareDataFileModule::SetNumberOfLine( Tint nline ) 00179 { 00180 theNumberOfLine = nline; 00181 return; 00182 } 00183 00184 #endif