Kigs Framework  Doc version 0.8
Open source multi purpose Rapid Application Development framework
Classes | Public Member Functions | Protected Attributes | List of all members
InstanceFactory Class Reference

#include <InstanceFactory.h>

Classes

class  ModuleAssociation
 Utility class to store "createInstance" method for each class of a module. More...
 

Public Member Functions

 InstanceFactory (KigsCore *core)
 constructor More...
 
CoreModifiableGetInstance (const std::string &instancename, const KigsID &classname, std::vector< CoreModifiableAttribute * > *args=nullptr)
 create an instance with the given name of the given class type More...
 
void RegisterClass (createMethod method, const KigsID &className, const std::string &moduleName)
 register a new class in the instance factory More...
 
bool GetModuleIDFromClassName (const KigsID &className, KigsID &ModuleID)
 create an instance of the given class type with the given instance name
More...
 
const kigs::unordered_map< KigsID, ModuleAssociation > & GetModuleList ()
 get the registered module list
 

Protected Attributes

KigsCoremCore
 pointer on core module singleton
 
kigs::unordered_map< KigsID, ModuleAssociationmModuleList
 map of registered modules
 

Detailed Description

register and instanciate classes

Constructor & Destructor Documentation

◆ InstanceFactory()

InstanceFactory::InstanceFactory ( KigsCore core)

constructor

Parameters
core: instance of Core

Member Function Documentation

◆ GetInstance()

CoreModifiable * InstanceFactory::GetInstance ( const std::string &  instancename,
const KigsID &  classname,
std::vector< CoreModifiableAttribute * > *  args = nullptr 
)

create an instance with the given name of the given class type

create an instance of the given class type with the given instance name

Parameters
instancename: name of the new instance
classname: class of the new instance
Returns
the instance of 'classname' named 'instancename', or a DoNothingObject if failed

for each module try to find the class type

if class type is found then return a new instance

no corresponding class was found, return 0

◆ GetModuleIDFromClassName()

bool InstanceFactory::GetModuleIDFromClassName ( const KigsID &  className,
KigsID &  ModuleID 
)

create an instance of the given class type with the given instance name

for each module try to find the class type

no corresponding class was found, return false and empty string

◆ RegisterClass()

void InstanceFactory::RegisterClass ( createMethod  method,
const KigsID &  className,
const std::string &  moduleName 
)

register a new class in the instance factory

register a new class to instance factory

Parameters
method: create method of the class
className: class to register
moduleName: name of the module which contain the class

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