# PhasicFlow: src/MotionModel/entities/timeInterval/timeInterval.cpp Source File

timeInterval.cpp
Go to the documentation of this file.
#include "timeInterval.hpp"
#include "dictionary.hpp"
FUNCTION_H
pFlow::timeInterval::timeInterval(const dictionary& dict)
{
if(!read(dict))
{
fatalExit;
}
}
FUNCTION_H
bool pFlow::timeInterval::read(const dictionary& dict)
{
startTime_ = dict.getValOrSet<real>("startTime", 0);
endTime_ = dict.getValOrSet<real>("endTime", largeValue);
return true;
}
FUNCTION_H
bool pFlow::timeInterval::write(dictionary& dict) const
{
if( !dict.add("startTime", startTime_) )
{
fatalErrorInFunction<<
" error in writing startTime to dictionary "<< dict.globalName()<<endl;
return false;
}
if( !dict.add("endTime", endTime_) )
{
fatalErrorInFunction<<
" error in writing endTime to dictionary "<< dict.globalName()<<endl;
return false;
}
return true;
}
FUNCTION_H
bool pFlow::timeInterval::read(iIstream& is)
{
word key;
real val;
is >> key >> val;
if(key != "startTime")
{
ioErrorInFile(is.name(), is.lineNumber())<<
" expected startTime but found "<< key <<endl;
return false;
}
else
startTime_ = val;
is.readEndStatement(FUNCTION_NAME);
is >> key >> val;
if(key != "endTime")
{
ioErrorInFile(is.name(), is.lineNumber())<<
" expected endTime but found "<< key <<endl;
return false;
}
else
endTime_ = val;
is.readEndStatement(FUNCTION_NAME);
return true;
}
FUNCTION_H
bool pFlow::timeInterval::write(iOstream& os)const
{
os.writeWordEntry("startTime", startTime_);
os.writeWordEntry("endTime", endTime_);
return os.check(FUNCTION_NAME);
}
timeInterval.hpp
pFlow::dictionary::getValOrSet
T getValOrSet(const word &keyword, const T &setVal) const
Definition: dictionary.hpp:325
pFlow::real
float real
Definition: builtinTypes.hpp:46
fatalExit
#define fatalExit
Definition: error.hpp:57
pFlow::timeInterval::write
FUNCTION_H bool write(dictionary &dict) const
Definition: timeInterval.cpp:26
pFlow::word
std::string word
Definition: builtinTypes.hpp:63
pFlow::iIstream::readEndStatement
char readEndStatement(const char *funcName)
Definition: iIstream.cpp:324
FUNCTION_NAME
#define FUNCTION_NAME
Definition: pFlowMacros.hpp:29
pFlow::dictionary::globalName
virtual word globalName() const
Definition: dictionary.cpp:349
pFlow::dictionary::add
bool add(const word &keyword, const float &v)
Definition: dictionary.cpp:422
pFlow::timeInterval::read
FUNCTION_H bool read(const dictionary &dict)
Definition: timeInterval.cpp:17
pFlow::endl
iOstream & endl(iOstream &os)
Definition: iOstream.hpp:312
pFlow::IOstream::check
virtual bool check(const char *operation) const
Definition: IOstream.cpp:42
FUNCTION_H
#define FUNCTION_H
Definition: pFlowMacros.hpp:58
pFlow::iIstream
Definition: iIstream.hpp:33
fatalErrorInFunction
#define fatalErrorInFunction
Definition: error.hpp:42
pFlow::timeInterval::timeInterval
INLINE_FUNCTION_HD timeInterval()
Definition: timeInterval.hpp:30
dictionary.hpp
pFlow::IOstream::name
virtual const word & name() const
Definition: IOstream.cpp:31
ioErrorInFile
#define ioErrorInFile(fileName, lineNumber)
Definition: error.hpp:49
pFlow::IOstream::lineNumber
int32 lineNumber() const
Definition: IOstream.hpp:187
pFlow::largeValue
const real largeValue
Definition: numericConstants.hpp:35
pFlow::iOstream
Definition: iOstream.hpp:53
pFlow::iOstream::writeWordEntry
iOstream & writeWordEntry(const word &key, const T &value)
Definition: iOstream.hpp:217
pFlow::dictionary
Definition: dictionary.hpp:38