www.cemf.ir
Timers.hpp
Go to the documentation of this file.
1 /*------------------------------- phasicFlow ---------------------------------
2  O C enter of
3  O O E ngineering and
4  O O M ultiscale modeling of
5  OOOOOOO F luid flow
6 ------------------------------------------------------------------------------
7  Copyright (C): www.cemf.ir
8  email: hamid.r.norouzi AT gmail.com
9 ------------------------------------------------------------------------------
10 Licence:
11  This file is part of phasicFlow code. It is a free software for simulating
12  granular and multiphase flows. You can redistribute it and/or modify it under
13  the terms of GNU General Public License v3 or any other later versions.
14 
15  phasicFlow is distributed to help others in their research in the field of
16  granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
17  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 
19 -----------------------------------------------------------------------------*/
20 
21 #ifndef __Timerss_hpp__
22 #define __Timerss_hpp__
23 
24 
25 #include "List.hpp"
26 #include "Timer.hpp"
27 
28 
29 namespace pFlow
30 {
31 
32 class Timers
33 :
34  public pFlow::Timer
35 {
36 protected:
37 
39 
41 
42 public:
43 
44  TypeInfo("Timers");
45 
46 
47  Timers(const word& name)
48  :
49  Timer(name)
50  {}
51 
53  :
55  {
56  if(parrent)
57  {
58  level_ = parrent->level()+1;
59  }
60  }
61 
62  virtual ~Timers()
63  {
64  for(auto& timer:timers_)
65  {
66  timer->removeParrent();
67  }
68  }
69 
70  // add a timer to this node
72  {
73  return makeUnique<Timer>(name, this);
74  }
75 
76 
78  {
79  timers_.push_back(timer);
80  }
81 
83  {
84  timers_.erase(timers_.find(timer));
85  }
86 
87  virtual int32 level()const
88  {
89  return level_;
90  }
91 
92  virtual bool master()const
93  {
94  return true;
95  }
96 
97  real accTimersTotal()const override;
98 
99  virtual bool write(iOstream& os, bool subTree = true)const;
100 
101 
102  virtual bool read(iIstream& is)
103  {
104  return true;
105  }
106 
107 };
108 
109 inline iOstream& operator<<(iOstream& os, const Timers& t)
110 {
111  t.write(os, true);
112  return os;
113 }
114 
116 {
117  return is;
118 }
119 
120 }
121 
122 
123 #endif //__Timers_hpp__
pFlow::List< pFlow::Timer * >
pFlow::Timers::~Timers
virtual ~Timers()
Definition: Timers.hpp:62
pFlow::Timers::addToList
void addToList(Timer *timer)
Definition: Timers.hpp:77
pFlow::Timers::Timers
Timers(const word &name)
Definition: Timers.hpp:47
pFlow::real
float real
Definition: builtinTypes.hpp:45
pFlow::Timers::read
virtual bool read(iIstream &is)
Definition: Timers.hpp:102
pFlow::Timers::master
virtual bool master() const
Definition: Timers.hpp:92
List.hpp
pFlow::word
std::string word
Definition: builtinTypes.hpp:64
pFlow::List::find
const_iterator find(const T &val) const
Definition: ListI.hpp:108
pFlow::Timers::TypeInfo
TypeInfo("Timers")
pFlow::Timers
Definition: Timers.hpp:32
pFlow
Definition: demGeometry.hpp:27
pFlow::Timer::parrent
Timers * parrent() const
Definition: Timer.hpp:99
pFlow::iIstream
Interface class for any input stream
Definition: iIstream.hpp:37
pFlow::Timers::level
virtual int32 level() const
Definition: Timers.hpp:87
pFlow::int32
int int32
Definition: builtinTypes.hpp:50
pFlow::Timer
Definition: Timer.hpp:33
pFlow::operator>>
INLINE_FUNCTION iIstream & operator>>(iIstream &str, AB3History &ab3)
Definition: AdamsBashforth3.hpp:41
pFlow::Timers::Timers
Timers(const word &name, Timers *parrent)
Definition: Timers.hpp:52
pFlow::operator<<
INLINE_FUNCTION iOstream & operator<<(iOstream &str, const AB3History &ab3)
Definition: AdamsBashforth3.hpp:57
pFlow::Timer::name
const word & name() const
Definition: Timer.hpp:80
pFlow::uniquePtr
Definition: uniquePtr.hpp:42
pFlow::Timers::accTimersTotal
real accTimersTotal() const override
Definition: Timers.cpp:24
Timer.hpp
pFlow::Timers::level_
int32 level_
Definition: Timers.hpp:40
pFlow::Timers::removeFromList
void removeFromList(Timer *timer)
Definition: Timers.hpp:82
pFlow::Timer::timer
std::chrono::high_resolution_clock timer
Definition: Timer.hpp:37
pFlow::Timers::write
virtual bool write(iOstream &os, bool subTree=true) const
Definition: Timers.cpp:46
pFlow::iOstream
Interface class for any output stream.
Definition: iOstream.hpp:59
pFlow::Timers::timers_
List< pFlow::Timer * > timers_
Definition: Timers.hpp:38
pFlow::Timers::addTimer
uniquePtr< Timer > addTimer(const word &name)
Definition: Timers.hpp:71