Radium Engine  1.5.20
Loading...
Searching...
No Matches
ObjectWithSemantic.hpp
1#pragma once
2
3#include <Core/RaCore.hpp>
4
5#include <cstdarg>
6#include <set>
7
8namespace Ra {
9namespace Core {
10namespace Utils {
17class RA_CORE_API ObjectWithSemantic
18{
19 public:
21
24
25 inline explicit ObjectWithSemantic( const ObjectWithSemantic& other ) :
26 m_names { other.m_names } {}
27
28 virtual inline ~ObjectWithSemantic() = default;
29
30 inline bool hasSemantic( const SemanticName& name ) const {
31 return m_names.find( name ) != m_names.end();
32 }
33
34 inline const SemanticNameCollection& semantics() const { return m_names; }
35
36 inline ObjectWithSemantic& operator=( const ObjectWithSemantic& other ) {
37 CORE_UNUSED( other );
38 CORE_ASSERT( m_names == other.m_names, "Try to assign object with different semantics" );
39 return *this;
40 }
41 inline ObjectWithSemantic& operator=( ObjectWithSemantic&& other ) {
42 CORE_UNUSED( other );
43 CORE_ASSERT( m_names == other.m_names, "Try to assign object with different semantics" );
44 return *this;
45 }
46
47 inline bool shareSemantic( const ObjectWithSemantic& other ) const {
48 return std::any_of( m_names.begin(), m_names.end(), [&other]( const auto& s ) {
49 return other.hasSemantic( s );
50 } );
51 }
52
53 inline bool sameSemantics( const ObjectWithSemantic& other ) const {
54 return m_names == other.m_names;
55 }
56
57 protected:
58 template <class... SemanticNames>
59 inline explicit ObjectWithSemantic( SemanticNames... names ) : m_names { names... } {}
60
61 inline explicit ObjectWithSemantic( const SemanticNameCollection& otherNames ) :
62 m_names { otherNames } {}
63
64 private:
65 SemanticNameCollection m_names;
66};
67
68} // namespace Utils
69} // namespace Core
70} // namespace Ra
T any_of(T... args)
Object associated with one or multiple semantic names.
hepler function to manage enum as underlying types in VariableSet
Definition Cage.cpp:3