Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Private Member Functions | Static Private Member Functions | List of all members
ObjectFactory Class Reference

#include <ObjectFactory.h>

+ Inheritance diagram for ObjectFactory:
+ Collaboration diagram for ObjectFactory:

Public Types

using CreatorFunction = std::function< Object *()>
 

Public Member Functions

 ObjectFactory ()
 
virtual ~ObjectFactory ()
 
virtual ObjectType GetObjectType () const
 
bool Register (const std::string &className, CreatorFunction creator)
 Enregistre une fonction de cr�ation pour un nom de classe donn�.
 
bool IsRegistered (const std::string &className) const
 
ObjectCreateObject (const std::string &className)
 Cr�e une nouvelle instance de l'objet sp�cifi� par son nom de classe.
 
ObjectComponentAddComponent (const std::string &className, Object *owner)
 
virtual void OnEvent (const Message &msg) override
 
- Public Member Functions inherited from Object
 Object ()
 
virtual ~Object ()
 
virtual void Process ()
 
virtual void Render ()
 
uint64_t GetUID () const
 

Static Public Member Functions

static ObjectFactoryGetInstance ()
 
static ObjectFactoryGet ()
 

Public Attributes

std::map< std::string, CreatorFunctionm_registeredCreators
 
- Public Attributes inherited from Object
std::string name = "unnamed_object"
 

Private Member Functions

ObjectFindObjectByUID (uint64_t uid)
 

Static Private Member Functions

static std::vector< Object * > & GetWorldObjectList ()
 

Additional Inherited Members

- Protected Attributes inherited from Object
uint64_t uid = 0
 

Detailed Description

Definition at line 25 of file ObjectFactory.h.

Member Typedef Documentation

◆ CreatorFunction

Definition at line 28 of file ObjectFactory.h.

Constructor & Destructor Documentation

◆ ObjectFactory()

ObjectFactory::ObjectFactory ( )
inline

◆ ~ObjectFactory()

virtual ObjectFactory::~ObjectFactory ( )
inlinevirtual

Member Function Documentation

◆ AddComponent()

ObjectComponent * ObjectFactory::AddComponent ( const std::string &  className,
Object owner 
)
inline

Definition at line 108 of file ObjectFactory.h.

References World::Get(), GetComponentTypeID_Static(), m_registeredCreators, ObjectComponent::SetOwner(), and SYSTEM_LOG.

Referenced by Npc::Create(), and Player::Create().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CreateObject()

Object * ObjectFactory::CreateObject ( const std::string &  className)
inline

Cr�e une nouvelle instance de l'objet sp�cifi� par son nom de classe.

Parameters
classNameLe nom de la classe � cr�er.
Returns
Un pointeur vers le nouvel objet BaseObject, ou nullptr si non trouv�.

Definition at line 95 of file ObjectFactory.h.

References World::Get(), GetComponentTypeID_Static(), m_registeredCreators, and SYSTEM_LOG.

+ Here is the call graph for this function:

◆ FindObjectByUID()

Object * ObjectFactory::FindObjectByUID ( uint64_t  uid)
inlineprivate

Definition at line 202 of file ObjectFactory.h.

References GetComponentTypeID_Static(), GetWorldObjectList(), and Object::uid.

+ Here is the call graph for this function:

◆ Get()

static ObjectFactory & ObjectFactory::Get ( )
inlinestatic

Definition at line 58 of file ObjectFactory.h.

References GetInstance().

Referenced by Npc::Create(), and Player::Create().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetInstance()

static ObjectFactory & ObjectFactory::GetInstance ( )
inlinestatic

Definition at line 53 of file ObjectFactory.h.

References GetComponentTypeID_Static().

Referenced by AutoRegister< T >::AutoRegister(), and Get().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetObjectType()

virtual ObjectType ObjectFactory::GetObjectType ( ) const
inlinevirtual

Definition at line 50 of file ObjectFactory.h.

References Singleton.

◆ GetWorldObjectList()

static std::vector< Object * > & ObjectFactory::GetWorldObjectList ( )
inlinestaticprivate

Definition at line 211 of file ObjectFactory.h.

References World::Get().

Referenced by FindObjectByUID(), and OnEvent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IsRegistered()

bool ObjectFactory::IsRegistered ( const std::string &  className) const
inline

Definition at line 85 of file ObjectFactory.h.

References GetComponentTypeID_Static(), and m_registeredCreators.

+ Here is the call graph for this function:

◆ OnEvent()

virtual void ObjectFactory::OnEvent ( const Message msg)
inlineoverridevirtual

◆ Register()

bool ObjectFactory::Register ( const std::string &  className,
CreatorFunction  creator 
)
inline

Enregistre une fonction de cr�ation pour un nom de classe donn�.

Parameters
classNameLe nom de la classe (cl�).
creatorLa fonction de cr�ation (std::function retournant BaseObject*).
Returns
true si l'enregistrement a r�ussi, false sinon (d�j� enregistr�).

Definition at line 66 of file ObjectFactory.h.

References GetComponentTypeID_Static(), m_registeredCreators, and SYSTEM_LOG.

Referenced by AutoRegister< T >::AutoRegister().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_registeredCreators

std::map<std::string, CreatorFunction> ObjectFactory::m_registeredCreators

Definition at line 29 of file ObjectFactory.h.

Referenced by AddComponent(), CreateObject(), IsRegistered(), and Register().


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