dynamic-graph  4.4.3
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>

Public Member Functions

 SignalTimeDependent (boost::function2< T &, T &, Time > t, const SignalArray_const< Time > &sig, std::string name="")
 
 SignalTimeDependent (const SignalArray_const< Time > &arr, std::string name="")
 
 SignalTimeDependent (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
 

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 56 of file fwd.hh.


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