Loading [MathJax]/extensions/TeX/AMSmath.js
Radium Engine  1.5.24
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ItemEntry.hpp
1#pragma once
2
3#include <Core/CoreMacros.hpp>
4#include <Core/Utils/Index.hpp>
5#include <Engine/RaEngine.hpp>
6#include <string>
7#include <vector>
8
9namespace Ra {
10namespace Engine {
11class RadiumEngine;
12
13namespace Scene {
14
15class Entity;
16class Component;
17
24struct RA_ENGINE_API ItemEntry {
26 ItemEntry() = default;
27
32 explicit ItemEntry( Entity* ent,
33 Component* comp = nullptr,
34 Ra::Core::Utils::Index ro = Ra::Core::Utils::Index::Invalid() ) :
35 m_entity { ent }, m_component { comp }, m_roIndex { ro } {}
36
38 inline bool operator==( const ItemEntry& rhs ) const;
39
41 bool isValid() const;
42
44 bool isSelectable() const;
45
47 inline bool isEntityNode() const;
48
50 inline bool isComponentNode() const;
51
53 inline bool isRoNode() const;
54
56 inline void checkConsistency() const;
57
59 Entity* m_entity { nullptr };
60
63 Component* m_component { nullptr };
64
66 Ra::Core::Utils::Index m_roIndex {};
67};
68
70RA_ENGINE_API std::string getEntryName( const Engine::RadiumEngine* engine, const ItemEntry& ent );
71
77 const ItemEntry& ent );
78
80 ON_DEBUG( checkConsistency() );
81 return ( m_entity && !m_component );
82}
83
85 ON_DEBUG( checkConsistency() );
86 return ( m_entity && m_component && m_roIndex.isInvalid() );
87}
88
89bool ItemEntry::isRoNode() const {
90 ON_DEBUG( checkConsistency() );
91 return ( m_entity && m_component && m_roIndex.isValid() );
92}
93
95 CORE_ASSERT( m_entity || ( !m_component && m_roIndex.isInvalid() ),
96 "Component or RO is set while entity is not" );
97 CORE_ASSERT( m_component || m_roIndex.isInvalid(), "RO is set while component is not" );
98}
99
100inline bool ItemEntry::operator==( const ItemEntry& rhs ) const {
101 return m_entity == rhs.m_entity && m_component == rhs.m_component && m_roIndex == rhs.m_roIndex;
102}
103
104} // namespace Scene
105} // namespace Engine
106} // namespace Ra
A component is an element that can be updated by a system. It is also linked to some other components...
Definition Component.hpp:31
An entity is an scene element. It ties together components with a transform.
Definition Entity.hpp:23
std::string getEntryName(const Engine::RadiumEngine *engine, const ItemEntry &ent)
Returns the name associated to the given item.
Definition ItemEntry.cpp:17
std::vector< Ra::Core::Utils::Index > getItemROs(const Engine::RadiumEngine *, const ItemEntry &ent)
Definition ItemEntry.cpp:28
hepler function to manage enum as underlying types in VariableSet
Definition Cage.cpp:4
Ra::Core::Utils::Index m_roIndex
RO index of the represented object.
Definition ItemEntry.hpp:66
ItemEntry(Entity *ent, Component *comp=nullptr, Ra::Core::Utils::Index ro=Ra::Core::Utils::Index::Invalid())
Definition ItemEntry.hpp:32
ItemEntry()=default
Create an invalid entry.
bool isComponentNode() const
Returns true if the item represents a component.
Definition ItemEntry.hpp:84
void checkConsistency() const
Debug checks.
Definition ItemEntry.hpp:94
Entity * m_entity
The entity represented by the item, or owning the object represented.
Definition ItemEntry.hpp:59
bool operator==(const ItemEntry &rhs) const
Compare two items.
bool isEntityNode() const
Returns true if the item represents an entity.
Definition ItemEntry.hpp:79
bool isRoNode() const
Returns true if the item represents a render object.
Definition ItemEntry.hpp:89