# PhasicFlow: src/phasicFlow/Timer/Timers.hpp Source File

Timers.hpp
Go to the documentation of this file.
/*------------------------------- phasicFlow ---------------------------------
O C enter of
O O E ngineering and
O O M ultiscale modeling of
OOOOOOO F luid flow
------------------------------------------------------------------------------
Copyright (C): www.cemf.ir
email: hamid.r.norouzi AT gmail.com
------------------------------------------------------------------------------
Licence:
This file is part of phasicFlow code. It is a free software for simulating
granular and multiphase flows. You can redistribute it and/or modify it under
the terms of GNU General Public License v3 or any other later versions.
phasicFlow is distributed to help others in their research in the field of
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-----------------------------------------------------------------------------*/
#ifndef __Timerss_hpp__
#define __Timerss_hpp__
#include "List.hpp"
#include "Timer.hpp"
namespace pFlow
{
class Timers
:
public pFlow::Timer
{
protected:
List<pFlow::Timer*> timers_;
int32 level_ = 0;
public:
TypeInfo("Timers");
Timers(const word& name)
:
Timer(name)
{}
Timers(const word& name, Timers* parrent)
:
Timer(name, parrent)
{
if(parrent_)
{
level_ = parrent_->level()+1;
}
}
virtual ~Timers()
{
for(auto& timer:timers_)
{
timer->removeParrent();
}
}
// add a timer to this node
uniquePtr<Timer> addTimer(const word& name)
{
return makeUnique<Timer>(name, this);
}
void addToList(Timer* timer)
{
timers_.push_back(timer);
}
void removeFromList(Timer* timer)
{
timers_.erase(timers_.find(timer));
}
virtual int32 level()const
{
return level_;
}
virtual bool master()const
{
return true;
}
real accTimersTotal()const override;
virtual bool write(iOstream& os, bool subTree = true)const;
virtual bool read(iIstream& is)
{
return true;
}
};
inline iOstream& operator<<(iOstream& os, const Timers& t)
{
t.write(os, true);
return os;
}
inline iIstream& operator>>(iIstream& is, Timers& t)
{
return is;
}
}
#endif //__Timers_hpp__
pFlow::List< pFlow::Timer * >
pFlow::Timers::~Timers
virtual ~Timers()
Definition: Timers.hpp:63
pFlow::Timers::addToList
void addToList(Timer *timer)
Definition: Timers.hpp:78
pFlow::Timers::Timers
Timers(const word &name)
Definition: Timers.hpp:48
pFlow::real
float real
Definition: builtinTypes.hpp:46
pFlow::Timers::read
virtual bool read(iIstream &is)
Definition: Timers.hpp:103
pFlow::Timers::master
virtual bool master() const
Definition: Timers.hpp:93
List.hpp
pFlow::List::find
constIterator find(const T &val) const
Definition: ListI.hpp:92
pFlow::word
std::string word
Definition: builtinTypes.hpp:63
pFlow::Timers::TypeInfo
TypeInfo("Timers")
pFlow::Timers
Definition: Timers.hpp:33
pFlow
Definition: demComponent.hpp:28
pFlow::Timer::parrent_
Timers * parrent_
Definition: Timer.hpp:60
pFlow::iIstream
Definition: iIstream.hpp:33
pFlow::Timers::level
virtual int32 level() const
Definition: Timers.hpp:88
pFlow::int32
int int32
Definition: builtinTypes.hpp:53
pFlow::Timer
Definition: Timer.hpp:39
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:53
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:77
pFlow::uniquePtr
Definition: uniquePtr.hpp:44
pFlow::Timers::accTimersTotal
real accTimersTotal() const override
Definition: Timers.cpp:24
Timer.hpp
pFlow::Timers::level_
int32 level_
Definition: Timers.hpp:41
pFlow::Timers::removeFromList
void removeFromList(Timer *timer)
Definition: Timers.hpp:83
pFlow::Timer::timer
std::chrono::high_resolution_clock timer
Definition: Timer.hpp:43
pFlow::Timers::write
virtual bool write(iOstream &os, bool subTree=true) const
Definition: Timers.cpp:46
pFlow::iOstream
Definition: iOstream.hpp:53
pFlow::Timers::timers_
List< pFlow::Timer * > timers_
Definition: Timers.hpp:39
pFlow::Timers::addTimer
uniquePtr< Timer > addTimer(const word &name)
Definition: Timers.hpp:72