Lightmetrica  0.0.1.50dbee3 (yosakoi)
 All Classes Functions Variables Typedefs Enumerations Enumerator
Public Types | Static Public Member Functions | List of all members
ComponentFactory Class Reference

#include <component.h>

Public Types

typedef std::function
< Component *()> 
CreateComponentFunc
 

Static Public Member Functions

static bool CheckRegistered (const std::string &interfaceType, const std::string &implType)
 
static bool Register (const std::string &interfaceType, const std::string &implType, const CreateComponentFunc &func)
 
static ComponentCreate (const std::string &interfaceType, const std::string &implType)
 
static void LoadPlugins (const std::string &pluginDir)
 
static void UnloadPlugins ()
 
template<typename InterfaceType >
static bool CheckRegistered (const std::string &implType)
 
template<typename InterfaceType >
static InterfaceType * Create (const std::string &implType)
 
template<typename InterfaceType >
static InterfaceType * Create ()
 

Detailed Description

Component factory. Factory class for components. All components are managed by the factory.

Member Function Documentation

bool ComponentFactory::CheckRegistered ( const std::string &  interfaceType,
const std::string &  implType 
)
static

Check if the component is registered.

Parameters
interfaceTypeComponent interface type.
implTypeComponent implementation type.
Return values
trueComponent of the given type is registered.
falseComponent of the given type is not registered.
template<typename InterfaceType >
static bool ComponentFactory::CheckRegistered ( const std::string &  implType)
inlinestatic

Check if the component is registered.

Template Parameters
InterfaceTypeInterface type.
Parameters
interfaceTypeComponent interface type.
implTypeComponent implementation type.
Return values
trueComponent of the given type is registered.
falseComponent of the given type is not registered.
Component * ComponentFactory::Create ( const std::string &  interfaceType,
const std::string &  implType 
)
static

Create an instance of a component.

Parameters
interfaceTypeComponent interface type.
implTypeComponent implementation type.
Returns
Instance. nullptr if not registered.
template<typename InterfaceType >
static InterfaceType* ComponentFactory::Create ( const std::string &  implType)
inlinestatic

Create an instance of a component with interface type. Creates an instance of a component with the type of the given interface.

Template Parameters
InterfaceTypeInterface type.
Parameters
implTypeComponent implementation type.
Returns
Instance. nullptr if not registered, or failed to cast.
template<typename InterfaceType >
static InterfaceType* ComponentFactory::Create ( )
inlinestatic

Create an instance of a component with interface type. This function creates default implementation for the givan interface.

Template Parameters
InterfaceTypeInterface type.
Returns
Instance. nullptr if not registered, or failed to cast.
void ComponentFactory::LoadPlugins ( const std::string &  pluginDir)
static

Load plugins. This function must be called once in the initialization phase.

Parameters
pluginDirPlugin directory.
bool ComponentFactory::Register ( const std::string &  interfaceType,
const std::string &  implType,
const CreateComponentFunc &  func 
)
static

Register a component. Registers a component to the factory. Registered components can be instantiated with Create function.

Parameters
interfaceTypeComponent interface type.
implTypeComponent implementation type.
funcInstance creation function.
Return values
trueSuccessfully registered.
falseFailed to register a component.
void ComponentFactory::UnloadPlugins ( )
static

Unload plugins. Unloads loaded plugins.


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