NifTK  16.4.1 - 0798f20
CMIC's Translational Medical Imaging Platform
Public Types | Public Member Functions | Public Attributes | Protected Member Functions | List of all members
niftk::AtomicStateTransitionTester< TestObject, TestObjectState > Class Template Reference

Test class to ensure the atomic transition from one object state to another. More...

Inheritance diagram for niftk::AtomicStateTransitionTester< TestObject, TestObjectState >:
Inheritance graph
[legend]
Collaboration diagram for niftk::AtomicStateTransitionTester< TestObject, TestObjectState >:
Collaboration graph
[legend]

Public Types

typedef ItkSignalCollector::Signals ItkSignals
 
typedef QtSignalCollector::Signal QtSignal
 
typedef QtSignalCollector::Signals QtSignals
 

Public Member Functions

 mitkClassMacroItkParent (AtomicStateTransitionTester, itk::Object) mitkNewMacro1Param(AtomicStateTransitionTester
 
virtual TestObject GetTestObject () const
 Gets the object whose state consistency is being tested. More...
 
virtual TestObjectState::Pointer GetInitialState () const
 Gets the initial state of the test object. More...
 
virtual TestObjectState::Pointer GetNextState () const
 Gets the next state of the test object. More...
 
virtual TestObjectState::Pointer GetExpectedState () const
 Gets the expected state of the test object. More...
 
virtual void SetExpectedState (typename TestObjectState::Pointer _arg)
 Sets the expected state of the test object. More...
 
virtual void Clear ()
 Clears the collected signals and resets the states. More...
 
void Connect (itk::Object *itkObject, const itk::EventObject &event)
 Connects this object to the specified events of itkObject. The consistency of the test object will be checked after these ITK events. More...
 
void Connect (const itk::EventObject &event)
 Connects this object to the specified events of the test object. The consistency of the test object will be checked after these ITK events. The function assumes that the test object is an itk::Object. More...
 
void Connect (const QObject *qObject, const char *signal=0)
 Connects this object to the specified signals of the given object. The consistency of the test object will be checked after these Qt signals. The function assumes that the test object is a QObject. More...
 
void Connect (const char *signal)
 Connects this object to the specified signals of the test object. The consistency of the test object will be checked after these Qt signals. The function assumes that the test object is a QObject. More...
 
const ItkSignalsGetItkSignals () const
 Returns the collected ITK signals. More...
 
ItkSignals GetItkSignals (const itk::Object *itkObject, const itk::EventObject &event=itk::AnyEvent()) const
 Returns a set of the collected ITK signals that are sent from the given object, and are of the given type or its subtype. More...
 
ItkSignals GetItkSignals (const itk::EventObject &event) const
 Returns a set of the collected ITK signals that are of the given type or its subtype. More...
 
const QtSignalsGetQtSignals () const
 Gets the Qt signals collected by this object. More...
 
QtSignals GetQtSignals (const QObject *object, const char *signal=0)
 Returns a set of the collected Qt signals that are of the given type. More...
 
QtSignals GetQtSignals (const char *signal)
 Returns a set of the collected Qt signals that are sent from the given object, and are of the given type. More...
 

Public Attributes

TestObject typedef
ItkSignalCollector::Signal 
ItkSignal
 

Protected Member Functions

 AtomicStateTransitionTester (TestObject testObject)
 Constructs an AtomicStateTransitionTester object. More...
 
virtual ~AtomicStateTransitionTester ()
 Destructs an AtomicStateTransitionTester object. More...
 
virtual void OnItkSignalReceived (const itk::Object *object, const itk::EventObject &event)
 Handler for the ITK signals. Checks the consistency of the test object. More...
 
virtual void OnQtSignalReceived (const QObject *object, const char *signal)
 Handler for the Qt signals. Checks the consistency of the test object. More...
 
virtual void PrintSelf (std::ostream &os, itk::Indent indent) const
 Prints the collected signals to the given stream or to the standard output if no stream is given. More...
 

Detailed Description

template<class TestObject, class TestObjectState>
class niftk::AtomicStateTransitionTester< TestObject, TestObjectState >

Test class to ensure the atomic transition from one object state to another.

The state of the tested object must change at most once during the execution of a public function.

Pattern of use:

typedef niftk::AtomicStateTransitionTester<Viewer, ViewerState> ViewerStateTester;
ViewerStateTester::Pointer viewerStateTester = ViewerStateTester::New(viewer);

Connect the object to the ITK or Qt events sent out from this object or some of its aggregated objects:

viewer->Connect(viewer->GetAxialWindow(), mitk::FocusEvent()); ... viewer->SomePublicFunction(...);

Check the received signals if needed:

QVERIFY( viewerStateTester->GetItkSignals( mitk::FocusEvent() ).size() == 1 );

viewerStateTester->Clear(); viewer->AnotherPublicFunction(...); ...

Member Typedef Documentation

template<class TestObject , class TestObjectState >
typedef ItkSignalCollector::Signals niftk::AtomicStateTransitionTester< TestObject, TestObjectState >::ItkSignals
template<class TestObject , class TestObjectState >
typedef QtSignalCollector::Signal niftk::AtomicStateTransitionTester< TestObject, TestObjectState >::QtSignal
template<class TestObject , class TestObjectState >
typedef QtSignalCollector::Signals niftk::AtomicStateTransitionTester< TestObject, TestObjectState >::QtSignals

Constructor & Destructor Documentation

template<class TestObject , class TestObjectState >
niftk::AtomicStateTransitionTester< TestObject, TestObjectState >::AtomicStateTransitionTester ( TestObject  testObject)
protected

Constructs an AtomicStateTransitionTester object.

We collect the ITK signals using an ItkSignalCollector object.

If the tested object is a QObject then let us discover its public signals and connect this object to them.

Note: The SIGNAL macro preprends a '2' before the signals and '1' before slots. So that the connect mechanism works, we have to imitate this behaviour here.

template<class TestObject , class TestObjectState >
niftk::AtomicStateTransitionTester< TestObject, TestObjectState >::~AtomicStateTransitionTester ( )
protectedvirtual

Destructs an AtomicStateTransitionTester object.

Member Function Documentation

template<class TestObject , class TestObjectState >
void niftk::AtomicStateTransitionTester< TestObject, TestObjectState >::Clear ( void  )
virtual

Clears the collected signals and resets the states.

template<class TestObject , class TestObjectState >
void niftk::AtomicStateTransitionTester< TestObject, TestObjectState >::Connect ( itk::Object *  itkObject,
const itk::EventObject &  event 
)

Connects this object to the specified events of itkObject. The consistency of the test object will be checked after these ITK events.

template<class TestObject , class TestObjectState >
void niftk::AtomicStateTransitionTester< TestObject, TestObjectState >::Connect ( const itk::EventObject &  event)

Connects this object to the specified events of the test object. The consistency of the test object will be checked after these ITK events. The function assumes that the test object is an itk::Object.

template<class TestObject , class TestObjectState >
void niftk::AtomicStateTransitionTester< TestObject, TestObjectState >::Connect ( const QObject *  qObject,
const char *  signal = 0 
)

Connects this object to the specified signals of the given object. The consistency of the test object will be checked after these Qt signals. The function assumes that the test object is a QObject.

template<class TestObject , class TestObjectState >
void niftk::AtomicStateTransitionTester< TestObject, TestObjectState >::Connect ( const char *  signal)

Connects this object to the specified signals of the test object. The consistency of the test object will be checked after these Qt signals. The function assumes that the test object is a QObject.

template<class TestObject , class TestObjectState >
virtual TestObjectState::Pointer niftk::AtomicStateTransitionTester< TestObject, TestObjectState >::GetExpectedState ( ) const
virtual

Gets the expected state of the test object.

template<class TestObject , class TestObjectState >
virtual TestObjectState::Pointer niftk::AtomicStateTransitionTester< TestObject, TestObjectState >::GetInitialState ( ) const
virtual

Gets the initial state of the test object.

template<class TestObject , class TestObjectState >
const ItkSignals& niftk::AtomicStateTransitionTester< TestObject, TestObjectState >::GetItkSignals ( ) const
inline

Returns the collected ITK signals.

template<class TestObject , class TestObjectState >
ItkSignals niftk::AtomicStateTransitionTester< TestObject, TestObjectState >::GetItkSignals ( const itk::Object *  itkObject,
const itk::EventObject &  event = itk::AnyEvent() 
) const
inline

Returns a set of the collected ITK signals that are sent from the given object, and are of the given type or its subtype.

template<class TestObject , class TestObjectState >
ItkSignals niftk::AtomicStateTransitionTester< TestObject, TestObjectState >::GetItkSignals ( const itk::EventObject &  event) const
inline

Returns a set of the collected ITK signals that are of the given type or its subtype.

template<class TestObject , class TestObjectState >
virtual TestObjectState::Pointer niftk::AtomicStateTransitionTester< TestObject, TestObjectState >::GetNextState ( ) const
virtual

Gets the next state of the test object.

template<class TestObject , class TestObjectState >
const QtSignals& niftk::AtomicStateTransitionTester< TestObject, TestObjectState >::GetQtSignals ( ) const
inline

Gets the Qt signals collected by this object.

template<class TestObject , class TestObjectState >
QtSignals niftk::AtomicStateTransitionTester< TestObject, TestObjectState >::GetQtSignals ( const QObject *  object,
const char *  signal = 0 
)
inline

Returns a set of the collected Qt signals that are of the given type.

template<class TestObject , class TestObjectState >
QtSignals niftk::AtomicStateTransitionTester< TestObject, TestObjectState >::GetQtSignals ( const char *  signal)
inline

Returns a set of the collected Qt signals that are sent from the given object, and are of the given type.

template<class TestObject , class TestObjectState >
virtual TestObject niftk::AtomicStateTransitionTester< TestObject, TestObjectState >::GetTestObject ( ) const
virtual

Gets the object whose state consistency is being tested.

template<class TestObject , class TestObjectState >
niftk::AtomicStateTransitionTester< TestObject, TestObjectState >::mitkClassMacroItkParent ( AtomicStateTransitionTester< TestObject, TestObjectState >  ,
itk::Object   
)
template<class TestObject , class TestObjectState >
virtual void niftk::AtomicStateTransitionTester< TestObject, TestObjectState >::OnItkSignalReceived ( const itk::Object *  object,
const itk::EventObject &  event 
)
inlineprotectedvirtual

Handler for the ITK signals. Checks the consistency of the test object.

Implements niftk::ItkSignalListener.

template<class TestObject , class TestObjectState >
virtual void niftk::AtomicStateTransitionTester< TestObject, TestObjectState >::OnQtSignalReceived ( const QObject *  object,
const char *  signal 
)
inlineprotectedvirtual

Handler for the Qt signals. Checks the consistency of the test object.

Implements niftk::QtSignalListener.

template<class TestObject , class TestObjectState >
void niftk::AtomicStateTransitionTester< TestObject, TestObjectState >::PrintSelf ( std::ostream &  os,
itk::Indent  indent 
) const
protectedvirtual

Prints the collected signals to the given stream or to the standard output if no stream is given.

template<class TestObject , class TestObjectState >
virtual void niftk::AtomicStateTransitionTester< TestObject, TestObjectState >::SetExpectedState ( typename TestObjectState::Pointer  _arg)
virtual

Sets the expected state of the test object.

Member Data Documentation

template<class TestObject , class TestObjectState >
TestObject typedef ItkSignalCollector::Signal niftk::AtomicStateTransitionTester< TestObject, TestObjectState >::ItkSignal

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