MIRA
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
Class Class Referenceabstract

Class object which supports some kind of class reflection. More...

#include <factory/Class.h>

Inheritance diagram for Class:
Inheritance graph
[legend]

Public Member Functions

virtual ~Class ()
 
virtual std::string const & getIdentifier () const
 Return identifier for the class. More...
 
virtual std::string const & getName () const
 Return name of the class. More...
 
virtual int getTypeId () const =0
 Return unique id for the class. More...
 
virtual Typename getTypename () const =0
 Returns the platform independent C++ typename of the class. More...
 
std::map< std::string, std::string > const & getMetaInfo () const
 Return map with meta information. More...
 
std::string const & getMetaInfo (const std::string &meta) const
 Returns meta information for the given meta key. More...
 
virtual ObjectnewInstance () const =0
 Return a new instance of the class associated with the class object. More...
 
template<class CLASS >
CLASS * newInstance () const
 Return a new instance of the class associated with the class object. More...
 
virtual ObjectnewInstance (int paramCount,...) const =0
 Return a new instance of the class associated with the class object. More...
 
virtual ObjectnewInstance (std::string const &childIdentifier) const =0
 Return a new instance of the child class with the given identifier. More...
 
template<class CLASS >
CLASS * newInstance (std::string const &childIdentifier) const
 Return a new instance of the child class with the given identifier. More...
 
virtual ObjectnewInstance (std::string const &childIdentifier, int paramCount,...) const =0
 Return a new instance of the child class with the given identifier. More...
 
bool isClassRegistered (std::string const &classIdentifier) const
 Return true if a class with the desired identifier is registered. More...
 
void eraseChild (Class const *const iClass)
 Remove the given child class from the class. More...
 
void eraseParent (Class const *const iClass)
 Remove the given class from the list of parents. More...
 
ClassProxy getClassByIdentifier (std::string const &classIdentifier) const
 Return the ClassProxy object for the desired Class. More...
 
std::vector< ClassProxygetClassByMeta (std::string const &metaKey, std::string const &metaValue) const
 Return vector of ClassProxy objects matching the meta criterion. More...
 
template<class T >
std::vector< ClassProxygetClassByMeta (T funcPtr) const
 Return vector of Class objects returning true for the given comparison function. More...
 
std::map< std::string, ClassProxygetDerivedClasses () const
 Return registered children for the associated class to the given map. More...
 
std::map< std::string, ClassProxygetDirectParents () const
 Return map with the direct parents of this class. More...
 
bool isBaseOf (Class const *const derived) const
 Return true if given class is registered and derived from this class. More...
 
bool isBaseOf (ClassProxy derived) const
 Return true if given class is registered and derived from this class. More...
 
bool isBaseOf (std::string const &identifier) const
 Return true if given class is registered and derived from this class. More...
 
bool isDerivedFrom (Class const *const base) const
 Return true if given class is registered and parent of this class. More...
 
bool isDerivedFrom (ClassProxy base) const
 Return true if given class is registered and parent of this class. More...
 
bool isDirectlyDerivedFrom (Class const *const base) const
 Return true if the given class is a direct parent. More...
 
bool isDirectlyDerivedFrom (ClassProxy base) const
 Return true if the given class is a direct parent. More...
 
bool isDeclaredAbstract () const
 Return true if the associated class is declared to be abstract (comparison with isAbstract() allows to detect programming errors.) More...
 
virtual bool isAbstract () const =0
 Return true if the associated class is abstract. More...
 
bool isLibraryLoaded () const
 Return true if the library which contains the associated class is loaded. More...
 
template<typename Reflector >
MIRA_SPLIT_REFLECT_MEMBER void reflectRead (Reflector &r)
 Implementation of class member reflection. More...
 
template<typename Reflector >
void reflectWrite (Reflector &r)
 Implementation of class member reflection. More...
 
bool operator== (Class const &other) const
 Returns true, if the two classes are identical. More...
 
bool operator!= (Class const &other) const
 Returns true, if the two classes are not identical. More...
 
bool operator< (Class const &other) const
 Return true, if the comparison of the identifiers returns true. More...
 
template<typename Reflector >
void reflectRead (Reflector &r)
 

Protected Member Functions

virtual ObjectnewVAInstance (int paramCount, std::va_list) const =0
 Call the specific constructor depending on the number of parameters passed to the function. More...
 
 Class (std::string const &identifier, std::string const &name, std::map< std::string, std::string > const &metaInfo, bool libLoaded)
 This function is called: the constructor. More...
 
 Class (std::string const &identifier, std::string const &name, bool libLoaded)
 This function is called: the constructor. More...
 

Protected Attributes

std::map< std::string, ClassProxymDerivedChildren
 map of children More...
 
std::map< std::string, ClassProxymDirectParents
 map of parents More...
 
std::string mIdentifier
 class identifier More...
 
std::string mName
 class name More...
 
std::string mLib
 lib name More...
 
std::map< std::string, std::string > mMetaInfo
 meta info of class More...
 
