Atoms Crowd  4.1.0
Atoms::BehaviourFactory Class Reference

Behaviour factory. More...

#include <BehaviourFactory.h>

Public Types

enum  ModuleType { kNone = -1, kNative = 0, kScript = 1 }
 
typedef Behaviour *(* creatorFn) ()
 

Public Member Functions

BehaviourcreateBehaviour (const std::string &name)
 Creates a behaviour. More...
 
bool registerBehaviour (const std::string &moduleName, creatorFn func, unsigned int moduleType=kNative, bool replace=false, const std::string category="")
 Registers a behaviour in the factory. More...
 
bool deregisterBehaviour (const std::string &name)
 Deregisters a Behaviour type from the factory. More...
 
std::vector< std::string > getRegisteredBehaviours ()
 Gets all registered behaviour modules. More...
 
const std::string getBehaviourCategory (const std::string &moduleName)
 Gets a registered behaviour category. More...
 
bool isRegistered (const std::string &name)
 Check if a behaviour is registered. More...
 
void clear ()
 Clear factory.
 
short moduleType (const std::string &name)
 Gets the module type.
 

Static Public Member Functions

static BehaviourFactoryinstance ()
 Singleton access.
 

Detailed Description

Behaviour factory.

Factory used to create Behaviours.

Member Function Documentation

◆ createBehaviour()

Behaviour* Atoms::BehaviourFactory::createBehaviour ( const std::string &  name)

Creates a behaviour.

Parameters
namebehaviour type name
Returns
Pinter to the behaviour created

◆ deregisterBehaviour()

bool Atoms::BehaviourFactory::deregisterBehaviour ( const std::string &  name)

Deregisters a Behaviour type from the factory.

Parameters
nameBehaviour name
Returns
True if the Behaviour is removed from the map

◆ getBehaviourCategory()

const std::string Atoms::BehaviourFactory::getBehaviourCategory ( const std::string &  moduleName)

Gets a registered behaviour category.

Returns
String representing the behaviour category, the string will be empty if this module has no category

◆ getRegisteredBehaviours()

std::vector<std::string> Atoms::BehaviourFactory::getRegisteredBehaviours ( )

Gets all registered behaviour modules.

Returns
List of all behaviour registered

◆ isRegistered()

bool Atoms::BehaviourFactory::isRegistered ( const std::string &  name)

Check if a behaviour is registered.

Parameters
nameBehaviour module name
Returns
Return true if the behaviour module is already registered

◆ registerBehaviour()

bool Atoms::BehaviourFactory::registerBehaviour ( const std::string &  moduleName,
creatorFn  func,
unsigned int  moduleType = kNative,
bool  replace = false,
const std::string  category = "" 
)

Registers a behaviour in the factory.

Parameters
nameBehavioir name
funccreator function
replaceReplace if it already exists
Returns
True if the behaviour is added to the map

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