17 #ifndef IGNITION_GAZEBO_ENTITYCOMPONENTMANAGER_HH_ 18 #define IGNITION_GAZEBO_ENTITYCOMPONENTMANAGER_HH_ 29 #include <type_traits> 30 #include <unordered_set> 37 #include "ignition/gazebo/Export.hh" 41 #include "ignition/gazebo/detail/View.hh" 48 inline namespace IGNITION_GAZEBO_VERSION_NAMESPACE {
75 public:
Entity CreateEntity();
79 public:
size_t EntityCount()
const;
92 public:
void RequestRemoveEntity(
const Entity _entity,
93 bool _recursive =
true);
98 public:
void RequestRemoveEntities();
103 public:
bool HasEntity(
const Entity _entity)
const;
121 public:
bool SetParentEntity(
const Entity _child,
const Entity _parent);
132 public:
bool EntityHasComponent(
const Entity _entity,
140 public:
bool EntityHasComponentType(
const Entity _entity,
147 public:
bool EntityMatches(
Entity _entity,
155 public:
bool RemoveComponent(
163 public:
bool RemoveComponent(
171 public:
template<
typename ComponentTypeT>
172 bool RemoveComponent(
Entity _entity);
176 public:
void RebuildViews();
184 public:
template<
typename ComponentTypeT>
186 const ComponentTypeT &_data);
193 public:
template<
typename ComponentTypeT>
194 const ComponentTypeT *Component(
const Entity _entity)
const;
201 public:
template<
typename ComponentTypeT>
202 ComponentTypeT *Component(
const Entity _entity);
208 public:
template<
typename ComponentTypeT>
209 const ComponentTypeT *Component(
const ComponentKey &_key)
const;
215 public:
template<
typename ComponentTypeT>
226 public:
template<
typename ComponentTypeT>
227 ComponentTypeT *ComponentDefault(
Entity _entity,
228 const typename ComponentTypeT::Type &_default =
229 typename ComponentTypeT::Type());
239 public:
template<
typename ComponentTypeT>
240 std::optional<typename ComponentTypeT::Type> ComponentData(
241 const Entity _entity)
const;
253 public:
template<
typename ComponentTypeT>
254 bool SetComponentData(
const Entity _entity,
255 const typename ComponentTypeT::Type &_data);
266 public:
template<
typename ComponentTypeT>
267 const ComponentTypeT *First()
const;
272 public:
template<
typename ComponentTypeT>
273 ComponentTypeT *First();
286 public:
template<
typename ...ComponentTypeTs>
287 Entity EntityByComponents(
288 const ComponentTypeTs &..._desiredComponents)
const;
302 public:
template<
typename ...ComponentTypeTs>
304 const ComponentTypeTs &..._desiredComponents)
const;
321 public:
template<
typename ...ComponentTypeTs>
323 const ComponentTypeTs &..._desiredComponents)
const;
326 private:
template <
typename T>
341 public:
template<
typename ...ComponentTypeTs>
343 bool(
const Entity &_entity,
344 const ComponentTypeTs *...)>>::type _f)
const;
358 public:
template<
typename ...ComponentTypeTs>
360 bool(
const Entity &_entity,
361 ComponentTypeTs *...)>>::type _f);
375 public:
template<
typename ...ComponentTypeTs>
377 bool(
const Entity &_entity,
378 const ComponentTypeTs *...)>>::type _f)
const;
392 public:
template<
typename ...ComponentTypeTs>
394 bool(
const Entity &_entity,
395 ComponentTypeTs *...)>>::type _f);
401 public:
template <
class Function,
class... ComponentTypeTs>
402 static void ForEach(Function _f,
const ComponentTypeTs &... _components);
418 public:
template <
typename... ComponentTypeTs>
420 bool(
const Entity &_entity,
421 ComponentTypeTs *...)>>::type _f);
435 public:
template <
typename... ComponentTypeTs>
437 bool(
const Entity &_entity,
438 const ComponentTypeTs *...)>>::type _f)
const;
450 public:
template<
typename ...ComponentTypeTs>
452 bool(
const Entity &_entity,
453 const ComponentTypeTs *...)>>::type _f)
const;
495 public:
bool HasNewEntities()
const;
499 public:
bool HasEntitiesMarkedForRemoval()
const;
504 public:
bool HasOneTimeComponentChanges()
const;
510 ComponentTypesWithPeriodicChanges()
const;
536 bool _full =
false)
const;
567 public:
void SetChanged(
582 public:
void SetEntityCreateOffset(uint64_t _offset);
587 protected:
void ClearNewlyCreatedEntities();
591 protected:
void ClearRemovedComponents();
596 protected:
void ProcessRemoveEntityRequests();
599 protected:
void SetAllComponentsUnchanged();
607 private:
bool IsNewEntity(
const Entity _entity)
const;
612 private:
bool IsMarkedForRemoval(
const Entity _entity)
const;
617 private:
bool RemoveEntity(
const Entity _entity);
673 private:
template<
typename FirstComponent,
674 typename ...RemainingComponents,
676 sizeof...(RemainingComponents) == 0,
int>::type = 0>
677 void AddComponentsToView(detail::View &_view,
678 const Entity _entity)
const;
685 private:
template<
typename FirstComponent,
686 typename ...RemainingComponents,
688 sizeof...(RemainingComponents) != 0,
int>::type = 0>
689 void AddComponentsToView(detail::View &_view,
690 const Entity _entity)
const;
696 private:
template<
typename ...ComponentTypeTs>
697 detail::View &FindView()
const;
707 detail::View>::iterator &_iter)
const;
716 detail::View &&_view)
const;
720 private:
void UpdateViews(
const Entity _entity);
752 bool _full =
false)
const;
758 friend class SimulationRunner;
762 friend class NetworkManagerPrimary;
763 friend class NetworkManagerSecondary;
767 friend class detail::View;
773 #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:65
uint64_t ComponentTypeId
A unique identifier for a component type. A component type must be derived from components::BaseCompo...
Definition: Types.hh:86
class IGNITION_GAZEBO_HIDDEN EntityComponentManagerPrivate
Definition: EntityComponentManager.hh:50
int ComponentId
A unique identifier for a component instance. The uniqueness of a ComponentId is scoped to the compon...
Definition: Types.hh:81
ComponentState
Possible states for a component.
Definition: Types.hh:63
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...