bool mLibLoaded
 is associated lib loaded? More...
 

Friends

class ClassFactory
 
template<typename CLASS >
class TClass
 
class ClassProxy
 

Detailed Description

Class object which supports some kind of class reflection.

Furthermore, the class object acts like a class factory, which is responsible for all registered children of the class.

Constructor & Destructor Documentation

◆ ~Class()

virtual ~Class ( )
virtual

◆ Class() [1/2]

Class ( std::string const &  identifier,
std::string const &  name,
std::map< std::string, std::string > const &  metaInfo,
bool  libLoaded 
)
protected

This function is called: the constructor.

◆ Class() [2/2]

Class ( std::string const &  identifier,
std::string const &  name,
bool  libLoaded 
)
protected

This function is called: the constructor.

Member Function Documentation

◆ getIdentifier()

virtual std::string const& getIdentifier ( ) const
virtual

Return identifier for the class.

The identifiers probably contains the namespace of the class.

Reimplemented in NullClass, and TemplateClass< CLASS >.

◆ getName()

virtual std::string const& getName ( ) const
virtual

Return name of the class.

The name will not contain any informations about the class namespace (if the macro for automatic extraction of the name has been used). Otherwise the function simply returns the name given in the object macro.

Reimplemented in NullClass, and TemplateClass< CLASS >.

◆ getTypeId()

virtual int getTypeId ( ) const
pure virtual

Return unique id for the class.

Keep in mind that this id is only valid during execution time and only for this process.

Implemented in TClass< CLASS >, TClass< mira::Object >, NullClass, and VacantClass.

◆ getTypename()

virtual Typename getTypename ( ) const
pure virtual

Returns the platform independent C++ typename of the class.

Implemented in TClass< CLASS >, TClass< mira::Object >, NullClass, and VacantClass.

◆ getMetaInfo() [1/2]

std::map<std::string, std::string> const& getMetaInfo ( ) const

Return map with meta information.

meta information is coded as key-value pair.

◆ getMetaInfo() [2/2]

std::string const& getMetaInfo ( const std::string &  meta) const

Returns meta information for the given meta key.

This method is provided for convenience. If the specified meta information is not available an empty string is returned.

◆ newInstance() [1/6]

virtual Object* newInstance ( ) const
pure virtual

Return a new instance of the class associated with the class object.

The derived TClass and VacantClasses will return the derived class type using covariant return types.

Exceptions
XFactoryLogicalIf the class is abstract.
XFactoryLogicalIf the class has no default constructor

Implemented in TClass< CLASS >, TClass< mira::Object >, VacantClass, and NullClass.

◆ newInstance() [2/6]

CLASS * newInstance ( ) const
inline

Return a new instance of the class associated with the class object.

The class is casted to the desired class type.

Exceptions
XFactoryBadCastIf the cast fails
XFactoryLogicalIf the class is abstract.
XFactoryLogicalIf the class has no default constructor

◆ newInstance() [3/6]

virtual Object* newInstance ( int  paramCount,
  ... 
) const
pure virtual

Return a new instance of the class associated with the class object.

A list of parameters for the constructor can be passed. The derived TClass and VacantClasses will NOT return the derived class type since the combination of va_list and covariant return types seems to be unsupported...

Exceptions
XFactoryLogicalIf the class is abstract.
XFactoryLogicalIf the class has no constructor matching the given parameter list (or if the constructor is not registered)

Implemented in TClass< CLASS >, TClass< mira::Object >, VacantClass, and NullClass.

◆ newInstance() [4/6]

virtual Object* newInstance ( std::string const &  childIdentifier) const
pure virtual

Return a new instance of the child class with the given identifier.

The derived TClass and VacantClasses will return the derived class type using covariant return types.

Exceptions
XFactoryLogicalIf the class is abstract.
XFactoryLogicalIf the class has no default constructor

Implemented in TClass< CLASS >, TClass< mira::Object >, VacantClass, and NullClass.

◆ newInstance() [5/6]

CLASS * newInstance ( std::string const &  childIdentifier) const
inline

Return a new instance of the child class with the given identifier.

The class is casted to the desired class type.

Exceptions
XFactoryBadCastIf the cast fails
XFactoryLogicalIf the class is abstract.
XFactoryLogicalIf the class has no default constructor

◆ newInstance() [6/6]

virtual Object* newInstance ( std::string const &  childIdentifier,
int  paramCount,
  ... 
) const
pure virtual

Return a new instance of the child class with the given identifier.

A list of parameters for the constructor can be passed. The derived TClass and VacantClasses will NOT return the derived class type since the combination of va_list and covariant return types seems to be unsupported...

Exceptions
XFactoryLogicalIf the class is abstract.
XFactoryLogicalIf the class has no constructor matching the given parameter list (or if the constructor is not registered)

Implemented in TClass< CLASS >, TClass< mira::Object >, VacantClass, and NullClass.

◆ isClassRegistered()

bool isClassRegistered ( std::string const &  classIdentifier) const

Return true if a class with the desired identifier is registered.

