DEKI/ENGINE docs
manual api reference
Deki 0.40.1
Modular C++ engine with a visual editor, for 2D and 3D
Loading...
Searching...
No Matches

A node in the scene: a name, components, children and, in most builds, a transform. More...

#include <deki/Object.h>

Public Member Functions

 Object ()
 Object (const Object &)=delete
 Not copyable: an Object owns its children and components by raw pointer, so a copy would double-free them, and the editor-only side table is keyed by this, which a copy would share.
 Object (const std::string &objectName)
 ~Object ()
 Must stay out of line: it erases this object's row from the editor-only side table in Object.cpp.
void AddChild (Object *child)
template<typename T, typename... Args>
T * AddComponent (Args &&... args)
Object * FindChild (uint32_t childId)
Object * FindChildByName (const std::string &name)
template<typename T>
T * FindInterface ()
 The first component that implements interface T, found through the ComponentInterfaceAdapters registry (no RTTI).
int GetChildIndex (Object *child) const
const std::vector< Object * > & GetChildren () const
template<typename T>
T * GetComponent ()
 The first component of type T or of a class directly derived from T.
template<typename T>
const T * GetComponent () const
Component * GetComponentByTypeId (uint32_t typeId)
 The first component whose type id is exactly typeId.
const Component * GetComponentByTypeId (uint32_t typeId) const
template<typename T>
std::vector< T * > GetComponents ()
 Every component of type T or of a class directly derived from T.
const std::vector< Component * > & GetComponents () const
uint32_t GetId () const
const std::string & GetInstanceOverridesJson () const
const std::string & GetName () const
Scene * GetOwnerScene () const
Object * GetParent () const
const std::string & GetSourceSceneGuid () const
 Empty when this object is not a scene instance.
template<typename T>
bool HasComponent () const
 True when a component of type T or a class directly derived from T is attached.
void InsertChildAt (Object *child, size_t index)
bool IsActive () const
bool IsActiveInHierarchy () const
 True when this object and all its ancestors are active.
bool IsDescendantOf (Object *ancestor) const
bool IsEditorOnly () const
bool IsPartOfInstance () const
bool IsPendingDestroy () const
 True from Scene::DestroyDekiObject() until the object is deleted at the end of the lifecycle phase.
bool IsPersistent () const
bool IsSceneInstance () const
void MarkWorldTransformDirty ()
Object & operator= (const Object &)=delete
void RemoveChild (Object *child)
template<typename T>
void RemoveComponent ()
void RemoveComponent (Component *comp)
 Removes and deletes comp.
void RemoveFromParent ()
void SetActive (bool value)
 Out of line: a change tells the owner scene to rebuild its list of active components, so an object shown after load gets Start and Update.
void SetEditorOnly (bool value)
void SetId (uint32_t newId)
void SetInstanceOverridesJson (const std::string &json)
void SetName (const std::string &newName)
void SetOwnerScene (Scene *scene)
void SetParent (Object *newParent)
void SetPartOfInstance (bool value)
void SetPersistent (bool value)
void SetSourceSceneGuid (const std::string &guid)

Static Public Member Functions

static uint32_t GenerateDeterministicId (uint32_t seed1, uint32_t seed2)
static uint32_t GenerateId ()

Friends

Component * Internal::AddComponentByName (Object &object, const std::string &typeName)
void Internal::AttachComponent (Object &object, Component *component)
int Internal::DetachComponent (Object &object, Component *component)
void Internal::ReattachComponent (Object &object, Component *component, size_t index)
class LifecycleManager
class Scene

Detailed Description

A node in the scene: a name, components, children and, in most builds, a transform.

Constructor & Destructor Documentation

◆ Object() [1/3]

Deki::Object::Object ( )

◆ Object() [2/3]

Deki::Object::Object ( const std::string & objectName)

◆ Object() [3/3]

Deki::Object::Object ( const Object & )
delete

Not copyable: an Object owns its children and components by raw pointer, so a copy would double-free them, and the editor-only side table is keyed by this, which a copy would share.

◆ ~Object()

Deki::Object::~Object ( )

Must stay out of line: it erases this object's row from the editor-only side table in Object.cpp.

Defining it = default here would make the class layout depend on DEKI_EDITOR again.

Member Function Documentation

◆ AddChild()

void Deki::Object::AddChild ( Object * child)

◆ AddComponent()

template<typename T, typename... Args>
T * Deki::Object::AddComponent ( Args &&... args)
inline

◆ FindChild()

Object * Deki::Object::FindChild ( uint32_t childId)

◆ FindChildByName()

Object * Deki::Object::FindChildByName ( const std::string & name)

◆ FindInterface()

template<typename T>
T * Deki::Object::FindInterface ( )
inline

The first component that implements interface T, found through the ComponentInterfaceAdapters registry (no RTTI).

T must have a static constexpr uint32_t kInterfaceID member.

◆ GenerateDeterministicId()

uint32_t Deki::Object::GenerateDeterministicId ( uint32_t seed1,
uint32_t seed2 )
inlinestatic

◆ GenerateId()

uint32_t Deki::Object::GenerateId ( )
inlinestatic

◆ GetChildIndex()

int Deki::Object::GetChildIndex ( Object * child) const

◆ GetChildren()

