A map class which can create DrObjects from names.
More...
#include <drogon/DrClassMap.h>
|
| static void | registerClass (const std::string &className, const DrAllocFunc &func, const DrSharedAllocFunc &sharedFunc=nullptr) |
| | Register a class into the map.
|
| static DrObjectBase * | newObject (const std::string &className) |
| | Create a new instance of the class named by className.
|
|
static std::shared_ptr< DrObjectBase > | newSharedObject (const std::string &className) |
| | Get the shared_ptr instance of the class named by className.
|
| static const std::shared_ptr< DrObjectBase > & | getSingleInstance (const std::string &className) |
| | Get the singleton object of the class named by className.
|
| template<typename T> |
| static std::shared_ptr< T > | getSingleInstance () |
| | Get the singleton T type object.
|
| static void | setSingleInstance (const std::shared_ptr< DrObjectBase > &ins) |
| | Set a singleton object into the map.
|
| static std::vector< std::string > | getAllClassName () |
| | Get all names of classes registered in the map.
|
| static std::string | demangle (const char *mangled_name) |
| | demangle the type name which is returned by typeid(T).name().
|
|
|
static std::unordered_map< std::string, std::pair< DrAllocFunc, DrSharedAllocFunc > > & | getMap () |
A map class which can create DrObjects from names.
◆ demangle()
| std::string drogon::DrClassMap::demangle |
( |
const char * | mangled_name | ) |
|
|
inlinestatic |
demangle the type name which is returned by typeid(T).name().
- Parameters
-
| mangled_name | The type name which is returned by typeid(T).name(). |
- Returns
- std::string The human readable type name.
◆ getAllClassName()
| std::vector< std::string > drogon::DrClassMap::getAllClassName |
( |
| ) |
|
|
static |
Get all names of classes registered in the map.
- Returns
- std::vector<std::string> the vector of class names.
◆ getSingleInstance() [1/2]
template<typename T>
| std::shared_ptr< T > drogon::DrClassMap::getSingleInstance |
( |
| ) |
|
|
inlinestatic |
Get the singleton T type object.
- Template Parameters
-
- Returns
- std::shared_ptr<T> The smart pointer to the instance.
- Note
- The T must be a subclass of the DrObjectBase class.
◆ getSingleInstance() [2/2]
| const std::shared_ptr< DrObjectBase > & drogon::DrClassMap::getSingleInstance |
( |
const std::string & | className | ) |
|
|
static |
Get the singleton object of the class named by className.
- Parameters
-
| className | The name of the class |
- Returns
- const std::shared_ptr<DrObjectBase>& The smart pointer to the instance.
◆ newObject()
| DrObjectBase * drogon::DrClassMap::newObject |
( |
const std::string & | className | ) |
|
|
static |
Create a new instance of the class named by className.
- Parameters
-
| className | The name of the class |
- Returns
- DrObjectBase* The pointer to the newly created instance.
◆ registerClass()
| void drogon::DrClassMap::registerClass |
( |
const std::string & | className, |
|
|
const DrAllocFunc & | func, |
|
|
const DrSharedAllocFunc & | sharedFunc = nullptr ) |
|
static |
Register a class into the map.
- Parameters
-
| className | The name of the class |
| func | The function which can create a new instance of the class. |
◆ setSingleInstance()
| void drogon::DrClassMap::setSingleInstance |
( |
const std::shared_ptr< DrObjectBase > & | ins | ) |
|
|
static |
Set a singleton object into the map.
- Parameters
-
| ins | The smart pointer to the instance. |
The documentation for this class was generated from the following file: