dynamic-graph  4.1.0-8-gdab7-dirty
Dynamic graph library
SignalTimeDependent< T, Time > Class Template Reference

A type of signal that enforces a time dependency between other signals, making sure its inputs are up to date on access, using a incrementing time tick as reference. More...

#include <dynamic-graph/signal-time-dependent.h>

Inheritance diagram for SignalTimeDependent< T, Time >:
Collaboration diagram for SignalTimeDependent< T, Time >:

Public Member Functions

 SignalTimeDependent (std::string name="")
 
 SignalTimeDependent (const SignalArray_const< Time > &arr, std::string name="")
 
 SignalTimeDependent (boost::function2< T &, T &, Time > t, const SignalArray_const< Time > &sig, std::string name="")
 
const T & access (const Time &t1)
 
virtual void addDependency (const SignalBase< Time > &signal)
 
virtual void clearDependencies ()
 
std::ostream & displayDependencies (std::ostream &os, const int depth=-1, std::string space="", std::string next1="", std::string next2="") const
 
virtual Time getPeriodTime () const
 
virtual bool needUpdate (const Time &t) const
 
const T & operator() (const Time &t1)
 
virtual void removeDependency (const SignalBase< Time > &signal)
 
virtual void setPeriodTime (const Time &p)
 
std::ostream & writeGraph (std::ostream &os) const
 
- Public Member Functions inherited from Signal< T, Time >
 Signal (std::string name)
 
virtual const T & accessCopy () const
 
virtual void checkCompatibility ()
 
virtual std::ostream & display (std::ostream &os) const
 
virtual void get (std::ostream &value) const
 
virtual void getClassName (std::string &aClassName) const
 
bool getKeepReference ()
 
 operator const T & () const
 
virtual Signal< T, Time > & operator= (const T &t)
 
virtual void recompute (const Time &t)
 
virtual void set (std::istringstream &value)
 
virtual void setConstant (const T &t)
 
virtual void setFunction (boost::function2< T &, T &, Time > t, Mutex *mutexref=NULL)
 
void setKeepReference (const bool &b)
 
virtual void setReference (const T *t, Mutex *mutexref=NULL)
 
virtual void setReferenceNonConstant (T *t, Mutex *mutexref=NULL)
 
virtual void trace (std::ostream &os) const
 
- Public Member Functions inherited from SignalBase< Time >
 SignalBase (std::string name="")
 
virtual const Time & getTime () const
 
virtual void setTime (const Time &t)
 
const bool & getReady () const
 
const std::string & getName () const
 
void getClassName (std::string &aClassName) const
 
void setReady (const bool sready=true)
 
virtual void plug (SignalBase< Time > *sigarg)
 
virtual void unplug ()
 
virtual bool isPlugged () const
 
virtual SignalBase< Time > * getPluged () const
 
virtual void setConstantDefault ()
 
std::string shortName () const
 
virtual void ExtractNodeAndLocalNames (std::string &LocalName, std::string &NodeName) const
 
- Public Member Functions inherited from TimeDependency< Time >
 TimeDependency (SignalBase< Time > *sig, const DependencyType dep=DEPENDENCY_TYPE_DEFAULT)
 
 TimeDependency (SignalBase< Time > *sig, const SignalArray_const< Time > &arr, const DependencyType dep=DEPENDENCY_TYPE_DEFAULT)
 
void addDependencies (const SignalArray_const< Time > &arr)
 
void addDependency (const SignalBase< Time > &sig)
 
void clearDependency ()
 
std::ostream & displayDependencies (std::ostream &os, const int depth=-1, std::string space="", std::string next1="", std::string next2="") const
 
bool getNeedUpdateFromAllChildren () const
 
Time getPeriodTime () const
 
bool needUpdate (const Time &t1) const
 
void removeDependency (const SignalBase< Time > &sig)
 
void setDependencyType (DependencyType dep)
 
void setNeedUpdateFromAllChildren (const bool b=true)
 
void setPeriodTime (const Time &p)
 

Additional Inherited Members

- Public Types inherited from Signal< T, Time >
typedef int * Mutex
 
typedef int * MutexError
 
- Public Types inherited from TimeDependency< Time >
typedef std::list< const SignalBase< Time > * > Dependencies
 
enum  DependencyType { TIME_DEPENDENT, BOOL_DEPENDENT, ALWAYS_READY }
 
- Public Attributes inherited from TimeDependency< Time >
Dependencies dependencies
 
DependencyType dependencyType
 
Time lastAskForUpdate
 
SignalBase< Time > & leader
 
Time periodTime
 
bool updateFromAllChildren
 
- Static Public Attributes inherited from TimeDependency< Time >
static const bool ALL_READY_DEFAULT = false
 
static const DependencyType DEPENDENCY_TYPE_DEFAULT = TIME_DEPENDENT
 
static const Time PERIOD_TIME_DEFAULT = 1
 
- Protected Types inherited from Signal< T, Time >
enum  SignalType { CONSTANT, REFERENCE, REFERENCE_NON_CONST, FUNCTION }
 
- Protected Attributes inherited from Signal< T, Time >
bool copyInit
 
bool keepReference
 
Mutex * providerMutex
 
SignalType signalType
 
T * Tcopy
 
Tcopy1
 
Tcopy2
 
boost::function2< T &, T &, Time > Tfunction
 
const T * Treference
 
T * TreferenceNonConst
 
- Protected Attributes inherited from SignalBase< Time >
std::string name
 
bool ready
 
Time signalTime
 
- Static Protected Attributes inherited from Signal< T, Time >
static const bool KEEP_REFERENCE_DEFAULT = false
 
static const SignalType SIGNAL_TYPE_DEFAULT = CONSTANT
 

Detailed Description

template<class T, class Time>
class dynamicgraph::SignalTimeDependent< T, Time >

A type of signal that enforces a time dependency between other signals, making sure its inputs are up to date on access, using a incrementing time tick as reference.

It works this way. For a given SignalTimeDependent S,

  • the user manually adds dependent signals through the use of the SignalTimeDependent::addDependency function.
  • On access (calling the signal S SignalTimeDependent::operator()(const Time&) or SignalTimeDependent::access(const Time&) function), if the dependent signals are not up-to-date, i.e. if their [last update] time is less than the current time, their value will be SignalTimeDependent::access ()'ed to bring them up-to-date.

Thus, the value of dependent signals can be accessed quickly and repeatedly through the Signal::accessCopy () function.

An example:

class MyEntity : public Entity {
public:
// Some signal dependencies
SignalPtr<T,int> dep1, dep2;
SignalTimeDependent<T,int> signal;
MyEntity (const std::string& name)
: Entity (name)
, signal (
// Set the function that computes the signal value
boost::bind (&Entity::computeSignal, this, _1, _2),
// Declare the dependencies
dep1 << dep2,
"signalname")
{}
T& computeSignal (T& res, int time)
{
// The accesses below update the signal if necessary.
dep1(time);
dep1.access(time);
dep1.recompute(time);
// If dep1 and dep2 are already up-to-date, for a faster access, use
dep1.accessCopy();
dep2.accessCopy();
// Compute res
return res;
}

Definition at line 43 of file fwd.hh.


The documentation for this class was generated from the following files: