38template <
class base_t>
47 static base_t*
Create(
const std::string& type,
const std::string& name) {
52 static base_t*
Cast(base_t* base,
const std::string& type) {
58 return (
Cast(base,type) != 0);
62 virtual base_t*
Create(
const std::string& name)
const = 0;
64 virtual base_t*
Cast(base_t* base)
const = 0;
70 static std::map<std::string,VQwFactory<base_t>*> theMap;
75 typename std::map<std::string,VQwFactory<base_t>*>::iterator type;
89 QwWarning <<
"To register this type, add the following line to the top "
92 QwWarning <<
"Ensure that the dynamic library contains the factory object."
111template <
class base_t,
class type_t>
122 base_t*
Create(
const std::string& name)
const override {
123 return new type_t(name);
127 type_t*
Cast(base_t* base)
const override {
128 return dynamic_cast<type_t*
>(base);
152template <
class handler_t>
154template <
class subsystem_t>
156template <
class dataelement_t>
169template <
class base_t>
180 const std::type_index ti =
typeid(*this);
181 char* name = abi::__cxa_demangle(ti.name(), 0, 0, &status);
182 std::string str(name);
211template <
class base_t,
class type_t>
221 return new type_t(
static_cast<const type_t&
>(*
this));
228 static base_t*
Create(
const std::string& name) {
234 static type_t*
Cast(type_t* type) {
248template <
class subsystem_t>
252template <
class subsystem_t>
256template <
class dataelement_t>
263#define REGISTER_DATA_HANDLER_FACTORY(A) \
264 VALIDATE_DATA_HANDLER_PATTERN(A); \
265 template<> const VQwDataHandlerFactory* MQwCloneable<VQwDataHandler,A>::fFactory = new QwFactory<VQwDataHandler,A>(#A)
270#define REGISTER_SUBSYSTEM_FACTORY(A) \
271 VALIDATE_SUBSYSTEM_PATTERN(A); \
272 template<> const VQwSubsystemFactory* MQwCloneable<VQwSubsystem,A>::fFactory = new QwFactory<VQwSubsystem,A>(#A)
277#define REGISTER_DATA_ELEMENT_FACTORY(A) \
278 VALIDATE_DATA_ELEMENT_PATTERN(A); \
279 template<> const VQwDataElementFactory* MQwCloneable<VQwDataElement,A>::fFactory = new QwFactory<VQwDataElement,A>(#A)
A logfile class, based on an identical class in the Hermes analyzer.
#define QwError
Predefined log drain for errors.
#define QwWarning
Predefined log drain for warnings.
#define QwMessage
Predefined log drain for regular messages.
class VQwCloneable< VQwSubsystem > VQwSubsystemCloneable
Mix-in factory functionality for subsystems.
class VQwCloneable< VQwDataHandler > VQwDataHandlerCloneable
Mix-in factory functionality for datahandlers.
class VQwCloneable< VQwDataElement > VQwDataElementCloneable
Mix-in factory functionality for data elements.
class VQwFactory< VQwDataHandler > VQwDataHandlerFactory
Factory type with functionality for data handlers.
class VQwFactory< VQwDataElement > VQwDataElementFactory
Factory type with functionality for data elements.
class VQwFactory< VQwSubsystem > VQwSubsystemFactory
Factory type with functionality for subsystems.
QwException_TypeUnknown()
Abstract factory base for runtime object creation.
static void ListRegisteredTypes()
List available type factories.
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)
virtual ~VQwFactory()
Default virtual destructor.
static base_t * Cast(base_t *base, const std::string &type)
Dynamic cast of object into type.
static std::map< std::string, VQwFactory * > & GetRegisteredTypes()
Map from string to concrete type factories.
static VQwFactory * GetFactory(const std::string &type)
Get a concrete type factory by string.
static bool InheritsFrom(base_t *base, const std::string &type)
Test whether object inherits from type.
static base_t * Create(const std::string &type, const std::string &name)
Create an object of type with name.
base_t * Create(const std::string &name) const override
Concrete type creation.
type_t * Cast(base_t *base) const override
Dynamic cast of type.
QwFactory(const std::string &type)
Constructor which stores type name in list of registered types.
Virtual base providing polymorphic copy construction.
virtual base_t * Clone() const
Abstract clone method when no derived method is defined.
virtual const VQwFactory< base_t > * Factory() const
Virtual factory getter.
virtual ~VQwCloneable()
Virtual destructor.
std::string GetClassName() const
Get demangled name of this class.
Mix-in template for concrete cloneable types.
static type_t * Cast(type_t *type)
Object dynamic cast.
const VQwFactory< base_t > * Factory() const override
Factory getter.
static base_t * Create(const std::string &name)
Object creation.
base_t * Clone() const override
Concrete clone method.
static const VQwFactory< base_t > * fFactory
Pointer to the factory of this type.
~MQwCloneable() override
Virtual destructor.
static std::ostream & endl(std::ostream &)
End of the line.
The pure virtual base class of all data elements.
Base class for subsystems implementing container-delegation pattern.
Abstract base for handlers that consume multiple subsystems and produce derived outputs.