timeInterval.hpp
Go to the documentation of this file.
1 
2 
3 #ifndef __timeInterval_hpp__
4 #define __timeInterval_hpp__
5 
6 #include "types.hpp"
7 #include "pFlowMacros.hpp"
8 
9 namespace pFlow
10 {
11 
12 // forward
13 class dictionary;
14 
15 
17 {
18 protected:
20 
22 
24 
25  bool isInInterval_ = true;
26 
27 public:
28 
31 
33  timeInterval(const timeInterval&) = default;
34 
36  timeInterval& operator=(const timeInterval&) = default;
37 
39  timeInterval(const dictionary& dict);
40 
42  ~timeInterval() = default;
43 
45  auto startTime()const
46  {
47  return startTime_;
48  }
49 
51  auto endTime()const
52  {
53  return endTime_;
54  }
55 
57  auto time()const
58  {
59  return time_;
60  }
61 
63  void setTime(real t)
64  {
66  time_ = t;
67  }
68 
70  bool inTimeRange(real t)const
71  {
72  return t>= startTime_ && t<= endTime_;
73  }
74 
76  bool inTimeRange()const
77  {
78  return isInInterval_;
79  }
80 
81  // - IO operation
82  FUNCTION_H
83  bool read(const dictionary& dict);
84 
86  bool write(dictionary& dict) const;
87 
89  bool read(iIstream& is);
90 
92  bool write(iOstream& os)const;
93 };
94 
95 
96 inline iOstream& operator <<(iOstream& os, const timeInterval& obj)
97 {
98  if(!obj.write(os))
99  {
100  fatalExit;
101  }
102  return os;
103 }
104 
106 {
107  if( !obj.read(is) )
108  {
109  fatalExit;
110  }
111  return is;
112 }
113 
114 }
115 
116 #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