Jpp  18.4.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Protected Attributes | Friends | List of all members
JDB::JDatalogs_t Struct Reference

Container for datalog strings. More...

#include <JDatalogString.hh>

Inheritance diagram for JDB::JDatalogs_t:
std::vector< JDatalogString >

Public Member Functions

 JDatalogs_t (const std::initializer_list< std::string > &buffer={})
 Constructor. More...
 
 JDatalogs_t (const std::set< std::string > &buffer)
 Constructor. More...
 
void load (const std::string &file_name)
 Load message from input file. More...
 

Protected Attributes

std::set< std::stringsources
 

Friends

std::istream & operator>> (std::istream &in, JDatalogs_t &object)
 Read message from input. More...
 

Detailed Description

Container for datalog strings.

Definition at line 172 of file JDatalogString.hh.

Constructor & Destructor Documentation

JDB::JDatalogs_t::JDatalogs_t ( const std::initializer_list< std::string > &  buffer = {})
inline

Constructor.

Parameters
bufferlist of valid source names

Definition at line 180 of file JDatalogString.hh.

180  {}) :
181  sources(buffer)
182  {}
std::set< std::string > sources
JDB::JDatalogs_t::JDatalogs_t ( const std::set< std::string > &  buffer)
inline

Constructor.

Parameters
bufferlist of valid source names

Definition at line 190 of file JDatalogString.hh.

190  :
191  sources(buffer)
192  {}
std::set< std::string > sources

Member Function Documentation

void JDB::JDatalogs_t::load ( const std::string file_name)
inline

Load message from input file.

Parameters
file_namefile name

Definition at line 200 of file JDatalogString.hh.

201  {
202  using namespace std;
203  using namespace JPP;
204 
205  if (getFilenameExtension(file_name) == "log" ||
206  getFilenameExtension(file_name) == "txt") {
207 
208  ifstream in(file_name.c_str());
209 
210  in.ignore(numeric_limits<std::streamsize>::max(), '\n');
211 
212  in >> *this;
213 
214  in.close();
215 
216  } else if (getFilenameExtension(file_name) == "gz") {
217 
218  igzstream in(file_name.c_str());
219 
220  in.ignore(numeric_limits<std::streamsize>::max(), '\n');
221 
222  in >> *this;
223 
224  in.close();
225 
226  } else {
227 
228  THROW(JFileOpenException, "Invalid file name extension " << file_name);
229  }
230  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:712
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Definition: JCanberra.sh:48
std::string getFilenameExtension(const std::string &file_name)
Get file name extension, i.e. part after last JEEP::FILENAME_SEPARATOR if any.
Definition: JeepToolkit.hh:109

Friends And Related Function Documentation

std::istream& operator>> ( std::istream &  in,
JDatalogs_t object 
)
friend

Read message from input.

Parameters
ininput stream
objectmessages
Returns
input stream

Definition at line 240 of file JDatalogString.hh.

241  {
242  using namespace std;
243 
244  JDatalogString datalog;
245 
246  bool append = false;
247 
248  for (string buffer; getline(in, buffer); ) {
249 
250  istringstream is(buffer);
251 
252  if (is >> datalog.run >> datalog.utc >> datalog.source >> datalog.parameter) {
253 
254  append = false;
255 
256  if (SOURCE_NAMES(datalog.source) && !IGNORED_PARAMETER_NAMES(datalog.parameter)) {
257 
258  while (is.peek() != EOF && isspace((char) is.peek())) { is.ignore(1); }
259 
260  getline(is, datalog.data);
261 
262  // new datalog
263 
264  if (object.sources.empty() || object.sources.count(datalog.source) != 0) {
265 
266  object.push_back(datalog);
267 
268  append = true;
269  }
270  }
271 
272  } else if (append) {
273 
274  // append traling data to latest datalog
275 
276  if (!object.empty()) {
277  object.rbegin()->data.append(" " + buffer);
278  }
279  }
280  }
281  return in;
282  }
is
Definition: JDAQCHSM.chsm:167
Auxiliary data structure for datalog strings.
std::istream & getline(std::istream &in, JString &object)
Read string from input stream until end of line.
Definition: JString.hh:478
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Definition: JCanberra.sh:48
std::set< std::string > sources
const JKeywords SOURCE_NAMES
Valid source names.
const JKeywords IGNORED_PARAMETER_NAMES
Ignored parameter names.

Member Data Documentation

std::set<std::string> JDB::JDatalogs_t::sources
protected

Definition at line 285 of file JDatalogString.hh.


The documentation for this struct was generated from the following file: