Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
igtl::ObjectFactory< T > Class Template Referenceabstract

#include <igtlObjectFactory.h>

Inheritance diagram for igtl::ObjectFactory< T >:
Inheritance graph
[legend]
Collaboration diagram for igtl::ObjectFactory< T >:
Collaboration graph
[legend]

Public Types

typedef SmartPointer< const SelfConstPointer
 
typedef SmartPointer< SelfPointer
 
typedef ObjectFactoryBase Self
 
typedef Object Superclass
 

Public Member Functions

virtual LightObject::Pointer CreateAnother () const
 
virtual void DebugOff () const
 
virtual void DebugOn () const
 
virtual void Delete ()
 
virtual void Disable (const char *className)
 
virtual std::list< std::string > GetClassOverrideDescriptions ()
 
virtual std::list< std::string > GetClassOverrideNames ()
 
virtual std::list< std::string > GetClassOverrideWithNames ()
 
bool GetDebug () const
 
virtual const char * GetDescription (void) const =0
 
virtual bool GetEnableFlag (const char *className, const char *subclassName)
 
virtual std::list< bool > GetEnableFlags ()
 
virtual const char * GetIGTLSourceVersion (void) const =0
 
const char * GetLibraryPath ()
 
virtual const char * GetNameOfClass () const
 
virtual int GetReferenceCount () const
 
 igtlTypeMacro (ObjectFactoryBase, Object)
 
 igtlTypeMacro (Object, LightObject)
 
void Print (std::ostream &os) const
 
virtual void Register () const
 
void SetDebug (bool debugFlag) const
 
virtual void SetEnableFlag (bool flag, const char *className, const char *subclassName)
 
virtual void SetReferenceCount (int)
 
virtual void UnRegister () const
 

Static Public Member Functions

static void BreakOnError ()
 
static T::Pointer Create ()
 
static std::list< LightObject::PointerCreateAllInstance (const char *igtlclassname)
 
static LightObject::Pointer CreateInstance (const char *igtlclassname)
 
static std::list< ObjectFactoryBase * > GetRegisteredFactories ()
 
static Pointer New ()
 
static void RegisterFactory (ObjectFactoryBase *)
 
static void ReHash ()
 
static void UnRegisterAllFactories ()
 
static void UnRegisterFactory (ObjectFactoryBase *)
 
static void SetGlobalWarningDisplay (bool flag)
 
static bool GetGlobalWarningDisplay ()
 
static void GlobalWarningDisplayOn ()
 
static void GlobalWarningDisplayOff ()
 

Protected Member Functions

virtual LightObject::Pointer CreateObject (const char *igtlclassname)
 
virtual void PrintSelf (std::ostream &os) const
 
void RegisterOverride (const char *classOverride, const char *overrideClassName, const char *description, bool enableFlag, CreateObjectFunctionBase *createFunction)
 
virtual void PrintHeader (std::ostream &os) const
 
virtual void PrintTrailer (std::ostream &os) const
 

Protected Attributes

volatile int m_ReferenceCount
 
SimpleFastMutexLock m_ReferenceCountLock
 

Detailed Description

template<class T>
class igtl::ObjectFactory< T >

Create instances of a class.

ObjectFactory is a helper class used to created instances of a class. Object factories are used for instantiation because they allow run-time replacement of a class with a user-supplied version. For example, if you wished to replace an algorithm with your own custom version, or with a hardware-accelerated version, ObjectFactory can be used to do this.

This implementation of the object factory is templated and uses RTTI (Run-Time Type Information) to create the name of the class it is to instantiate. (The name may include template type parameters, depending on the class definition.)

Definition at line 60 of file igtlObjectFactory.h.

Member Typedef Documentation

◆ ConstPointer

Definition at line 70 of file igtlObjectFactoryBase.h.

◆ Pointer

Definition at line 69 of file igtlObjectFactoryBase.h.

◆ Self

Standard class typedefs.

Definition at line 67 of file igtlObjectFactoryBase.h.

◆ Superclass

Definition at line 68 of file igtlObjectFactoryBase.h.

Member Function Documentation

◆ BreakOnError()

static void igtl::LightObject::BreakOnError ( )
staticinherited

This method is called when igtlExceptionMacro executes. It allows the debugger to break on error.

◆ Create()

template<class T >
static T::Pointer igtl::ObjectFactory< T >::Create ( )
inlinestatic

◆ CreateAllInstance()

static std::list<LightObject::Pointer> igtl::ObjectFactoryBase::CreateAllInstance ( const char *  igtlclassname)
staticinherited

Create and return all possible instances of the named igtl object. Each loaded ObjectFactoryBase will be asked in the order the factory was in the IGTL_AUTOLOAD_PATH. All created objects will be returned in the list.

◆ CreateAnother()

virtual LightObject::Pointer igtl::Object::CreateAnother ( ) const
virtualinherited

Create an object from an instance, potentially deferring to a factory. This method allows you to create an instance of an object that is exactly the same type as the referring object. This is useful in cases where an object has been cast back to a base class.

Reimplemented from igtl::LightObject.

◆ CreateInstance()

static LightObject::Pointer igtl::ObjectFactoryBase::CreateInstance ( const char *  igtlclassname)
staticinherited

Create and return an instance of the named igtl object. Each loaded ObjectFactoryBase will be asked in the order the factory was in the IGTL_AUTOLOAD_PATH. After the first factory returns the object no other factories are asked.

Referenced by igtl::ObjectFactory< T >::Create().

◆ CreateObject()

virtual LightObject::Pointer igtl::ObjectFactoryBase::CreateObject ( const char *  igtlclassname)
protectedvirtualinherited

This method is provided by sub-classes of ObjectFactoryBase. It should create the named igtl object or return 0 if that object is not supported by the factory implementation.

◆ DebugOff()

virtual void igtl::Object::DebugOff ( ) const
virtualinherited

Turn debugging output off.

◆ DebugOn()

virtual void igtl::Object::DebugOn ( ) const
virtualinherited

Turn debugging output on.

◆ Delete()

virtual void igtl::LightObject::Delete ( )
virtualinherited

Delete an igtl object. This method should always be used to delete an object when the new operator was used to create it. Using the C delete method will not work with reference counting.

◆ Disable()

virtual void igtl::ObjectFactoryBase::Disable ( const char *  className)
virtualinherited

Set all enable flags for the given class to 0. This will mean that the factory will stop producing class with the given name.

◆ GetClassOverrideDescriptions()

virtual std::list<std::string> igtl::ObjectFactoryBase::GetClassOverrideDescriptions ( )
virtualinherited

Return a list of descriptions for class overrides.

◆ GetClassOverrideNames()

virtual std::list<std::string> igtl::ObjectFactoryBase::GetClassOverrideNames ( )
virtualinherited

Return a list of classes that this factory overrides.

◆ GetClassOverrideWithNames()

virtual std::list<std::string> igtl::ObjectFactoryBase::GetClassOverrideWithNames ( )
virtualinherited

Return a list of the names of classes that override classes.

◆ GetDebug()

bool igtl::Object::GetDebug ( ) const
inherited

Get the value of the debug flag.

◆ GetDescription()

virtual const char* igtl::ObjectFactoryBase::GetDescription ( void  ) const
pure virtualinherited

Return a descriptive string describing the factory.

◆ GetEnableFlag()

virtual bool igtl::ObjectFactoryBase::GetEnableFlag ( const char *  className,
const char *  subclassName 
)
virtualinherited

Get the Enable flag for the specific override of className.

◆ GetEnableFlags()

virtual std::list<bool> igtl::ObjectFactoryBase::GetEnableFlags ( )
virtualinherited

Return a list of enable flags.

◆ GetGlobalWarningDisplay()

static bool igtl::Object::GetGlobalWarningDisplay ( )
staticinherited

This is a global flag that controls whether any debug, warning or error messages are displayed.

◆ GetIGTLSourceVersion()

virtual const char* igtl::ObjectFactoryBase::GetIGTLSourceVersion ( void  ) const
pure virtualinherited

All sub-classes of ObjectFactoryBase should must return the version of IGTL they were built with. This should be implemented with the macro IGTL_SOURCE_VERSION and NOT a call to Version::GetIGTLSourceVersion. As the version needs to be compiled into the file as a string constant. This is critical to determine possible incompatible dynamic factory loads.

◆ GetLibraryPath()

const char* igtl::ObjectFactoryBase::GetLibraryPath ( )
inherited

This returns the path to a dynamically loaded factory.

◆ GetNameOfClass()

virtual const char* igtl::LightObject::GetNameOfClass ( ) const
inlinevirtualinherited

Return the name of this class as a string. Used by the object factory (implemented in New()) to instantiate objects of a named type. Also used for debugging and other output information.

Definition at line 84 of file igtlLightObject.h.

◆ GetReferenceCount()

virtual int igtl::LightObject::GetReferenceCount ( ) const
inlinevirtualinherited

Gets the reference count on this object.

Definition at line 110 of file igtlLightObject.h.

◆ GetRegisteredFactories()

static std::list<ObjectFactoryBase*> igtl::ObjectFactoryBase::GetRegisteredFactories ( )
staticinherited

Return the list of all registered factories. This is NOT a copy, do not remove items from this list!

◆ GlobalWarningDisplayOff()

static void igtl::Object::GlobalWarningDisplayOff ( )
inlinestaticinherited

This is a global flag that controls whether any debug, warning or error messages are displayed.

Definition at line 116 of file igtlObject.h.

References igtl::Object::SetGlobalWarningDisplay().

◆ GlobalWarningDisplayOn()

