Urho3D execution context. Provides access to subsystems, object factories and attributes, and event receivers. More...

#include <Urho3D/Core/Context.h>

Inheritance diagram for Urho3D::Context:
[legend]
Collaboration diagram for Urho3D::Context:
[legend]

Public Member Functions

 Context ()
 Construct.
 
 ~Context ()
 Destruct. More...
 
template<class T >
SharedPtr< T > CreateObject ()
 Create an object by type. Return pointer to it or null if no factory found.
 
SharedPtr< ObjectCreateObject (StringHash objectType)
 Create an object by type hash. Return pointer to it or null if no factory found.
 
void RegisterFactory (ObjectFactory *factory)
 Register a factory for an object type.
 
void RegisterFactory (ObjectFactory *factory, const char *category)
 Register a factory for an object type and specify the object category.
 
void RegisterSubsystem (Object *subsystem)
 Register a subsystem.
 
void RemoveSubsystem (StringHash objectType)
 Remove a subsystem.
 
void RegisterAttribute (StringHash objectType, const AttributeInfo &attr)
 Register object attribute.
 
void RemoveAttribute (StringHash objectType, const char *name)
 Remove object attribute.
 
void UpdateAttributeDefaultValue (StringHash objectType, const char *name, const Variant &defaultValue)
 Update object attribute's default value.
 
VariantMapGetEventDataMap ()
 Return a preallocated map for event data. Used for optimization to avoid constant re-allocation of event data maps.
 
bool RequireSDL (unsigned int sdlFlags)
 Initialises the specified SDL systems, if not already. Returns true if successful. This call must be matched with ReleaseSDL() when SDL functions are no longer required, even if this call fails.
 
void ReleaseSDL ()
 Indicate that you are done with using SDL. Must be called after using RequireSDL().
 
void CopyBaseAttributes (StringHash baseType, StringHash derivedType)
 Copy base class attributes to derived class.
 
template<class T >
void RegisterFactory ()
 Template version of registering an object factory.
 
template<class T >
void RegisterFactory (const char *category)
 Template version of registering an object factory with category.
 
template<class T >
void RemoveSubsystem ()
 Template version of removing a subsystem.
 
template<class T >
void RegisterAttribute (const AttributeInfo &attr)
 Template version of registering an object attribute.
 
template<class T >
void RemoveAttribute (const char *name)
 Template version of removing an object attribute.
 
template<class T , class U >
void CopyBaseAttributes ()
 Template version of copying base class attributes to derived class.
 
template<class T >
void UpdateAttributeDefaultValue (const char *name, const Variant &defaultValue)
 Template version of updating an object attribute's default value.
 
ObjectGetSubsystem (StringHash type) const
 Return subsystem by type.
 
const VariantGetGlobalVar (StringHash key) const
 Return global variable based on key.
 
const VariantMapGetGlobalVars () const
 Return all global variables.
 
void SetGlobalVar (StringHash key, const Variant &value)
 Set global variable with the respective key and value.
 
const HashMap< StringHash,
SharedPtr< Object > > & 
GetSubsystems () const
 Return all subsystems.
 
const HashMap< StringHash,
SharedPtr< ObjectFactory > > & 
GetObjectFactories () const
 Return all object factories.
 
const HashMap< String, Vector
< StringHash > > & 
GetObjectCategories () const
 Return all object categories.
 
ObjectGetEventSender () const
 Return active event sender. Null outside event handling.
 
EventHandlerGetEventHandler () const
 Return active event handler. Set by Object. Null outside event handling.
 
const StringGetTypeName (StringHash objectType) const
 Return object type name from hash, or empty if unknown.
 
AttributeInfoGetAttribute (StringHash objectType, const char *name)
 Return a specific attribute description for an object, or null if not found.
 
template<class T >
T * GetSubsystem () const
 Template version of returning a subsystem.
 
template<class T >
AttributeInfoGetAttribute (const char *name)
 Template version of returning a specific attribute description.
 
