Orocos Real-Time Toolkit  2.8.3
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
RTT::extras::FileDescriptorSimulationActivity Class Reference

Simulate a FileDescriptorActivity (FDA) Primarily this is designed for unit tests that are testing components that require a FDA. More...

#include <rtt/extras/FileDescriptorSimulationActivity.hpp>

Inheritance diagram for RTT::extras::FileDescriptorSimulationActivity:
RTT::extras::FileDescriptorActivityInterface RTT::base::ActivityInterface

Public Types

typedef boost::shared_ptr< ActivityInterfaceshared_ptr
 

Public Member Functions

 FileDescriptorSimulationActivity (int priority, base::RunnableInterface *_r=0, const std::string &name="FileDescriptorSimulationActivity")
 
 FileDescriptorSimulationActivity (int scheduler, int priority, base::RunnableInterface *_r=0, const std::string &name="FileDescriptorSimulationActivity")
 
 FileDescriptorSimulationActivity (int scheduler, int priority, Seconds period, base::RunnableInterface *_r=0, const std::string &name="FileDescriptorSimulationActivity")
 
 FileDescriptorSimulationActivity (int scheduler, int priority, Seconds period, unsigned cpu_affinity, base::RunnableInterface *_r=0, const std::string &name="FileDescriptorSimulationActivity")
 
virtual ~FileDescriptorSimulationActivity ()
 Cleanup and notify the base::RunnableInterface that we are gone. More...
 
void watch (int fd)
 Does nothing. More...
 
void unwatch (int fd)
 Does nothing. More...
 
void clearAllWatches ()
 Does nothing. More...
 
bool isWatched (int fd) const
 Returns false always. More...
 
bool isUpdated (int fd) const
 Return false. More...
 
bool hasTimeout () const
 Return false. More...
 
bool hasError () const
 True if one of the file descriptors has a problem (for instance it has been closed) More...
 
void setTimeout (int timeout)
 Does nothing. More...
 
void setTimeout_us (int timeout_us)
 Does nothing. More...
 
int getTimeout () const
 Return 0. More...
 
int getTimeout_us () const
 Returns 0. More...
 
virtual bool start ()
 Returns true. More...
 
virtual bool stop ()
 Returns true. More...
 
virtual bool isRunning () const
 Returns true. More...
 
virtual bool isActive () const
 Returns true. More...
 
virtual Seconds getPeriod () const
 Returns period. More...
 
virtual bool isPeriodic () const
 Returns true iff (0 != period) More...
 
virtual bool setPeriod (Seconds s)
 If s>0 then returns true and period == s, otherwise returns false. More...
 
virtual unsigned getCpuAffinity () const
 Returns 0. More...
 
virtual bool setCpuAffinity (unsigned cpu)
 Returns true. More...
 
virtual bool execute ()
 Returns true. More...
 
virtual bool trigger ()
 Returns true. More...
 
virtual os::ThreadInterfacethread ()
 Returns os::MainThread::Instance() More...
 
virtual bool run (RunnableInterface *r)
 Run exclusively this RunnableInterface. More...
 
virtual RunnableInterfacegetRunner () const
 Returns a pointer to the RunnableInterface instance. More...
 

Protected Member Functions

void disableRun (RunnableInterface *caller)
 This method is only meant for RunnableInterface (ie runner) in order to inform the ActivityInterface it should no longer be used. More...
 

Protected Attributes

Seconds period
 Fake period - some classes require period!=0. More...
 
bool running
 
RunnableInterfacerunner
 

Detailed Description

Simulate a FileDescriptorActivity (FDA) Primarily this is designed for unit tests that are testing components that require a FDA.

This implementation allows deterministic cycling of such a component.

The intended use case is a component that is woken up by its FDA and then the component determines why it was woken up by calling isUpdated(), hasTimeout(), and hasError(). The unit test code should call work() with an appropriate reason, which will end up being returned to the component through the above calls. So a unit test call of work(IOReady) will result in isUpdated() returning true to the component, and similarly for work(TimeOut) and hasTimeout(). Currently hasError() always returns false - there is no way to simulate this with the current implementation.

Note
Component OwnThread operations are executed by the MainThread, which is correct for a unit test case that is directly executing.

Definition at line 58 of file FileDescriptorSimulationActivity.hpp.

Member Typedef Documentation

typedef boost::shared_ptr<ActivityInterface> RTT::base::ActivityInterface::shared_ptr
inherited

Constructor & Destructor Documentation

FileDescriptorSimulationActivity::FileDescriptorSimulationActivity ( int  priority,
base::RunnableInterface _r = 0,
const std::string &  name = "FileDescriptorSimulationActivity" 
)

Definition at line 37 of file FileDescriptorSimulationActivity.cpp.

FileDescriptorSimulationActivity::FileDescriptorSimulationActivity ( int  scheduler,
int  priority,
base::RunnableInterface _r = 0,
const std::string &  name = "FileDescriptorSimulationActivity" 
)

Definition at line 49 of file FileDescriptorSimulationActivity.cpp.

FileDescriptorSimulationActivity::FileDescriptorSimulationActivity ( int  scheduler,
int  priority,
Seconds  period,
base::RunnableInterface _r = 0,
const std::string &  name = "FileDescriptorSimulationActivity" 
)

Definition at line 62 of file FileDescriptorSimulationActivity.cpp.

FileDescriptorSimulationActivity::FileDescriptorSimulationActivity ( int  scheduler,
int  priority,
Seconds  period,
unsigned  cpu_affinity,
base::RunnableInterface _r = 0,
const std::string &  name = "FileDescriptorSimulationActivity" 
)

Definition at line 77 of file FileDescriptorSimulationActivity.cpp.

FileDescriptorSimulationActivity::~FileDescriptorSimulationActivity ( )
virtual

Cleanup and notify the base::RunnableInterface that we are gone.

Definition at line 94 of file FileDescriptorSimulationActivity.cpp.

References stop().

Member Function Documentation

void FileDescriptorSimulationActivity::clearAllWatches ( )
virtual

Does nothing.

Implements RTT::extras::FileDescriptorActivityInterface.

Definition at line 113 of file FileDescriptorSimulationActivity.cpp.

void RTT::base::ActivityInterface::disableRun ( RunnableInterface caller)
inlineprotectedinherited

This method is only meant for RunnableInterface (ie runner) in order to inform the ActivityInterface it should no longer be used.

run(0) can not be used in this case because it would recurse.

Definition at line 73 of file ActivityInterface.hpp.

Referenced by RTT::base::RunnableInterface::setActivity(), and RTT::base::RunnableInterface::~RunnableInterface().

bool FileDescriptorSimulationActivity::execute ( )
virtual

Returns true.

Implements RTT::base::ActivityInterface.

Definition at line 221 of file FileDescriptorSimulationActivity.cpp.

unsigned FileDescriptorSimulationActivity::getCpuAffinity ( ) const
virtual

Returns 0.

Implements RTT::base::ActivityInterface.

Definition at line 210 of file FileDescriptorSimulationActivity.cpp.

Seconds FileDescriptorSimulationActivity::getPeriod ( ) const
virtual

Returns period.

Implements RTT::base::ActivityInterface.

Definition at line 191 of file FileDescriptorSimulationActivity.cpp.

References period.

RunnableInterface * ActivityInterface::getRunner ( ) const
virtualinherited

Returns a pointer to the RunnableInterface instance.

Definition at line 70 of file ActivityInterface.cpp.

References RTT::base::ActivityInterface::runner.

Referenced by RTT::ExecutionEngine::setActivity().

int FileDescriptorSimulationActivity::getTimeout ( ) const
virtual
int FileDescriptorSimulationActivity::getTimeout_us ( ) const
virtual
bool FileDescriptorSimulationActivity::hasError ( ) const
virtual

True if one of the file descriptors has a problem (for instance it has been closed)

This should only be used from within the base::RunnableInterface this activity is driving, i.e. in TaskContext::updateHook() or TaskContext::errorHook().

Implements RTT::extras::FileDescriptorActivityInterface.

Definition at line 133 of file FileDescriptorSimulationActivity.cpp.

bool FileDescriptorSimulationActivity::hasTimeout ( ) const
virtual

Return false.

See also
work()

Implements RTT::extras::FileDescriptorActivityInterface.

Definition at line 128 of file FileDescriptorSimulationActivity.cpp.

bool FileDescriptorSimulationActivity::isActive ( ) const
virtual

Returns true.

Implements RTT::base::ActivityInterface.

Definition at line 186 of file FileDescriptorSimulationActivity.cpp.

References running.