static void igtl::Object::GlobalWarningDisplayOn ( )
inlinestaticinherited

This is a global flag that controls whether any debug, warning or error messages are displayed.

Definition at line 114 of file igtlObject.h.

References igtl::Object::SetGlobalWarningDisplay().

◆ igtlTypeMacro() [1/2]

igtl::ObjectFactoryBase::igtlTypeMacro ( ObjectFactoryBase  ,
Object   
)
inherited

Run-time type information (and related methods).

◆ igtlTypeMacro() [2/2]

igtl::Object::igtlTypeMacro ( Object  ,
LightObject   
)
inherited

Standard part of all igtl objects.

◆ New()

static Pointer igtl::Object::New ( )
staticinherited

Method for creation through the object factory.

◆ Print()

void igtl::LightObject::Print ( std::ostream &  os) const
inherited

Cause the object to print itself out.

◆ PrintHeader()

virtual void igtl::LightObject::PrintHeader ( std::ostream &  os) const
protectedvirtualinherited

Methods invoked by Print() to print information about the object including superclasses. Typically not called by the user (use Print() instead) but used in the hierarchical print process to combine the output of several classes.

◆ PrintSelf()

virtual void igtl::ObjectFactoryBase::PrintSelf ( std::ostream &  os) const
protectedvirtualinherited

Methods invoked by Print() to print information about the object including superclasses. Typically not called by the user (use Print() instead) but used in the hierarchical print process to combine the output of several classes.

Reimplemented from igtl::Object.

◆ PrintTrailer()

virtual void igtl::LightObject::PrintTrailer ( std::ostream &  os) const
protectedvirtualinherited

Methods invoked by Print() to print information about the object including superclasses. Typically not called by the user (use Print() instead) but used in the hierarchical print process to combine the output of several classes.

◆ Register()

virtual void igtl::Object::Register ( ) const
virtualinherited

Return this objects modified time. Update the modification time for this object. Many filters rely on the modification time to determine if they need to recompute their data. Increase the reference count (mark as used by another object).

Reimplemented from igtl::LightObject.

◆ RegisterFactory()

static void igtl::ObjectFactoryBase::RegisterFactory ( ObjectFactoryBase )
staticinherited

Register a factory so it can be used to create igtl objects.

◆ RegisterOverride()

void igtl::ObjectFactoryBase::RegisterOverride ( const char *  classOverride,
const char *  overrideClassName,
const char *  description,
bool  enableFlag,
CreateObjectFunctionBase createFunction 
)
protectedinherited

Register object creation information with the factory.

◆ ReHash()

static void igtl::ObjectFactoryBase::ReHash ( )
staticinherited

Re-check the IGTL_AUTOLOAD_PATH for new factory libraries. This calls UnRegisterAll before re-loading.

◆ SetDebug()

void igtl::Object::SetDebug ( bool  debugFlag) const
inherited

Set the value of the debug flag. A non-zero value turns debugging on.

◆ SetEnableFlag()

virtual void igtl::ObjectFactoryBase::SetEnableFlag ( bool  flag,
const char *  className,
const char *  subclassName 
)
virtualinherited

Set the Enable flag for the specific override of className.

◆ SetGlobalWarningDisplay()

static void igtl::Object::SetGlobalWarningDisplay ( bool  flag)
staticinherited

This is a global flag that controls whether any debug, warning or error messages are displayed.

Referenced by igtl::Object::GlobalWarningDisplayOff(), and igtl::Object::GlobalWarningDisplayOn().

◆ SetReferenceCount()

virtual void igtl::Object::SetReferenceCount ( int  )
virtualinherited

Sets the reference count (use with care)

Reimplemented from igtl::LightObject.

◆ UnRegister()

virtual void igtl::Object::UnRegister ( ) const
virtualinherited

Decrease the reference count (release by another object).

Reimplemented from igtl::LightObject.

◆ UnRegisterAllFactories()

static void igtl::ObjectFactoryBase::UnRegisterAllFactories ( )
staticinherited

Unregister all factories.

◆ UnRegisterFactory()

static void igtl::ObjectFactoryBase::UnRegisterFactory ( ObjectFactoryBase )
staticinherited

Remove a factory from the list of registered factories.

Member Data Documentation

◆ m_ReferenceCount

volatile int igtl::LightObject::m_ReferenceCount
mutableprotectedinherited

Number of uses of this object by other objects.

Definition at line 131 of file igtlLightObject.h.

◆ m_ReferenceCountLock

SimpleFastMutexLock igtl::LightObject::m_ReferenceCountLock
mutableprotectedinherited

Mutex lock to protect modification to the reference count

Definition at line 134 of file igtlLightObject.h.


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

Generated at Sat Apr 15 2017 02:30:07 for OpenIGTLink by doxygen 1.8.13 written by Dimitri van Heesch, © 1997-2012