Orocos Real-Time Toolkit  2.8.3
Public Member Functions | List of all members
RTT::scripting::ConditionCache Class Reference

A conditional that evaluates and caches another Condition. More...

#include <rtt/scripting/ConditionCache.hpp>

Inheritance diagram for RTT::scripting::ConditionCache:
RTT::scripting::ConditionInterface

Public Member Functions

 ConditionCache (ConditionInterface *c, internal::AssignableDataSource< bool >::shared_ptr ds=internal::AssignableDataSource< bool >::shared_ptr())
 
virtual ~ConditionCache ()
 
virtual bool evaluate ()
 Evaluate the Condition and return the outcome. More...
 
virtual void reset ()
 Some conditions need to be reset at some points. More...
 
internal::DataSource< bool >::shared_ptr getResult ()
 
virtual ConditionInterfacecopy (std::map< const base::DataSourceBase *, base::DataSourceBase * > &alreadyCloned) const
 When copying an Orocos program, we want identical internal::DataSource's to be mapped to identical DataSources, in order for the program to work correctly. More...
 
virtual ConditionInterfaceclone () const
 A clone will cache the same condition. More...
 

Detailed Description

A conditional that evaluates and caches another Condition.

In order to read the cached value, use ConditionBoolDataSource. By default, and after a reset, the cached condition returned in getResult() returns false.

Definition at line 54 of file ConditionCache.hpp.

Constructor & Destructor Documentation

RTT::scripting::ConditionCache::ConditionCache ( ConditionInterface c,
internal::AssignableDataSource< bool >::shared_ptr  ds = internal::AssignableDataSource<bool>::shared_ptr() 
)
inline

Definition at line 60 of file ConditionCache.hpp.

virtual RTT::scripting::ConditionCache::~ConditionCache ( )
inlinevirtual

Definition at line 65 of file ConditionCache.hpp.

Member Function Documentation

virtual ConditionInterface* RTT::scripting::ConditionCache::clone ( ) const
inlinevirtual

A clone will cache the same condition.

Implements RTT::scripting::ConditionInterface.

Definition at line 89 of file ConditionCache.hpp.

virtual ConditionInterface* RTT::scripting::ConditionCache::copy ( std::map< const base::DataSourceBase *, base::DataSourceBase * > &  alreadyCloned) const
inlinevirtual

When copying an Orocos program, we want identical internal::DataSource's to be mapped to identical DataSources, in order for the program to work correctly.

This is different from the clone function, where we simply want a new Command that can replace the old one directly.

This function takes a map that maps the old internal::DataSource's onto their new replacements. This way, it is possible to check before cloning a internal::DataSource, whether it has already been copied, and if so, reuse the existing copy.

To keep old source working, the standard implementation of this function simply calls the clone function. If your ConditionInterface uses a internal::DataSource, it is important that you reimplement this function correctly though.

Reimplemented from RTT::scripting::ConditionInterface.

Definition at line 81 of file ConditionCache.hpp.

References RTT::internal::AssignableDataSource< T >::copy().

virtual bool RTT::scripting::ConditionCache::evaluate ( )
inlinevirtual

Evaluate the Condition and return the outcome.

Returns
true if the condition is satisfied, false otherwise.

Implements RTT::scripting::ConditionInterface.

Definition at line 69 of file ConditionCache.hpp.

References RTT::internal::AssignableDataSource< T >::set(), and RTT::internal::DataSource< T >::value().

internal::DataSource<bool>::shared_ptr RTT::scripting::ConditionCache::getResult ( )
inline

Definition at line 79 of file ConditionCache.hpp.

virtual void RTT::scripting::ConditionCache::reset ( )
inlinevirtual

Some conditions need to be reset at some points.

E.g. a scripting::ConditionDuration counts the time since the first time a Command was executed, and if this time exceeds a certain preset time, returns true. Therefore, it needs to be reset, i.e. it needs to start counting, when the command is first executed.. scripting::ConditionOnce has a similar need. This function is called at such times.

Reimplemented from RTT::scripting::ConditionInterface.

Definition at line 75 of file ConditionCache.hpp.

References RTT::internal::AssignableDataSource< T >::set().


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