Rebel Fork Framework
Urho3D::Context Class Reference

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:
Urho3D::RefCounted Urho3D::ObjectReflectionRegistry

Public Member Functions

 Context ()
 ~Context () override
 Destruct. More...
void RegisterSubsystem (Object *object, StringHash type)
 Register a subsystem by explicitly using a type. Type must belong to inheritance hierarchy.
void RegisterSubsystem (Object *object)
 Register a subsystem.
void RemoveSubsystem (StringHash objectType)
 Remove a subsystem.
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().
template<class T >
void RegisterFactory (ea::string_view category={})
 Deprecated. Use AddFactoryReflection, AddAbstractReflection or AddReflection instead.
template<class T , class U = T>
T * RegisterSubsystem ()
 Template version of registering subsystem.
template<class T >
void RemoveSubsystem ()
 Template version of removing a subsystem.
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 SubsystemCacheGetSubsystems () const
 Return all subsystems.
ObjectGetEventSender () const
 Return active event sender. Null outside event handling.
EventHandlerGetEventHandler () const
 Return active event handler. Set by Object. Null outside event handling.
const ea::string & GetTypeName (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 ea::vector< AttributeInfo > * GetAttributes (StringHash type) const
 Return attribute descriptions for an object type, or null if none defined.
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.
 RefCounted (const RefCounted &rhs)=delete
 Prevent copy construction.
RefCountedoperator= (const RefCounted &rhs)=delete
 Prevent assignment.
int AddRef ()
int ReleaseRef ()
int Refs () const
int WeakRefs () const
RefCountRefCountPtr () const
 Return pointer to the reference count structure.
bool HasScriptObject () const
 Return true if script runtime object wrapping this native object exists.
bool IsScriptStrongRef () const
 Return true if script reference is strong.
- Public Member Functions inherited from Urho3D::ObjectReflectionRegistry
 ObjectReflectionRegistry (Context *context)
ObjectReflectionReflect (const TypeInfo *typeInfo)
 Return existing or new reflection for given type.
ObjectReflectionReflectCustomType (ea::unique_ptr< TypeInfo > typeInfo)
template<class T >
ObjectReflectionReflect ()
template<class T >
ObjectReflectionAddReflection (ea::string_view category="")
 Add new object reflection with or without object creation factory and assign it to the category.
template<class T >
ObjectReflectionAddFactoryReflection (ea::string_view category="")
template<class T >
ObjectReflectionAddAbstractReflection (ea::string_view category="")
ObjectReflectionGetReflection (StringHash typeNameHash)
 Return existing reflection for given type.
const ObjectReflectionGetReflection (StringHash typeNameHash) const
bool IsReflected (StringHash typeNameHash) const
template<class T >
ObjectReflectionGetReflection ()
template<class T >
const ObjectReflectionGetReflection () const
template<class T >
bool IsReflected () const
void SetReflectionCategory (const TypeInfo *typeInfo, ea::string_view category)
 Assign object reflection to the category.
template<class T >
void SetReflectionCategory (ea::string_view category)
void RemoveReflection (StringHash typeNameHash)
 Remove reflection.
template<class T >
void RemoveReflection ()
SharedPtr< ObjectCreateObject (StringHash typeNameHash)
 Create an object by type. Return pointer to it or null if no reflection is found.
const ea::unordered_map< StringHash, SharedPtr< ObjectReflection > > & GetObjectReflections () const
 Return reflections of all objects.
const ea::unordered_map< ea::string, ea::vector< StringHash > > & GetObjectCategories () const
 Return categories of reflected objects.
template<class T >
void RemoveAttribute (StringHash nameHash)
template<class T >
void UpdateAttributeDefaultValue (StringHash nameHash, const Variant &defaultValue)

Static Public Member Functions

static ContextGetInstance ()
 Return global instance of context object. Only one context may exist within application.

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

SubsystemCache subsystems_
ea::unordered_map< StringHash, SharedPtr< EventReceiverGroup > > eventReceivers_
 Event receivers for non-specific events.
ea::unordered_map< Object *, ea::unordered_map< StringHash, SharedPtr< EventReceiverGroup > > > specificEventReceivers_
 Event receivers for specific senders' events.
ea::vector< Object * > eventSenders_
 Event sender stack.
ea::vector< VariantMap * > eventDataMaps_
 Event data stack.
 Active event handler. Not stored in a stack for performance reasons; is needed only in esoteric cases.
VariantMap globalVars_
 Variant map for global variables that can persist throughout application execution.


class Object

Additional Inherited Members

- Public Attributes inherited from Urho3D::ObjectReflectionRegistry
Signal< void(ObjectReflection *), ObjectReflectionRegistryOnReflectionRemoved

Detailed Description

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

Constructor & Destructor Documentation

◆ ~Context()

Urho3D::Context::~Context ( )


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