#include <utilities/timer.h>
Public Member Functions | |
Timer (void) | |
void | SetTimeout (const std::size_t theTimeout) |
void | SetInstant (const bool theInstant) |
void | SetSingle (const bool theSingle) |
void | Run (void) |
virtual void | Action (void) |
virtual | ~Timer () |
Private Member Functions | |
Timer (const Timer &) | |
Timer | operator= (const Timer &) |
Private Attributes | |
std::size_t | Timeout |
bool | Instant |
bool | Single |
ThreadAbstraction | TimerThread |
Friends | |
void * | _TimerWrapperFunction (void *) |
Definition at line 44 of file timer.h.
nitro::Timer::Timer | ( | void | ) |
nitro::Timer::~Timer | ( | ) | [virtual] |
Virtual destructor.
Definition at line 125 of file timer.cpp.
{ try { } catch( nitro::exception e ) { } catch( ... ) { } }
nitro::Timer::Timer | ( | const Timer & | ) | [inline, private] |
void nitro::Timer::Action | ( | void | ) | [virtual] |
Function of the timer's action.
nitro::exception | Throws an exception of that type with the error description. |
Definition at line 110 of file timer.cpp.
References nitro::exception::code(), and nitro::exception::what().
Referenced by nitro::_TimerWrapperFunction().
{ try { } catch( nitro::exception e ) { throw( nitro::exception( std::string( "Timer::Action( void )::" ) + e.what() , e.code() ) ); } catch( ... ) { throw( nitro::exception( std::string( "Timer::Action( void )::An error occured" ) , 0 ) ); } }
void nitro::Timer::Run | ( | void | ) |
Function starts timer.
nitro::exception | Throws an exception of that type with the error description. |
Definition at line 94 of file timer.cpp.
References _TimerWrapperFunction, nitro::exception::code(), nitro::ThreadAbstraction::CreateThread(), TimerThread, and nitro::exception::what().
{ try { TimerThread.CreateThread( _TimerWrapperFunction , ( void * )( Timer * )this ); } catch( nitro::exception e ) { throw( nitro::exception( std::string( "Timer::Run( void )::" ) + e.what() , e.code() ) ); } catch( ... ) { throw( nitro::exception( std::string( "Timer::Run( void )::An error occured" ) , 0 ) ); } }
void nitro::Timer::SetInstant | ( | const bool | theInstant | ) |
Function sets field Instant.
theInstant | - flag of the instant action's execution. |
nitro::exception | Throws an exception of that type with the error description. |
Definition at line 35 of file timer.cpp.
References nitro::exception::code(), Instant, and nitro::exception::what().
{ try { Instant = theInstant; } catch( nitro::exception e ) { throw( nitro::exception( std::string( "Timer::SetInstant( const bool theInstant )::" ) + e.what() , e.code() ) ); } catch( ... ) { throw( nitro::exception( std::string( "Timer::SetInstant( const bool theInstant )::An error occured" ) , 0 ) ); } }
void nitro::Timer::SetSingle | ( | const bool | theSingle | ) |
Function sets field Instant.
theSingle | - flag of the single action's execution. |
nitro::exception | Throws an exception of that type with the error description. |
Definition at line 51 of file timer.cpp.
References nitro::exception::code(), Single, and nitro::exception::what().
{ try { Single = theSingle; } catch( nitro::exception e ) { throw( nitro::exception( std::string( "Timer::SetSingle( const bool theSingle )::" ) + e.what() , e.code() ) ); } catch( ... ) { throw( nitro::exception( std::string( "Timer::SetSingle( const bool theSingle )::An error occured" ) , 0 ) ); } }
void nitro::Timer::SetTimeout | ( | const std::size_t | theTimeout | ) |
Function sets timeout.
theTimeout | - Timeout. |
nitro::exception | Throws an exception of that type with the error description. |
Definition at line 19 of file timer.cpp.
References nitro::exception::code(), Timeout, and nitro::exception::what().
{ try { Timeout = theTimeout; } catch( nitro::exception e ) { throw( nitro::exception( std::string( "Timer::SetTimeout( const std::size_t theTimeout )::" ) + e.what() , e.code() ) ); } catch( ... ) { throw( nitro::exception( std::string( "Timer::SetTimeout( const std::size_t theTimeout )::An error occured" ) , 0 ) ); } }
void* _TimerWrapperFunction | ( | void * | Param | ) | [friend] |
Timer function for the thread.
Definition at line 67 of file timer.cpp.
Referenced by Run().
{ Timer * TimerPtr( ( Timer * ) Param ); if( TimerPtr->Instant ) { TimerPtr->Action(); if( TimerPtr->Single ) { return( NULL ); } } for( ; true ; ) { ThreadAbstraction::Sleep( TimerPtr->Timeout ); TimerPtr->Action(); if( TimerPtr->Single ) { return( NULL ); } } }
bool nitro::Timer::Instant [private] |
Instant execution of the action.
Definition at line 191 of file timer.h.
Referenced by nitro::_TimerWrapperFunction(), SetInstant(), and Timer().
bool nitro::Timer::Single [private] |
Single execution of the action.
Definition at line 203 of file timer.h.
Referenced by nitro::_TimerWrapperFunction(), SetSingle(), and Timer().
std::size_t nitro::Timer::Timeout [private] |
Timeout for action execution.
Definition at line 179 of file timer.h.
Referenced by nitro::_TimerWrapperFunction(), SetTimeout(), and Timer().
ThreadAbstraction nitro::Timer::TimerThread [private] |