|
ContRap-Core
|
Object factory provides an interface for instantiating objects from a string holding the type. More...
#include <objectfactory.h>
Public Member Functions | |
| void | register_type (MetaInfo *meta_info) |
| Registers a new type. | |
| bool | unregister_type (MetaInfo *meta_info) |
| Unregisters a type. | |
| void | destroy (void *object, const std::string &type_name) |
| Destroys an instance of an object. | |
| bool | is_registered (const std::string &type_name) |
| Checks if the mangled type is registered. | |
| bool | is_type_name (const std::string &type_name) |
| Checks if a type is a registered type name. | |
| bool | is_object (const std::string &type_name) |
| Checks if the type is a native ContRap object. | |
| DPtr | cast (const DPtr &object, const std::string &type_name) |
| Casts an object to the given type if possible. | |
| const std::string & | get_type_id (const std::string &type_name) const |
| Returns the type identifier of a type. | |
| const std::string & | get_type_name (const std::string &type_name) const |
| Returns the real name of a mangled type. | |
| MetaInfo * | get_meta_info (const std::string &type_name) |
| Returns the types meta information. | |
| std::string | to_string () const |
| Returns the contents as a string. | |
Static Public Member Functions | |
| static ObjectFactory * | get_instance () |
| Returns the instance of the factory. | |
Protected Attributes | |
| std::map< std::string, MetaInfo > | meta_infos |
| Holds the type meta information. | |
| std::map< std::string, std::string > | real_to_mangled |
| Association between mangled and real type names. | |
Static Protected Attributes | |
| static ObjectFactory * | object_factory |
| Static variable holding the singleton instance. | |
Object factory provides an interface for instantiating objects from a string holding the type.
Casts an object to the given type if possible.
| object | Object to cast to |
| type_name | Type to cast to |
| Pointer | to the castet object |
| void crp::ObjectFactory::destroy | ( | void * | object, |
| const std::string & | type_name | ||
| ) |
Destroys an instance of an object.
| object | Void pointer to the object |
| type_name | Name of the type |
| static ObjectFactory* crp::ObjectFactory::get_instance | ( | ) | [static] |
Returns the instance of the factory.
| MetaInfo* crp::ObjectFactory::get_meta_info | ( | const std::string & | type_name | ) |
Returns the types meta information.
Notice: The type name must be given in exactly the same form as it was registered by the meta implementation macro.
| type_name | Real type name |
| const std::string& crp::ObjectFactory::get_type_id | ( | const std::string & | type_name | ) | const |
Returns the type identifier of a type.
The returned value is system dependend.
Notice: The type name must be given in exactly the same form as it was registered by the meta implementation macro.
| type_name | Name of a type |
| const std::string& crp::ObjectFactory::get_type_name | ( | const std::string & | type_name | ) | const |
Returns the real name of a mangled type.
This name is system dependent.
Notice: The type name must be given in exactly the same form as it was registered by the meta implementation macro.
| type_name | Name of a mangled type |
| bool crp::ObjectFactory::is_object | ( | const std::string & | type_name | ) |
Checks if the type is a native ContRap object.
| type_name | Name of the type |
| bool crp::ObjectFactory::is_registered | ( | const std::string & | type_name | ) |
Checks if the mangled type is registered.
The mangled type is system dependent and should not hard-coded as a string. Use the TYPE_NAME macro to get a type name on your system.
| type_name | Name of the type |
| bool crp::ObjectFactory::is_type_name | ( | const std::string & | type_name | ) |
Checks if a type is a registered type name.
The type name must exactly match the type name which was used in the CONTRAP_OBJECT macro at the registration time point.
| type_name | Name of the type |
| void crp::ObjectFactory::register_type | ( | MetaInfo * | meta_info | ) |
Registers a new type.
| meta_info | Meta info of the type |
| std::string crp::ObjectFactory::to_string | ( | ) | const |
Returns the contents as a string.
| bool crp::ObjectFactory::unregister_type | ( | MetaInfo * | meta_info | ) |
Unregisters a type.
| meta_info | Meta info of the type |
std::map<std::string, MetaInfo> crp::ObjectFactory::meta_infos [protected] |
Holds the type meta information.
ObjectFactory* crp::ObjectFactory::object_factory [static, protected] |
Static variable holding the singleton instance.
std::map<std::string, std::string> crp::ObjectFactory::real_to_mangled [protected] |
Association between mangled and real type names.
1.7.3