JAPAn
Just Another Parity Analyzer
Loading...
Searching...
No Matches
VQwFactory< base_t > Class Template Referenceabstract

Abstract factory base for runtime object creation. More...

#include <QwFactory.h>

+ Inheritance diagram for VQwFactory< base_t >:

Public Member Functions

virtual ~VQwFactory ()
 Default virtual destructor.
 
virtual base_t * Create (const std::string &name) const =0
 Creation of objects by type (pure virtual)
 
virtual base_t * Cast (base_t *base) const =0
 Dynamic cast to type (pure virtual)
 

Static Public Member Functions

static base_t * Create (const std::string &type, const std::string &name)
 Create an object of type with name.
 
static base_t * Cast (base_t *base, const std::string &type)
 Dynamic cast of object into type.
 
static bool InheritsFrom (base_t *base, const std::string &type)
 Test whether object inherits from type.
 

Static Protected Member Functions

static std::map< std::string, VQwFactory * > & GetRegisteredTypes ()
 Map from string to concrete type factories.
 
static void ListRegisteredTypes ()
 List available type factories.
 
static VQwFactoryGetFactory (const std::string &type)
 Get a concrete type factory by string.
 

Detailed Description

template<class base_t>
class VQwFactory< base_t >

Abstract factory base for runtime object creation.

Enables instantiation of derived types based on runtime string identifiers. Maintains a registry of concrete factory instances that can create objects of specified types. Used throughout the framework to support configuration- driven object creation for subsystems, data handlers, and data elements.

Definition at line 39 of file QwFactory.h.

Constructor & Destructor Documentation

◆ ~VQwFactory()

template<class base_t>
virtual VQwFactory< base_t >::~VQwFactory ( )
inlinevirtual

Default virtual destructor.

Definition at line 44 of file QwFactory.h.

44{ }

Member Function Documentation

◆ Cast() [1/2]

template<class base_t>
virtual base_t * VQwFactory< base_t >::Cast ( base_t * base) const
pure virtual

◆ Cast() [2/2]

template<class base_t>
static base_t * VQwFactory< base_t >::Cast ( base_t * base,
const std::string & type )
inlinestatic

Dynamic cast of object into type.

Definition at line 52 of file QwFactory.h.

52 {
53 return GetFactory(type)->Cast(base);
54 }
Abstract factory base for runtime object creation.
Definition QwFactory.h:39
static base_t * Cast(base_t *base, const std::string &type)
Dynamic cast of object into type.
Definition QwFactory.h:52
static VQwFactory * GetFactory(const std::string &type)
Get a concrete type factory by string.
Definition QwFactory.h:82

References Cast(), and GetFactory().

Referenced by Cast(), and InheritsFrom().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Create() [1/2]

template<class base_t>
virtual base_t * VQwFactory< base_t >::Create ( const std::string & name) const
pure virtual

◆ Create() [2/2]

template<class base_t>
static base_t * VQwFactory< base_t >::Create ( const std::string & type,
const std::string & name )
inlinestatic

Create an object of type with name.

Definition at line 47 of file QwFactory.h.

47 {
48 return GetFactory(type)->Create(name);
49 }
static base_t * Create(const std::string &type, const std::string &name)
Create an object of type with name.
Definition QwFactory.h:47

References Create(), and GetFactory().

Referenced by Create().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetFactory()

template<class base_t>
static VQwFactory * VQwFactory< base_t >::GetFactory ( const std::string & type)
inlinestaticprotected

Get a concrete type factory by string.

Definition at line 82 of file QwFactory.h.

82 {
84 return GetRegisteredTypes()[type];
85 else {
86 QwError << "Type " << type << " is not registered!" << QwLog::endl;
87 QwMessage << "Available types:" << QwLog::endl;
89 QwWarning << "To register this type, add the following line to the top "
90 << "of the source file:" << QwLog::endl;
91 QwWarning << " REGISTER_SOMETHING_FACTORY(" << type << ");" << QwLog::endl;
92 QwWarning << "Ensure that the dynamic library contains the factory object."
93 << QwLog::endl;
95 }
96 }
static void ListRegisteredTypes()
List available type factories.
Definition QwFactory.h:74
static std::map< std::string, VQwFactory * > & GetRegisteredTypes()
Map from string to concrete type factories.
Definition QwFactory.h:69

References QwLog::endl(), GetRegisteredTypes(), ListRegisteredTypes(), QwError, QwMessage, and QwWarning.

Referenced by Cast(), and Create().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetRegisteredTypes()

template<class base_t>
static std::map< std::string, VQwFactory * > & VQwFactory< base_t >::GetRegisteredTypes ( )
inlinestaticprotected

Map from string to concrete type factories.

Definition at line 69 of file QwFactory.h.

69 {
71 return theMap;
72 }

Referenced by GetFactory(), ListRegisteredTypes(), and QwFactory< base_t, type_t >::QwFactory().

+ Here is the caller graph for this function:

◆ InheritsFrom()

template<class base_t>
static bool VQwFactory< base_t >::InheritsFrom ( base_t * base,
const std::string & type )
inlinestatic

Test whether object inherits from type.

Definition at line 57 of file QwFactory.h.

57 {
58 return (Cast(base,type) != 0);
59 }

References Cast().

+ Here is the call graph for this function:

◆ ListRegisteredTypes()

template<class base_t>
static void VQwFactory< base_t >::ListRegisteredTypes ( )
inlinestaticprotected

List available type factories.

Definition at line 74 of file QwFactory.h.

74 {
76 for (type = GetRegisteredTypes().begin();
77 type != GetRegisteredTypes().end(); type++ )
78 QwMessage << type->first << QwLog::endl;
79 }

References QwLog::endl(), GetRegisteredTypes(), and QwMessage.

Referenced by GetFactory().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

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