#include "igstkLogger.h"
#include "itkCommand.h"
#include <cstdlib>
Go to the source code of this file.
Namespaces | |
namespace | igstk |
This file contains the declarations of IGSTK Events used to communicate among components. | |
Defines | |
#define | igstkLogMacro(x, y) |
Macro for simplifying the use of logging: the first argument is the priority (see itkMacro.h) and the second argument is the message. | |
#define | igstkLogMacroStatic(obj, x, y) |
Macro for simplifying the use of logging: the first argument is an object that has a logger, the second argument is the priority (see itkMacro.h) and the second argument is the message. | |
#define | igstkLogMacro2(logger, x, y) |
Macro for simplifying the use of logging: the first argument is a pointer to a logger, the second argument is the priority (see itkMacro.h) and the second argument is the message. | |
#define | igstkSetMacro(name, type) |
Set built-in type. | |
#define | igstkGetMacro(name, type) |
Get built-in type. | |
#define | igstkNewMacro(x) |
New Macro creates a new object of a class that is using SmartPointers. | |
#define | igstkTypeMacro(thisClass, superclass) virtual const char *GetNameOfClass() const {return #thisClass;} |
Type Macro defines the GetNameOfClass() method for every class where it is invoked. | |
#define | igstkFriendClassMacro(type) friend type |
Create a Macro for friend class. | |
#define | igstkLoggerMacro() |
Macro that defines all the standard elements related to the Logger. | |
#define | igstkSetStringMacro(name) |
Set character string. | |
#define | igstkGetStringMacro(name) |
Get character string. | |
#define | igstkStateMachineMacroBase(igstktypename) |
Macro that defines all the standard elements related to the StateMachine. | |
#define | EMPTYPARAMETER |
#define | igstkStateMachineMacro() igstkStateMachineMacroBase( EMPTYPARAMETER ) |
This is the StateMachine Macro to be used with non-templated classes. | |
#define | igstkStateMachineTemplatedMacro() igstkStateMachineMacroBase( typename ) |
This is the StateMachine Macro to be used with templated classes. | |
#define | igstkDeclareInputMacro(inputname) InputType m_##inputname##Input |
Convenience macro for declaring Inputs to the State Machine. | |
#define | igstkDeclareStateMacro(inputname) StateType m_##inputname##State |
Convenience macro for declaring States of the State Machine. | |
#define | igstkAddInputMacro(inputname) |
Convenience macro for adding Inputs to the State Machine. | |
#define | igstkAddStateMacro(statename) |
Convenience macro for adding States to the State Machine. | |
#define | igstkAddTransitionMacro(state1, input, state2, action) |
Convenience macro for adding Transitions to the State Machine. | |
#define | igstkSetInitialStateMacro(inputname) this->m_StateMachine.SelectInitialState( this->m_##inputname##State ); |
Convenience macro for selecting the initial States of the State Machine. | |
#define | igstkPushInputMacro(inputname) this->m_StateMachine.PushInput( this->m_##inputname##Input ); |
Convenience macro for pushing an input in the queue of the State Machine. | |
#define | igstkStandardClassBasicTraitsMacro(classname, superclassname) |
Convenience macro for the initial standard traits of a class. | |
#define | igstkStandardAbstractClassTraitsMacro(classname, superclassname) |
Convenience macro for traits of an abstract non-templated class. | |
#define | igstkStandardClassTraitsMacro(classname, superclassname) |
Convenience macro for traits of a non-templated class. | |
#define | igstkStandardTemplatedAbstractClassTraitsMacro(classname, superclassname) |
Convenience macro for the traits of an abstract templated class. | |
#define | igstkStandardTemplatedClassTraitsMacro(classname, superclassname) |
Convenience macro for the traits of a templated class. | |
#define | igstkEventTransductionMacro(event, input) |
Convenience macro for creating an Observer for an Event, its callback and transducing it into a specified input to the state machine. | |
#define | igstkLoadedEventTransductionMacro(event, input) |
Convenience macro for creating an Observer for an Event with payload, its callback and transducing it into a specified input to the state machine that takes its value. | |
#define | igstkLoadedObjectEventTransductionMacro(event, input) |
#define | igstkObserverMacro(name, eventType, payloadType) |
#define | igstkObserverObjectMacro(name, eventType, payloadType) |
#define | igstkObserverConstObjectMacro(name, eventType, payloadType) |
It includes the Get, Set and Log macros.
Definition in file igstkMacros.h.
#define igstkLogMacro | ( | x, | |||
y | ) |
Value:
{ \ if (this->GetLogger() ) \ { \ if (this->GetLogger()->ShouldBuildMessage( ::igstk::Logger::x ) ) \ { \ ::itk::OStringStream message; \ message << y; \ this->GetLogger()->Write(::itk::Logger::x, message.str()); \ } \ } \ }
Definition at line 44 of file igstkMacros.h.
#define igstkLogMacroStatic | ( | obj, | |||
x, | |||||
y | ) |
Value:
{ \ if (obj->GetLogger() ) \ { \ if (obj->GetLogger()->ShouldBuildMessage( ::igstk::Logger::x ) ) \ { \ ::itk::OStringStream message; \ message << y; \ obj->GetLogger()->Write(::itk::Logger::x, message.str()); \ } \ } \ }
Definition at line 61 of file igstkMacros.h.
#define igstkLogMacro2 | ( | logger, | |||
x, | |||||
y | ) |
Value:
{ \ if ( logger ) \ { \ if (logger->ShouldBuildMessage( ::igstk::Logger::x )) \ { \ ::itk::OStringStream message; \ message << y; \ logger->Write(::itk::Logger::x, message.str()); \ } \ } \ }
Definition at line 78 of file igstkMacros.h.
#define igstkSetMacro | ( | name, | |||
type | ) |
Value:
virtual void Set##name (const type & _arg) \ { \ if (this->m_##name != _arg) \ { \ this->m_##name = _arg; \ } \ }
Creates member Set"name"() (e.g., SetTimeStep(time));
Definition at line 93 of file igstkMacros.h.
#define igstkGetMacro | ( | name, | |||
type | ) |
Value:
virtual const type & Get##name () const \ { \ return this->m_##name; \ }
Creates member Get"name"() (e.g., GetTimeStep(time));
Definition at line 105 of file igstkMacros.h.
#define igstkNewMacro | ( | x | ) |
Value:
static Pointer New(void) \ { \ Pointer smartPtr; \ x *rawPtr = new x; \ smartPtr = rawPtr; \ rawPtr->UnRegister(); \ return smartPtr; \ }
This macro differs from the one in ITK in that it DOES NOT uses factories. Factories add run-time uncertainty that is undesirable for IGSTK.
Definition at line 115 of file igstkMacros.h.
#define igstkTypeMacro | ( | thisClass, | |||
superclass | ) | virtual const char *GetNameOfClass() const {return #thisClass;} |
Type Macro defines the GetNameOfClass() method for every class where it is invoked.
Definition at line 128 of file igstkMacros.h.
#define igstkFriendClassMacro | ( | type | ) | friend type |
Create a Macro for friend class.
This will take care of platform specific ways of declaring a class as a friend
Definition at line 137 of file igstkMacros.h.
#define igstkLoggerMacro | ( | ) |
Value:
public: \ typedef ::igstk::Logger LoggerType; \ protected: \ LoggerType* GetLogger() const { return m_Logger; } \ private: \ mutable LoggerType::Pointer m_Logger; \ public: \ void SetLogger(LoggerType* logger) { m_Logger = logger; }
LoggerType must be defined before this macro is used.
Definition at line 143 of file igstkMacros.h.
#define igstkSetStringMacro | ( | name | ) |
Value:
virtual void Set##name (const char* _arg) \ { \ if ( _arg && (_arg == this->m_##name) ) { return;} \ if (_arg) \ { \ this->m_##name = _arg;\ } \ else \ { \ this->m_##name = ""; \ } \ this->Modified(); \ } \ virtual void Set##name (const std::string & _arg) \ { \ this->Set##name( _arg.c_str() ); \ } \
Creates member Set"name"() (e.g., SetFilename(char *)). The macro assumes that the class member (name) is declared a type std::string.
Definition at line 157 of file igstkMacros.h.
#define igstkGetStringMacro | ( | name | ) |
Value:
virtual const char* Get##name () const \ { \ return this->m_##name.c_str(); \ }
Creates member Get"name"() (e.g., SetFilename(char *)). The macro assumes that the class member (name) is declared as a type std::string.
Definition at line 180 of file igstkMacros.h.
#define igstkStateMachineMacroBase | ( | igstktypename | ) |
Value:
private: \ typedef ::igstk::StateMachine< Self > StateMachineType; \ typedef igstktypename StateMachineType::TMemberFunctionPointer ActionType; \ typedef igstktypename StateMachineType::StateType StateType; \ typedef igstktypename StateMachineType::InputType InputType; \ typedef igstktypename StateMachineType::OutputStreamType OutputStreamType; \ igstkFriendClassMacro( ::igstk::StateMachine< Self > ); \ StateMachineType m_StateMachine; \ typedef ::itk::ReceptorMemberCommand< Self > ReceptorObserverType; \ typedef igstktypename ReceptorObserverType::Pointer \ ReceptorObserverPointer; \ public: \ void ExportStateMachineDescription( OutputStreamType & ostr, \ bool skipLoops=false ) const \ { m_StateMachine.ExportDescription( ostr, skipLoops ); } \ void ExportStateMachineDescriptionToLTS( OutputStreamType & ostr,\ bool skipLoops=false ) const \ { m_StateMachine.ExportDescriptionToLTS( ostr, skipLoops ); } \ void ExportStateMachineDescriptionToSCXML( OutputStreamType & ostr,\ bool skipLoops=false ) const \ { m_StateMachine.ExportDescriptionToSCXML( ostr, skipLoops ); }
This macro factorizes code that should always be present when using the StateMachine.
Definition at line 190 of file igstkMacros.h.
#define EMPTYPARAMETER |
Definition at line 213 of file igstkMacros.h.
#define igstkStateMachineMacro | ( | ) | igstkStateMachineMacroBase( EMPTYPARAMETER ) |
This is the StateMachine Macro to be used with non-templated classes.
Definition at line 216 of file igstkMacros.h.
#define igstkStateMachineTemplatedMacro | ( | ) | igstkStateMachineMacroBase( typename ) |
This is the StateMachine Macro to be used with templated classes.
Definition at line 219 of file igstkMacros.h.
#define igstkDeclareInputMacro | ( | inputname | ) | InputType m_##inputname##Input |
Convenience macro for declaring Inputs to the State Machine.
Definition at line 223 of file igstkMacros.h.
#define igstkDeclareStateMacro | ( | inputname | ) | StateType m_##inputname##State |
Convenience macro for declaring States of the State Machine.
Definition at line 228 of file igstkMacros.h.
#define igstkAddInputMacro | ( | inputname | ) |
Value:
this->m_StateMachine.AddInput( this->m_##inputname##Input, \
#inputname"Input" );
Definition at line 233 of file igstkMacros.h.
#define igstkAddStateMacro | ( | statename | ) |
Value:
this->m_StateMachine.AddState( this->m_##statename##State,\
#statename"State" );
Definition at line 239 of file igstkMacros.h.
#define igstkAddTransitionMacro | ( | state1, | |||
input, | |||||
state2, | |||||
action | ) |
Value:
this->m_StateMachine.AddTransition( this->m_##state1##State, \ this->m_##input##Input, \ this->m_##state2##State, \ & Self::action##Processing );
Definition at line 244 of file igstkMacros.h.
#define igstkSetInitialStateMacro | ( | inputname | ) | this->m_StateMachine.SelectInitialState( this->m_##inputname##State ); |
Convenience macro for selecting the initial States of the State Machine.
Definition at line 252 of file igstkMacros.h.
#define igstkPushInputMacro | ( | inputname | ) | this->m_StateMachine.PushInput( this->m_##inputname##Input ); |
Convenience macro for pushing an input in the queue of the State Machine.
Definition at line 257 of file igstkMacros.h.
#define igstkStandardClassBasicTraitsMacro | ( | classname, | |||
superclassname | ) |
Value:
typedef classname Self; \ typedef superclassname Superclass; \ typedef ::itk::SmartPointer< Self > Pointer; \ typedef ::itk::SmartPointer< const Self > ConstPointer; \ igstkTypeMacro( classname, superclassname);
Definition at line 262 of file igstkMacros.h.
#define igstkStandardAbstractClassTraitsMacro | ( | classname, | |||
superclassname | ) |
Value:
igstkStandardClassBasicTraitsMacro( classname, superclassname ) \ igstkStateMachineMacro();
Definition at line 270 of file igstkMacros.h.
#define igstkStandardClassTraitsMacro | ( | classname, | |||
superclassname | ) |
Value:
igstkStandardAbstractClassTraitsMacro( classname, superclassname ) \ igstkNewMacro( Self );
Definition at line 275 of file igstkMacros.h.
#define igstkStandardTemplatedAbstractClassTraitsMacro | ( | classname, | |||
superclassname | ) |
Value:
igstkStandardClassBasicTraitsMacro( classname, superclassname ) \ igstkStateMachineTemplatedMacro();
Definition at line 281 of file igstkMacros.h.
#define igstkStandardTemplatedClassTraitsMacro | ( | classname, | |||
superclassname | ) |
Value:
igstkStandardTemplatedAbstractClassTraitsMacro( classname, superclassname ) \ igstkNewMacro( Self );
Definition at line 286 of file igstkMacros.h.
#define igstkEventTransductionMacro | ( | event, | |||
input | ) |
Value:
private: \ ReceptorObserverPointer m_Observer##event##input; \ void Callback##event##input##Input( const ::itk::EventObject & ) \ { \ igstkPushInputMacro( input ); \ m_StateMachine.ProcessInputs(); \ } \ public: \ void Observe##event##Event(const ::igstk::Object * object ) \ { \ m_Observer##event##input = ReceptorObserverType::New(); \ m_Observer##event##input->SetCallbackFunction( this, \ & Self::Callback##event##input##Input ); \ unsigned long tag = object->AddObserver( \ ::igstk::event##Event(),m_Observer##event##input ); \ this->RegisterObservedObject( object, tag ); \ }
Definition at line 293 of file igstkMacros.h.
#define igstkLoadedEventTransductionMacro | ( | event, | |||
input | ) |
Value:
private: \ ReceptorObserverPointer m_Observer##event##input; \ ::igstk::event##Event::PayloadType m_##input##InputToBeSet; \ void Callback##event##input##Input( const ::itk::EventObject & eventvar ) \ { \ const ::igstk::event##Event * realevent = \ dynamic_cast < const ::igstk::event##Event * > ( &eventvar ); \ if( realevent ) \ { \ m_##input##InputToBeSet = realevent->Get(); \ igstkPushInputMacro( input ); \ m_StateMachine.ProcessInputs(); \ } \ } \ public: \ void Observe##input##Input(const ::igstk::Object * object ) \ { \ m_Observer##event##input = ReceptorObserverType::New(); \ m_Observer##event##input->SetCallbackFunction( this,\ & Self::Callback##event##input##Input ); \ unsigned long tag = object->AddObserver( \ ::igstk::event##Event(),m_Observer##event##input ); \ this->RegisterObservedObject( object, tag ); \ }
Definition at line 316 of file igstkMacros.h.
#define igstkLoadedObjectEventTransductionMacro | ( | event, | |||
input | ) |
Value:
private: \ ReceptorObserverPointer m_Observer##event##input; \ ::igstk::event##Event::PayloadType * m_##input##InputToBeSet; \ void Callback##event##input##Input( const ::itk::EventObject & eventvar ) \ { \ const ::igstk::event##Event * realevent = \ dynamic_cast < const ::igstk::event##Event * > ( &eventvar ); \ if( realevent ) \ { \ m_##input##InputToBeSet = realevent->Get(); \ igstkPushInputMacro( input ); \ m_StateMachine.ProcessInputs(); \ } \ } \ public: \ void Observe##input##Input(const ::igstk::Object * object ) \ { \ m_Observer##event##input = ReceptorObserverType::New(); \ m_Observer##event##input->SetCallbackFunction( this,\ & Self::Callback##event##input##Input ); \ unsigned long tag = object->AddObserver( \ ::igstk::event##Event(),m_Observer##event##input ); \ this->RegisterObservedObject( object, tag ); \ }
Definition at line 341 of file igstkMacros.h.
#define igstkObserverMacro | ( | name, | |||
eventType, | |||||
payloadType | ) |
Definition at line 368 of file igstkMacros.h.
#define igstkObserverObjectMacro | ( | name, | |||
eventType, | |||||
payloadType | ) |
Definition at line 421 of file igstkMacros.h.
#define igstkObserverConstObjectMacro | ( | name, | |||
eventType, | |||||
payloadType | ) |
Definition at line 474 of file igstkMacros.h.