www.cemf.ir
timeInterval.cpp
Go to the documentation of this file.
1 
2 
3 #include "timeInterval.hpp"
4 #include "dictionary.hpp"
5 
8 {
9  if(!read(dict))
10  {
11  fatalExit;
12  }
13 }
14 
15 
18 {
19  startTime_ = dict.getValOrSet<real>("startTime", 0);
20  endTime_ = dict.getValOrSet<real>("endTime", largeValue);
21 
22  return true;
23 }
24 
27 {
28  if( !dict.add("startTime", startTime_) )
29  {
31  " error in writing startTime to dictionary "<< dict.globalName()<<endl;
32  return false;
33  }
34 
35  if( !dict.add("endTime", endTime_) )
36  {
38  " error in writing endTime to dictionary "<< dict.globalName()<<endl;
39  return false;
40  }
41 
42  return true;
43 }
44 
47 {
48  word key;
49  real val;
50 
51  is >> key >> val;
52  if(key != "startTime")
53  {
54  ioErrorInFile(is.name(), is.lineNumber())<<
55  " expected startTime but found "<< key <<endl;
56  return false;
57  }
58  else
59  startTime_ = val;
60 
62 
63  is >> key >> val;
64  if(key != "endTime")
65  {
66  ioErrorInFile(is.name(), is.lineNumber())<<
67  " expected endTime but found "<< key <<endl;
68  return false;
69  }
70  else
71  endTime_ = val;
72 
74 
75  return true;
76 }
77 
80 {
81  os.writeWordEntry("startTime", startTime_);
82  os.writeWordEntry("endTime", endTime_);
83  return os.check(FUNCTION_NAME);
84 }
timeInterval.hpp
pFlow::dictionary::getValOrSet
T getValOrSet(const word &keyword, const T &setVal) const
get the value of data entry or if not found, set the value to setVal
Definition: dictionary.hpp:415
pFlow::real
float real
Definition: builtinTypes.hpp:45
fatalExit
#define fatalExit
Fatal exit.
Definition: error.hpp:98
pFlow::timeInterval::write
FUNCTION_H bool write(dictionary &dict) const
Definition: timeInterval.cpp:26
pFlow::word
std::string word
Definition: builtinTypes.hpp:64
pFlow::iIstream::readEndStatement
char readEndStatement(const char *funcName)
End statement character ;.
Definition: iIstream.cpp:359
FUNCTION_NAME
#define FUNCTION_NAME
Definition: pFlowMacros.hpp:29
pFlow::dictionary::globalName
virtual word globalName() const
global name of entry, separated with dots
Definition: dictionary.cpp:356
pFlow::dictionary::add
bool add(const word &keyword, const float &v)
add a float dataEntry
Definition: dictionary.cpp:435
pFlow::timeInterval::read
FUNCTION_H bool read(const dictionary &dict)
Definition: timeInterval.cpp:17
pFlow::endl
iOstream & endl(iOstream &os)
Add newline and flush stream.
Definition: iOstream.hpp:341
pFlow::IOstream::check
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.cpp:42
FUNCTION_H
#define FUNCTION_H
Definition: pFlowMacros.hpp:62
pFlow::iIstream
Interface class for any input stream
Definition: iIstream.hpp:37
fatalErrorInFunction
#define fatalErrorInFunction
Report a fatal error and function name and exit the application.
Definition: error.hpp:77
pFlow::timeInterval::timeInterval
INLINE_FUNCTION_HD timeInterval()
Definition: timeInterval.hpp:30
dictionary.hpp
pFlow::IOstream::name
virtual const word & name() const
Return the name of the stream.
Definition: IOstream.cpp:31
ioErrorInFile
#define ioErrorInFile(fileName, lineNumber)
Report an error in file operation with supplied fileName and lineNumber.
Definition: error.hpp:87
pFlow::IOstream::lineNumber
int32 lineNumber() const
Const access to the current stream line number.
Definition: IOstream.hpp:223
pFlow::largeValue
const real largeValue
Definition: numericConstants.hpp:33
pFlow::iOstream
Interface class for any output stream.
Definition: iOstream.hpp:59
pFlow::iOstream::writeWordEntry
iOstream & writeWordEntry(const word &key, const T &value)
Write a keyword/value entry.
Definition: iOstream.hpp:239
pFlow::dictionary
Dictionary holds a set of data entries or sub-dictionaries that are enclosed in a curely braces or ar...
Definition: dictionary.hpp:67