const std::vector< Object * > & Deki::Object::GetChildren ( ) const
inline

◆ GetComponent() [1/2]

template<typename T>
T * Deki::Object::GetComponent ( )
inline

The first component of type T or of a class directly derived from T.

For example, GetComponent<SetupComponent>() returns an SDCardComponent that derives from SetupComponent.

◆ GetComponent() [2/2]

template<typename T>
const T * Deki::Object::GetComponent ( ) const
inline

◆ GetComponentByTypeId() [1/2]

Component * Deki::Object::GetComponentByTypeId ( uint32_t typeId)
inline

The first component whose type id is exactly typeId.

◆ GetComponentByTypeId() [2/2]

const Component * Deki::Object::GetComponentByTypeId ( uint32_t typeId) const
inline

◆ GetComponents() [1/2]

template<typename T>
std::vector< T * > Deki::Object::GetComponents ( )
inline

Every component of type T or of a class directly derived from T.

◆ GetComponents() [2/2]

const std::vector< Component * > & Deki::Object::GetComponents ( ) const
inline

◆ GetId()

uint32_t Deki::Object::GetId ( ) const
inline

◆ GetInstanceOverridesJson()

const std::string & Deki::Object::GetInstanceOverridesJson ( ) const

◆ GetName()

const std::string & Deki::Object::GetName ( ) const
inline

◆ GetOwnerScene()

Scene * Deki::Object::GetOwnerScene ( ) const
inline

◆ GetParent()

Object * Deki::Object::GetParent ( ) const
inline

◆ GetSourceSceneGuid()

const std::string & Deki::Object::GetSourceSceneGuid ( ) const

Empty when this object is not a scene instance.

The reference is valid until the next SetSourceSceneGuid on this object, or its destruction.

◆ HasComponent()

template<typename T>
bool Deki::Object::HasComponent ( ) const
inline

True when a component of type T or a class directly derived from T is attached.

◆ InsertChildAt()

void Deki::Object::InsertChildAt ( Object * child,
size_t index )

◆ IsActive()

bool Deki::Object::IsActive ( ) const
inline

◆ IsActiveInHierarchy()

bool Deki::Object::IsActiveInHierarchy ( ) const

True when this object and all its ancestors are active.

◆ IsDescendantOf()

bool Deki::Object::IsDescendantOf ( Object * ancestor) const

◆ IsEditorOnly()

bool Deki::Object::IsEditorOnly ( ) const
inline

◆ IsPartOfInstance()

bool Deki::Object::IsPartOfInstance ( ) const
inline

◆ IsPendingDestroy()

bool Deki::Object::IsPendingDestroy ( ) const
inline

True from Scene::DestroyDekiObject() until the object is deleted at the end of the lifecycle phase.

It reads as inactive in the meantime.

◆ IsPersistent()

bool Deki::Object::IsPersistent ( ) const
inline

◆ IsSceneInstance()

bool Deki::Object::IsSceneInstance ( ) const
inline

◆ MarkWorldTransformDirty()

void Deki::Object::MarkWorldTransformDirty ( )
inline

◆ operator=()

Object & Deki::Object::operator= ( const Object & )
delete

◆ RemoveChild()

void Deki::Object::RemoveChild ( Object * child)

◆ RemoveComponent() [1/2]

template<typename T>
void Deki::Object::RemoveComponent ( )
inline

◆ RemoveComponent() [2/2]

void Deki::Object::RemoveComponent ( Component * comp)

Removes and deletes comp.

From a component's Awake, Start or Update it gets no more calls and is deleted when that phase ends.

◆ RemoveFromParent()

void Deki::Object::RemoveFromParent ( )

◆ SetActive()

void Deki::Object::SetActive ( bool value)

Out of line: a change tells the owner scene to rebuild its list of active components, so an object shown after load gets Start and Update.

◆ SetEditorOnly()

void Deki::Object::SetEditorOnly ( bool value)
inline

◆ SetId()

void Deki::Object::SetId ( uint32_t newId)

◆ SetInstanceOverridesJson()

void Deki::Object::SetInstanceOverridesJson ( const std::string & json)

◆ SetName()

void Deki::Object::SetName ( const std::string & newName)
inline

◆ SetOwnerScene()

void Deki::Object::SetOwnerScene ( Scene * scene)
inline

◆ SetParent()

void Deki::Object::SetParent ( Object * newParent)

◆ SetPartOfInstance()

void Deki::Object::SetPartOfInstance ( bool value)
inline

◆ SetPersistent()

void Deki::Object::SetPersistent ( bool value)
inline

◆ SetSourceSceneGuid()

void Deki::Object::SetSourceSceneGuid ( const std::string & guid)

◆ Internal::AddComponentByName

Component * Internal::AddComponentByName ( Object & object,
const std::string & typeName )
friend

◆ Internal::AttachComponent

void Internal::AttachComponent ( Object & object,
Component * component )
friend

◆ Internal::DetachComponent

int Internal::DetachComponent ( Object & object,
Component * component )
friend

◆ Internal::ReattachComponent

void Internal::ReattachComponent ( Object & object,
Component * component,
size_t index )
friend

◆ LifecycleManager

friend class LifecycleManager
friend

◆ Scene

friend class Scene
friend

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