◆ eraseChild()

void eraseChild ( Class const *const  iClass)

Remove the given child class from the class.

Calls eraseChild on all parents and removes the given class from its own child list.

◆ eraseParent()

void eraseParent ( Class const *const  iClass)

Remove the given class from the list of parents.

Calls eraseParent on all children and removes the given class from its own parent list.

◆ getClassByIdentifier()

ClassProxy getClassByIdentifier ( std::string const &  classIdentifier) const

Return the ClassProxy object for the desired Class.

Exceptions
XFactoryUnknownIf the identifier is unknown.

◆ getClassByMeta() [1/2]

std::vector<ClassProxy> getClassByMeta ( std::string const &  metaKey,
std::string const &  metaValue 
) const

Return vector of ClassProxy objects matching the meta criterion.

The returned classes matches the given metakey and metavalue.

◆ getClassByMeta() [2/2]

std::vector< ClassProxy > getClassByMeta ( funcPtr) const
inline

Return vector of Class objects returning true for the given comparison function.

The comparison function has to take the meta information std::map<std::string, std::string> const& as argument and should return true if the meta information matches the desired criterion.

◆ getDerivedClasses()

std::map<std::string, ClassProxy> getDerivedClasses ( ) const

Return registered children for the associated class to the given map.

◆ getDirectParents()

std::map<std::string, ClassProxy> getDirectParents ( ) const

Return map with the direct parents of this class.

◆ isBaseOf() [1/3]

bool isBaseOf ( Class const *const  derived) const

Return true if given class is registered and derived from this class.

◆ isBaseOf() [2/3]

bool isBaseOf ( ClassProxy  derived) const

Return true if given class is registered and derived from this class.

◆ isBaseOf() [3/3]

bool isBaseOf ( std::string const &  identifier) const

Return true if given class is registered and derived from this class.

◆ isDerivedFrom() [1/2]

bool isDerivedFrom ( Class const *const  base) const

Return true if given class is registered and parent of this class.

◆ isDerivedFrom() [2/2]

bool isDerivedFrom ( ClassProxy  base) const

Return true if given class is registered and parent of this class.

◆ isDirectlyDerivedFrom() [1/2]

bool isDirectlyDerivedFrom ( Class const *const  base) const

Return true if the given class is a direct parent.

◆ isDirectlyDerivedFrom() [2/2]

bool isDirectlyDerivedFrom ( ClassProxy  base) const

Return true if the given class is a direct parent.

◆ isDeclaredAbstract()

bool isDeclaredAbstract ( ) const

Return true if the associated class is declared to be abstract (comparison with isAbstract() allows to detect programming errors.)

◆ isAbstract()

virtual bool isAbstract ( ) const
pure virtual

Return true if the associated class is abstract.

Implemented in TClass< CLASS >, TClass< mira::Object >, VacantClass, and NullClass.

◆ isLibraryLoaded()

bool isLibraryLoaded ( ) const

Return true if the library which contains the associated class is loaded.

TClass classes will return true and VacantClass classes will return false.

◆ reflectRead() [1/2]

MIRA_SPLIT_REFLECT_MEMBER void reflectRead ( Reflector &  r)

Implementation of class member reflection.

Attention: the default implementation will reflect the abstract key in order to read the information from the object. However, the abstract key will be ignored when writing information to the object.

◆ reflectWrite()

void reflectWrite ( Reflector &  r)
inline

Implementation of class member reflection.

Attention: the default implementation will reflect the abstract key in order to read the information from the object. However, the abstract key will be ignored when writing information to the object.

◆ operator==()

bool operator== ( Class const &  other) const
inline

Returns true, if the two classes are identical.

◆ operator!=()

bool operator!= ( Class const &  other) const
inline

Returns true, if the two classes are not identical.

◆ operator<()

bool operator< ( Class const &  other) const
inline

Return true, if the comparison of the identifiers returns true.

◆ newVAInstance()

virtual Object* newVAInstance ( int  paramCount,
std::va_list   
) const
protectedpure virtual

Call the specific constructor depending on the number of parameters passed to the function.

Implemented in VacantClass, TClass< CLASS >, TClass< mira::Object >, and NullClass.

◆ reflectRead() [2/2]

void reflectRead ( Reflector &  r)
inline

Friends And Related Function Documentation

◆ ClassFactory

friend class ClassFactory
friend

◆ TClass

friend class TClass
friend

◆ ClassProxy

friend class ClassProxy
friend

Member Data Documentation

◆ mDerivedChildren

std::map<std::string, ClassProxy > mDerivedChildren
protected

map of children

◆ mDirectParents

std::map<std::string, ClassProxy> mDirectParents
protected

map of parents

◆ mIdentifier

std::string mIdentifier
protected

class identifier

◆ mName

std::string mName
protected

class name

◆ mLib

std::string mLib
protected

lib name

◆ mMetaInfo

std::map<std::string, std::string> mMetaInfo
protected

meta info of class

◆ mLibLoaded

bool mLibLoaded
protected

is associated lib loaded?


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