const Vector< AttributeInfo > * GetAttributes (StringHash type) const
 Return attribute descriptions for an object type, or null if none defined.
 
const Vector< AttributeInfo > * GetNetworkAttributes (StringHash type) const
 Return network replication attribute descriptions for an object type, or null if none defined.
 
const HashMap< StringHash,
Vector< AttributeInfo > > & 
GetAllAttributes () const
 Return all registered attributes.
 
EventReceiverGroupGetEventReceivers (Object *sender, StringHash eventType)
 Return event receivers for a sender and event type, or null if they do not exist.
 
EventReceiverGroupGetEventReceivers (StringHash eventType)
 Return event receivers for an event type, or null if they do not exist.
 
- Public Member Functions inherited from Urho3D::RefCounted
 RefCounted ()
 Construct. Allocate the reference count structure and set an initial self weak reference.
 
virtual ~RefCounted ()
 Destruct. Mark as expired and also delete the reference count structure if no outside weak references exist.
 
void AddRef ()
 Increment reference count. Can also be called outside of a SharedPtr for traditional reference counting.
 
void ReleaseRef ()
 Decrement reference count and delete self if no more references. Can also be called outside of a SharedPtr for traditional reference counting.
 
int Refs () const
 Return reference count.
 
int WeakRefs () const
 Return weak reference count.
 
RefCountRefCountPtr ()
 Return pointer to the reference count structure.
 

Private Member Functions

void AddEventReceiver (Object *receiver, StringHash eventType)
 Add event receiver.
 
void AddEventReceiver (Object *receiver, Object *sender, StringHash eventType)
 Add event receiver for specific event.
 
void RemoveEventSender (Object *sender)
 Remove an event sender from all receivers. Called on its destruction.
 
void RemoveEventReceiver (Object *receiver, Object *sender, StringHash eventType)
 Remove event receiver from specific events.
 
void RemoveEventReceiver (Object *receiver, StringHash eventType)
 Remove event receiver from non-specific events.
 
void BeginSendEvent (Object *sender, StringHash eventType)
 Begin event send.
 
void EndSendEvent ()
 End event send. Clean up event receivers removed in the meanwhile.
 
void SetEventHandler (EventHandler *handler)
 Set current event handler. Called by Object.
 

Private Attributes

HashMap< StringHash, SharedPtr
< ObjectFactory > > 
factories_
 Object factories.
 
HashMap< StringHash, SharedPtr
< Object > > 
subsystems_
 Subsystems.
 
HashMap< StringHash, Vector
< AttributeInfo > > 
attributes_
 Attribute descriptions per object type.
 
HashMap< StringHash, Vector
< AttributeInfo > > 
networkAttributes_
 Network replication attribute descriptions per object type.
 
HashMap< StringHash, SharedPtr
< EventReceiverGroup > > 
eventReceivers_
 Event receivers for non-specific events.
 
HashMap< Object *, HashMap
< StringHash, SharedPtr
< EventReceiverGroup > > > 
specificEventReceivers_
 Event receivers for specific senders' events.
 
PODVector< Object * > eventSenders_
 Event sender stack.
 
PODVector< VariantMap * > eventDataMaps_
 Event data stack.
 
EventHandlereventHandler_
 Active event handler. Not stored in a stack for performance reasons; is needed only in esoteric cases.
 
HashMap< String, Vector
< StringHash > > 
objectCategories_
 Object categories.
 
VariantMap globalVars_
 Variant map for global variables that can persist throughout application execution.
 

Friends

class Object
 

Detailed Description

Urho3D execution context. Provides access to subsystems, object factories and attributes, and event receivers.

Constructor & Destructor Documentation

Urho3D::Context::~Context ( )

Destruct.

Todo:
Context should not need to know about subsystems

Here is the call graph for this function:


The documentation for this class was generated from the following files:
  • Source/Urho3D/Core/Context.h
  • Source/Urho3D/Core/Context.cpp