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

timeInterval.hpp
Go to the documentation of this file.
#ifndef __timeInterval_hpp__
#define __timeInterval_hpp__
#include "types.hpp"
#include "pFlowMacros.hpp"
namespace pFlow
{
// forward
class dictionary;
class timeInterval
{
protected:
real startTime_ = 0;
real endTime_ = largeValue;
real time_=0;
bool isInInterval_ = true;
public:
INLINE_FUNCTION_HD
timeInterval(){}
INLINE_FUNCTION_HD
timeInterval(const timeInterval&) = default;
INLINE_FUNCTION_HD
timeInterval& operator=(const timeInterval&) = default;
FUNCTION_H
timeInterval(const dictionary& dict);
INLINE_FUNCTION_HD
~timeInterval() = default;
INLINE_FUNCTION_HD
auto startTime()const
{
return startTime_;
}
INLINE_FUNCTION_HD
auto endTime()const
{
return endTime_;
}
INLINE_FUNCTION_HD
auto time()const
{
return time_;
}
INLINE_FUNCTION_HD
void setTime(real t)
{
isInInterval_ = inTimeRange(t);
time_ = t;
}
INLINE_FUNCTION_HD
bool inTimeRange(real t)const
{
return t>= startTime_ && t<= endTime_;
}
INLINE_FUNCTION_HD
bool inTimeRange()const
{
return isInInterval_;
}
// - IO operation
FUNCTION_H
bool read(const dictionary& dict);
FUNCTION_H
bool write(dictionary& dict) const;
FUNCTION_H
bool read(iIstream& is);
FUNCTION_H
bool write(iOstream& os)const;
};
inline iOstream& operator <<(iOstream& os, const timeInterval& obj)
{
if(!obj.write(os))
{
fatalExit;
}
return os;
}
inline iIstream& operator >>(iIstream& is, timeInterval& obj)
{
if( !obj.read(is) )
{
fatalExit;
}
return is;
}
}
#endif
pFlow::real
float real
Definition: builtinTypes.hpp:46
fatalExit
#define fatalExit
Definition: error.hpp:57
types.hpp
pFlow::timeInterval::startTime
INLINE_FUNCTION_HD auto startTime() const
Definition: timeInterval.hpp:45
pFlow::timeInterval::write
FUNCTION_H bool write(dictionary &dict) const
Definition: timeInterval.cpp:26
pFlow::timeInterval::operator=
INLINE_FUNCTION_HD timeInterval & operator=(const timeInterval &)=default
pFlow::timeInterval::~timeInterval
INLINE_FUNCTION_HD ~timeInterval()=default
pFlow::timeInterval::read
FUNCTION_H bool read(const dictionary &dict)
Definition: timeInterval.cpp:17
pFlow
Definition: demComponent.hpp:28
FUNCTION_H
#define FUNCTION_H
Definition: pFlowMacros.hpp:58
pFlow::iIstream
Definition: iIstream.hpp:33
pFlow::timeInterval::time
INLINE_FUNCTION_HD auto time() const
Definition: timeInterval.hpp:57
pFlowMacros.hpp
pFlow::timeInterval::timeInterval
INLINE_FUNCTION_HD timeInterval()
Definition: timeInterval.hpp:30
pFlow::timeInterval::inTimeRange
INLINE_FUNCTION_HD bool inTimeRange(real t) const
Definition: timeInterval.hpp:70
pFlow::timeInterval::endTime
INLINE_FUNCTION_HD auto endTime() const
Definition: timeInterval.hpp:51
pFlow::operator>>
INLINE_FUNCTION iIstream & operator>>(iIstream &str, AB3History &ab3)
Definition: AdamsBashforth3.hpp:41
pFlow::timeInterval::inTimeRange
INLINE_FUNCTION_HD bool inTimeRange() const
Definition: timeInterval.hpp:76
pFlow::timeInterval::startTime_
real startTime_
Definition: timeInterval.hpp:19
pFlow::timeInterval
Definition: timeInterval.hpp:16
pFlow::operator<<
INLINE_FUNCTION iOstream & operator<<(iOstream &str, const AB3History &ab3)
Definition: AdamsBashforth3.hpp:57
pFlow::largeValue
const real largeValue
Definition: numericConstants.hpp:35
INLINE_FUNCTION_HD
#define INLINE_FUNCTION_HD
Definition: pFlowMacros.hpp:51
pFlow::timeInterval::setTime
INLINE_FUNCTION_HD void setTime(real t)
Definition: timeInterval.hpp:63
pFlow::iOstream
Definition: iOstream.hpp:53
pFlow::dictionary
Definition: dictionary.hpp:38
pFlow::timeInterval::time_
real time_
Definition: timeInterval.hpp:23
pFlow::timeInterval::isInInterval_
bool isInInterval_
Definition: timeInterval.hpp:25
pFlow::timeInterval::endTime_
real endTime_
Definition: timeInterval.hpp:21