bool FileDescriptorSimulationActivity::isPeriodic ( ) const
virtual

Returns true iff (0 != period)

Implements RTT::base::ActivityInterface.

Definition at line 196 of file FileDescriptorSimulationActivity.cpp.

References period.

bool FileDescriptorSimulationActivity::isRunning ( ) const
virtual

Returns true.

Implements RTT::base::ActivityInterface.

Definition at line 181 of file FileDescriptorSimulationActivity.cpp.

References running.

bool FileDescriptorSimulationActivity::isUpdated ( int  fd) const
virtual

Return false.

See also
work()

Implements RTT::extras::FileDescriptorActivityInterface.

Definition at line 123 of file FileDescriptorSimulationActivity.cpp.

bool FileDescriptorSimulationActivity::isWatched ( int  fd) const
virtual

Returns false always.

Implements RTT::extras::FileDescriptorActivityInterface.

Definition at line 117 of file FileDescriptorSimulationActivity.cpp.

bool ActivityInterface::run ( RunnableInterface r)
virtualinherited

Run exclusively this RunnableInterface.

Precondition
this->isRunning() == false
Parameters
rThe RunnableInterface to run exclusively.
Returns
true if succeeded, false otherwise

Definition at line 57 of file ActivityInterface.cpp.

References RTT::base::ActivityInterface::isActive(), RTT::base::ActivityInterface::runner, and RTT::base::RunnableInterface::setActivity().

Referenced by RTT::TaskContext::setActivity().

bool FileDescriptorSimulationActivity::setCpuAffinity ( unsigned  cpu)
virtual

Returns true.

Implements RTT::base::ActivityInterface.

Definition at line 215 of file FileDescriptorSimulationActivity.cpp.

bool FileDescriptorSimulationActivity::setPeriod ( Seconds  s)
virtual

If s>0 then returns true and period == s, otherwise returns false.

Implements RTT::base::ActivityInterface.

Definition at line 201 of file FileDescriptorSimulationActivity.cpp.

References period.

void FileDescriptorSimulationActivity::setTimeout ( int  timeout)
virtual

Does nothing.

Implements RTT::extras::FileDescriptorActivityInterface.

Definition at line 138 of file FileDescriptorSimulationActivity.cpp.

void FileDescriptorSimulationActivity::setTimeout_us ( int  timeout_us)
virtual

Does nothing.

Implements RTT::extras::FileDescriptorActivityInterface.

Definition at line 143 of file FileDescriptorSimulationActivity.cpp.

bool FileDescriptorSimulationActivity::start ( )
virtual

Returns true.

Implements RTT::base::ActivityInterface.

Definition at line 163 of file FileDescriptorSimulationActivity.cpp.

References running.

bool FileDescriptorSimulationActivity::stop ( )
virtual

Returns true.

Implements RTT::base::ActivityInterface.

Definition at line 172 of file FileDescriptorSimulationActivity.cpp.

References running.

Referenced by ~FileDescriptorSimulationActivity().

os::ThreadInterface * FileDescriptorSimulationActivity::thread ( )
virtual
bool FileDescriptorSimulationActivity::trigger ( )
virtual

Returns true.

Implements RTT::base::ActivityInterface.

Definition at line 226 of file FileDescriptorSimulationActivity.cpp.

void FileDescriptorSimulationActivity::unwatch ( int  fd)
virtual

Does nothing.

Implements RTT::extras::FileDescriptorActivityInterface.

Definition at line 108 of file FileDescriptorSimulationActivity.cpp.

void FileDescriptorSimulationActivity::watch ( int  fd)
virtual

Does nothing.

Implements RTT::extras::FileDescriptorActivityInterface.

Definition at line 103 of file FileDescriptorSimulationActivity.cpp.

Member Data Documentation

Seconds RTT::extras::FileDescriptorSimulationActivity::period
protected

Fake period - some classes require period!=0.

Is initialized to 0

Definition at line 163 of file FileDescriptorSimulationActivity.hpp.

Referenced by getPeriod(), isPeriodic(), and setPeriod().

RunnableInterface* RTT::base::ActivityInterface::runner
protectedinherited
bool RTT::extras::FileDescriptorSimulationActivity::running
protected

Definition at line 165 of file FileDescriptorSimulationActivity.hpp.

Referenced by isActive(), isRunning(), start(), and stop().


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