Urho3D
Public Member Functions | Static Public Member Functions | Protected Attributes | Private Member Functions | Private Attributes | Friends | List of all members
Dviglo::Object Class Referenceabstract

#include </home/runner/work/Dviglo/Dviglo/DvigloRepository/Source/Urho3D/Core/Object.h>

Inheritance diagram for Dviglo::Object:
Dviglo::RefCounted Dviglo::Application Dviglo::Audio Dviglo::Connection Dviglo::Console Dviglo::ConstantBuffer Dviglo::Database Dviglo::DbConnection Dviglo::DebugHud Dviglo::Engine Dviglo::File Dviglo::FileSelector Dviglo::FileSystem Dviglo::FileWatcher Dviglo::Geometry Dviglo::Graphics Dviglo::IndexBuffer Dviglo::Input Dviglo::Localization Dviglo::Log Dviglo::MessageBox Dviglo::NamedPipe Dviglo::Network Dviglo::OcclusionBuffer Dviglo::PackageFile Dviglo::Profiler Dviglo::Renderer Dviglo::Resource Dviglo::ResourceCache Dviglo::ResourceRouter Dviglo::Serializable Dviglo::ShaderPrecache Dviglo::Time Dviglo::UI Dviglo::VertexBuffer Dviglo::View Dviglo::Viewport Dviglo::WorkQueue

Public Member Functions

 Object (Context *context)
 Construct.
 
 ~Object () override
 Destruct. Clean up self from event sender & receiver structures.
 
virtual StringHash GetType () const =0
 
virtual const StringGetTypeName () const =0
 
virtual const TypeInfoGetTypeInfo () const =0
 Return type info.
 
virtual void OnEvent (Object *sender, StringHash eventType, VariantMap &eventData)
 Handle event.
 
bool IsInstanceOf (StringHash type) const
 Check current instance is type of specified type.
 
bool IsInstanceOf (const TypeInfo *typeInfo) const
 Check current instance is type of specified type.
 
template<typename T >
bool IsInstanceOf () const
 Check current instance is type of specified class.
 
template<typename T >
T * Cast ()
 Cast the object to specified most derived class.
 
template<typename T >
const T * Cast () const
 Cast the object to specified most derived class.
 
void SubscribeToEvent (StringHash eventType, EventHandler *handler)
 Subscribe to an event that can be sent by any sender.
 
void SubscribeToEvent (Object *sender, StringHash eventType, EventHandler *handler)
 Subscribe to a specific sender's event.
 
void SubscribeToEvent (StringHash eventType, const std::function< void(StringHash, VariantMap &)> &function, void *userData=nullptr)
 Subscribe to an event that can be sent by any sender.
 
void SubscribeToEvent (Object *sender, StringHash eventType, const std::function< void(StringHash, VariantMap &)> &function, void *userData=nullptr)
 Subscribe to a specific sender's event.
 
void UnsubscribeFromEvent (StringHash eventType)
 Unsubscribe from an event.
 
void UnsubscribeFromEvent (Object *sender, StringHash eventType)
 Unsubscribe from a specific sender's event.
 
void UnsubscribeFromEvents (Object *sender)
 Unsubscribe from a specific sender's events.
 
void UnsubscribeFromAllEvents ()
 Unsubscribe from all events.
 
void UnsubscribeFromAllEventsExcept (const PODVector< StringHash > &exceptions, bool onlyUserData)
 Unsubscribe from all events except those listed, and optionally only those with userdata (script registered events).
 
void SendEvent (StringHash eventType)
 Send event to all subscribers.
 
void SendEvent (StringHash eventType, VariantMap &eventData)
 Send event with parameters to all subscribers.
 
VariantMapGetEventDataMap () const
 Return a preallocated map for event data. Used for optimization to avoid constant re-allocation of event data maps.
 
template<typename... Args>
void SendEvent (StringHash eventType, Args... args)
 Send event with variadic parameter pairs to all subscribers. The parameter pairs is a list of paramID and paramValue separated by comma, one pair after another.
 
ContextGetContext () const
 Return execution context.
 
const VariantGetGlobalVar (StringHash key) const
 
const VariantMapGetGlobalVars () const
 
void SetGlobalVar (StringHash key, const Variant &value)
 
ObjectGetSubsystem (StringHash type) const
 Return subsystem by type.
 
ObjectGetEventSender () const
 Return active event sender. Null outside event handling.
 
EventHandlerGetEventHandler () const
 Return active event handler. Null outside event handling.
 
bool HasSubscribedToEvent (StringHash eventType) const
 Return whether has subscribed to an event without specific sender.
 
bool HasSubscribedToEvent (Object *sender, StringHash eventType) const
 Return whether has subscribed to a specific sender's event.
 
bool HasEventHandlers () const
 Return whether has subscribed to any event.
 
template<class T >
T * GetSubsystem () const
 Template version of returning a subsystem.
 
const StringGetCategory () const
 
void SetBlockEvents (bool block)
 Block object from sending and receiving events.
 
bool GetBlockEvents () const
 Return sending and receiving events blocking status.
 
- Public Member Functions inherited from Dviglo::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.
 
void AddRef ()
 
void ReleaseRef ()
 
int Refs () const
 
int WeakRefs () const
 
RefCountRefCountPtr ()
 Return pointer to the reference count structure.
 

Static Public Member Functions

static const TypeInfoGetTypeInfoStatic ()
 Return type info static.
 

Protected Attributes

Contextcontext_
 Execution context.
 

Private Member Functions

EventHandlerFindEventHandler (StringHash eventType, EventHandler **previous=nullptr) const
 Find the first event handler with no specific sender.
 
EventHandlerFindSpecificEventHandler (Object *sender, EventHandler **previous=nullptr) const
 Find the first event handler with specific sender.
 
EventHandlerFindSpecificEventHandler (Object *sender, StringHash eventType, EventHandler **previous=nullptr) const
 Find the first event handler with specific sender and event type.
 
void RemoveEventSender (Object *sender)
 Remove event handlers related to a specific sender.
 

Private Attributes

LinkedList< EventHandlereventHandlers_
 Event handlers. Sender is null for non-specific handlers.
 
bool blockEvents_
 Block object from sending and receiving any events.
 

Friends

class Context
 

Detailed Description

Base class for objects with type identification, subsystem access and event sending/receiving capability.

Member Function Documentation

◆ GetCategory()

const String & Dviglo::Object::GetCategory ( ) const

Return object category. Categories are (optionally) registered along with the object factory. Return an empty string if the object category is not registered.

◆ GetGlobalVar()

const Variant & Dviglo::Object::GetGlobalVar ( StringHash  key) const

Return global variable based on key.

◆ GetGlobalVars()

const VariantMap & Dviglo::Object::GetGlobalVars ( ) const

Return all global variables.

◆ GetType()

virtual StringHash Dviglo::Object::GetType ( ) const
pure virtual

Return type hash.

Implemented in Dviglo::UnknownComponent.

◆ GetTypeName()

virtual const String& Dviglo::Object::GetTypeName ( ) const
pure virtual

Return type name.

Implemented in Dviglo::UnknownComponent.

◆ SetGlobalVar()

void Dviglo::Object::SetGlobalVar ( StringHash  key,
const Variant value 
)

Set global variable with the respective key and value.


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