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