Urho3D
|
Urho3D execution context. Provides access to subsystems, object factories and attributes, and event receivers. More...
#include <Context.h>
Public Member Functions | |
Context () | |
Construct. | |
~Context () | |
Destruct. | |
SharedPtr< Object > | CreateObject (ShortStringHash 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 | RegisterSubsystem (Object *subsystem) |
Register a subsystem. | |
void | RemoveSubsystem (ShortStringHash objectType) |
Remove a subsystem. | |
void | RegisterAttribute (ShortStringHash objectType, const AttributeInfo &attr) |
Register object attribute. | |
void | RemoveAttribute (ShortStringHash objectType, const char *name) |
Remove object attribute. | |
void | CopyBaseAttributes (ShortStringHash baseType, ShortStringHash derivedType) |
Copy base class attributes to derived class. | |
template<class T > | |
void | RegisterFactory () |
Template version of registering an object factory. | |
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. | |
Object * | GetSubsystem (ShortStringHash type) const |
Return subsystem by type. | |
const HashMap< ShortStringHash, SharedPtr< Object > > & | GetSubsystems () const |
Return all subsystems. | |
const HashMap< ShortStringHash, SharedPtr< ObjectFactory > > & | GetObjectFactories () const |
Return all object factories. | |
Object * | GetEventSender () const |
Return active event sender. Null outside event handling. | |
EventHandler * | GetEventHandler () const |
Return active event handler. Set by Object. Null outside event handling. | |
const String & | GetTypeName (ShortStringHash type) const |
Return object type name from hash, or empty if unknown. | |
template<class T > | |
T * | GetSubsystem () const |
Template version of returning a subsystem. | |
const Vector< AttributeInfo > * | GetAttributes (ShortStringHash type) const |
Return attribute descriptions for an object type, or null if none defined. | |
const Vector< AttributeInfo > * | GetNetworkAttributes (ShortStringHash type) const |
Return network replication attribute descriptions for an object type, or null if none defined. | |
HashSet< Object * > * | GetEventReceivers (Object *sender, StringHash eventType) |
Return event receivers for a sender and event type, or null if they do not exist. | |
HashSet< Object * > * | GetEventReceivers (StringHash eventType) |
Return event receivers for an event type, or null if they do not exist. | |
![]() | |
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. | |
RefCount * | RefCountPtr () |
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 | SetEventHandler (EventHandler *handler) |
Set current event handler. Called by Object. | |
void | BeginSendEvent (Object *sender) |
Begin event send. | |
void | EndSendEvent () |
End event send. Clean up event receivers removed in the meanwhile. |
Private Attributes | |
HashMap< ShortStringHash, SharedPtr< ObjectFactory > > | factories_ |
Object factories. | |
HashMap< ShortStringHash, SharedPtr< Object > > | subsystems_ |
Subsystems. | |
HashMap< ShortStringHash, Vector< AttributeInfo > > | attributes_ |
Attribute descriptions per object type. | |
HashMap< ShortStringHash, Vector< AttributeInfo > > | networkAttributes_ |
Network replication attribute descriptions per object type. | |
HashMap< StringHash, HashSet < Object * > > | eventReceivers_ |
Event receivers for non-specific events. | |
HashMap< Object *, HashMap < StringHash, HashSet< Object * > > > | specificEventReceivers_ |
Event receivers for specific senders' events. | |
PODVector< Object * > | eventSenders_ |
Event sender stack. | |
EventHandler * | eventHandler_ |
Active event handler. Not stored in a stack for performance reasons; is needed only in esoteric cases. |
Friends | |
class | Object |
Urho3D execution context. Provides access to subsystems, object factories and attributes, and event receivers.