Utopia 2
Framework for studying models of complex & adaptive systems.
Loading...
Searching...
No Matches
entity.hh
Go to the documentation of this file.
1#ifndef UTOPIA_CORE_ENTITY_HH
2#define UTOPIA_CORE_ENTITY_HH
3
4#include "state.hh"
5#include "tags.hh"
6#include "space.hh"
7#include "types.hh"
8
9
10namespace Utopia {
17
22template<typename EntityContainerType>
23struct NoCustomLinks {};
24
25
27
44template<typename StateType,
46 bool use_def_state_constr=false,
47 typename EntityTags=EmptyTag,
48 template<class> class CustomLinkContainers=NoCustomLinks>
52
54 static constexpr Update mode = update_mode;
55
58
61
63 template<class EntityContainerType>
65};
66
67
69
79template<typename Derived, typename _Traits>
80class Entity :
81 public StateContainer<typename _Traits::State, _Traits::mode>,
82 public _Traits::Tags
83{
84public:
86
90 using Traits = _Traits;
91
94
96 using State = typename Traits::State;
97
99 static constexpr Update mode = Traits::mode;
100
102 using Tags = typename Traits::Tags;
103
105
110 typename Traits::template CustomLinks<EntityContainer<Derived>>;
111
112
113private:
116
119
120
121public:
124 :
125 // Store arguments and initialize Tags via default constructor
127 Tags(),
128 _id(id),
129 // Initialize custom links empty, i.e. with its default constructor
131 {}
132
134 const IndexType& id() const {
135 return _id;
136 }
137
142
145 return _custom_links;
146 }
147};
148
149
150// end group Entity
155} // namespace Utopia
156
157#endif // UTOPIA_CORE_ENTITY_HH
Definition tags.hh:6
An entity is a slightly specialized state container.
Definition entity.hh:83
typename Traits::Tags Tags
The tags associated with this entity.
Definition entity.hh:102
const CustomLinkContainers & custom_links() const
Return const reference to custom link containers.
Definition entity.hh:144
Entity(const IndexType id, const State initial_state)
Construct an entity.
Definition entity.hh:123
typename Traits::State State
The type of the state of this entity.
Definition entity.hh:96
_Traits Traits
The traits of this entity.
Definition entity.hh:90
static constexpr Update mode
Whether this entity is updated synchronously.
Definition entity.hh:99
CustomLinkContainers _custom_links
Container for storing the custom links of this entity.
Definition entity.hh:118
const IndexType & id() const
Return const reference to entity ID.
Definition entity.hh:134
CustomLinkContainers & custom_links()
Return reference to custom link containers.
Definition entity.hh:139
typename Traits::template CustomLinks< EntityContainer< Derived > > CustomLinkContainers
A construct that has as members containers for custom-linked entities.
Definition entity.hh:110
const IndexType _id
ID of this entity.
Definition entity.hh:115
Container for states.
Definition state.hh:37
Container select_entities(const Manager &mngr, const DataIO::Config &sel_cfg)
Select entities according to parameters specified in a configuration.
Definition select.hh:213
Update
Update modes when applying rules.
Definition state.hh:20
Definition agent.hh:11
std::size_t IndexType
Type for indices, i.e. values used for container indexing, agent IDs, ...
Definition types.hh:40
The entity traits struct gathers types to be used for specializing an entity.
Definition entity.hh:49
CustomLinkContainers< EntityContainerType > CustomLinks
Template template parameter to specify type of custom links.
Definition entity.hh:64
EntityTags Tags
Custom entity tags.
Definition entity.hh:60
static constexpr bool use_default_state_constructor
Whether to use the default constructor for constructing a entity state.
Definition entity.hh:57
static constexpr Update mode
Whether the entitys should be synchronously updated.
Definition entity.hh:54
StateType State
Type of the entitys' state container.
Definition entity.hh:51