17 #ifndef IGNITION_GAZEBO_ENTITYCOMPONENTMANAGER_HH_ 18 #define IGNITION_GAZEBO_ENTITYCOMPONENTMANAGER_HH_ 20 #include <ignition/msgs/serialized.pb.h> 21 #include <ignition/msgs/serialized_map.pb.h> 28 #include <type_traits> 29 #include <unordered_set> 36 #include "ignition/gazebo/Export.hh" 40 #include "ignition/gazebo/detail/View.hh" 47 inline namespace IGNITION_GAZEBO_VERSION_NAMESPACE {
74 public:
Entity CreateEntity();
78 public:
size_t EntityCount()
const;
91 public:
void RequestRemoveEntity(
const Entity _entity,
92 bool _recursive =
true);
97 public:
void RequestRemoveEntities();
102 public:
bool HasEntity(
const Entity _entity)
const;
120 public:
bool SetParentEntity(
const Entity _child,
const Entity _parent);
131 public:
bool EntityHasComponent(
const Entity _entity,
139 public:
bool EntityHasComponentType(
const Entity _entity,
146 public:
bool EntityMatches(
Entity _entity,
154 public:
bool RemoveComponent(
162 public:
bool RemoveComponent(
170 public:
template<
typename ComponentTypeT>
171 bool RemoveComponent(
Entity _entity);
175 public:
void RebuildViews();
183 public:
template<
typename ComponentTypeT>
185 const ComponentTypeT &_data);
192 public:
template<
typename ComponentTypeT>
193 const ComponentTypeT *Component(
const Entity _entity)
const;
200 public:
template<
typename ComponentTypeT>
201 ComponentTypeT *Component(
const Entity _entity);
207 public:
template<
typename ComponentTypeT>
208 const ComponentTypeT *Component(
const ComponentKey &_key)
const;
214 public:
template<
typename ComponentTypeT>
226 public:
template<
typename ComponentTypeT>
227 const ComponentTypeT *First()
const;
232 public:
template<
typename ComponentTypeT>
233 ComponentTypeT *First();
246 public:
template<
typename ...ComponentTypeTs>
247 Entity EntityByComponents(
248 const ComponentTypeTs &..._desiredComponents)
const;
262 public:
template<
typename ...ComponentTypeTs>
264 const ComponentTypeTs &..._desiredComponents)
const;
281 public:
template<
typename ...ComponentTypeTs>
283 const ComponentTypeTs &..._desiredComponents)
const;
286 private:
template <
typename T>
301 public:
template<
typename ...ComponentTypeTs>
303 bool(
const Entity &_entity,
304 const ComponentTypeTs *...)>>::type _f)
const;
318 public:
template<
typename ...ComponentTypeTs>
320 bool(
const Entity &_entity,
321 ComponentTypeTs *...)>>::type _f);
335 public:
template<
typename ...ComponentTypeTs>
337 bool(
const Entity &_entity,
338 const ComponentTypeTs *...)>>::type _f)
const;
352 public:
template<
typename ...ComponentTypeTs>
354 bool(
const Entity &_entity,
355 ComponentTypeTs *...)>>::type _f);
361 public:
template <
class Function,
class... ComponentTypeTs>
362 static void ForEach(Function _f,
const ComponentTypeTs &... _components);
375 public:
template <
typename... ComponentTypeTs>
377 bool(
const Entity &_entity,
378 ComponentTypeTs *...)>>::type _f);
391 public:
template <
typename... ComponentTypeTs>
393 bool(
const Entity &_entity,
394 const ComponentTypeTs *...)>>::type _f)
const;
406 public:
template<
typename ...ComponentTypeTs>
408 bool(
const Entity &_entity,
409 const ComponentTypeTs *...)>>::type _f)
const;
431 public: msgs::SerializedState State(
449 public: msgs::SerializedState ChangedState()
const;
453 public:
bool HasNewEntities()
const;
457 public:
bool HasEntitiesMarkedForRemoval()
const;
462 public:
bool HasOneTimeComponentChanges()
const;
472 public:
void SetState(
const msgs::SerializedState &_stateMsg);
485 msgs::SerializedStateMap &_state,
488 bool _full =
false)
const;
505 public:
void ChangedState(msgs::SerializedStateMap &_state)
const;
515 public:
void SetState(
const msgs::SerializedStateMap &_stateMsg);
521 public:
void SetChanged(
535 protected:
void ClearNewlyCreatedEntities();
540 protected:
void ProcessRemoveEntityRequests();
543 protected:
void SetAllComponentsUnchanged();
551 private:
bool IsNewEntity(
const Entity _entity)
const;
556 private:
bool IsMarkedForRemoval(
const Entity _entity)
const;
561 private:
bool RemoveEntity(
const Entity _entity);
617 private:
template<
typename FirstComponent,
618 typename ...RemainingComponents,
620 sizeof...(RemainingComponents) == 0,
int>::type = 0>
621 void AddComponentsToView(detail::View &_view,
622 const Entity _entity)
const;
629 private:
template<
typename FirstComponent,
630 typename ...RemainingComponents,
632 sizeof...(RemainingComponents) != 0,
int>::type = 0>
633 void AddComponentsToView(detail::View &_view,
634 const Entity _entity)
const;
640 private:
template<
typename ...ComponentTypeTs>
641 detail::View &FindView()
const;
651 detail::View>::iterator &_iter)
const;
660 detail::View &&_view)
const;
664 private:
void UpdateViews(
const Entity _entity);
677 private:
void AddEntityToMessage(msgs::SerializedState &_msg,
693 private:
void AddEntityToMessage(msgs::SerializedStateMap &_msg,
696 bool _full =
false)
const;
702 friend class SimulationRunner;
706 friend class NetworkManagerPrimary;
707 friend class NetworkManagerSecondary;
711 friend class detail::View;
717 #include "ignition/gazebo/detail/EntityComponentManager.hh" Responsible for running GUI systems as new states are received from the backend.
Definition: GuiRunner.hh:40
Component< Entity, class ParentEntityTag > ParentEntity
This component holds an entity's parent entity.
Definition: ParentEntity.hh:41
The EntityComponentManager constructs, deletes, and returns components and entities. A component can be of any class which inherits from components::BaseComponent.
Definition: EntityComponentManager.hh:64
uint64_t ComponentTypeId
A unique identifier for a component type. A component type must be derived from components::BaseCompo...
Definition: Types.hh:87
class IGNITION_GAZEBO_HIDDEN EntityComponentManagerPrivate
Definition: EntityComponentManager.hh:49
int ComponentId
A unique identifier for a component instance. The uniqueness of a ComponentId is scoped to the compon...
Definition: Types.hh:82
ComponentState
Possible states for a component.
Definition: Types.hh:64
This library is part of the Ignition Robotics project.
uint64_t Entity
An Entity identifies a single object in simulation such as a model, link, or light. At its core, an Entity is just an identifier.
Definition: Entity.hh:59
Base class for all components.
Definition: Component.hh:230
Component value has suffered a one-time change. This indicates to systems that this change must be pr...