17 #ifndef IGNITION_GAZEBO_ENTITYCOMPONENTMANAGER_HH_ 18 #define IGNITION_GAZEBO_ENTITYCOMPONENTMANAGER_HH_ 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;
122 public:
bool SetParentEntity(
const Entity _child,
const Entity _parent);
133 public:
bool EntityHasComponent(
const Entity _entity,
141 public:
bool EntityHasComponentType(
const Entity _entity,
148 public:
bool EntityMatches(
Entity _entity,
156 public:
bool RemoveComponent(
164 public:
bool RemoveComponent(
172 public:
template<
typename ComponentTypeT>
173 bool RemoveComponent(
Entity _entity);
177 public:
void RebuildViews();
185 public:
template<
typename ComponentTypeT>
187 const ComponentTypeT &_data);
194 public:
template<
typename ComponentTypeT>
195 const ComponentTypeT *Component(
const Entity _entity)
const;
202 public:
template<
typename ComponentTypeT>
203 ComponentTypeT *Component(
const Entity _entity);
209 public:
template<
typename ComponentTypeT>
210 const ComponentTypeT *Component(
const ComponentKey &_key)
const;
216 public:
template<
typename ComponentTypeT>
227 public:
template<
typename ComponentTypeT>
228 ComponentTypeT *ComponentDefault(
Entity _entity,
229 const typename ComponentTypeT::Type &_default =
230 typename ComponentTypeT::Type());
240 public:
template<
typename ComponentTypeT>
241 std::optional<typename ComponentTypeT::Type> ComponentData(
242 const Entity _entity)
const;
254 public:
template<
typename ComponentTypeT>
255 bool SetComponentData(
const Entity _entity,
256 const typename ComponentTypeT::Type &_data);
267 public:
template<
typename ComponentTypeT>
268 const ComponentTypeT *First()
const;
273 public:
template<
typename ComponentTypeT>
274 ComponentTypeT *First();
287 public:
template<
typename ...ComponentTypeTs>
288 Entity EntityByComponents(
289 const ComponentTypeTs &..._desiredComponents)
const;
303 public:
template<
typename ...ComponentTypeTs>
305 const ComponentTypeTs &..._desiredComponents)
const;
322 public:
template<
typename ...ComponentTypeTs>
324 const ComponentTypeTs &..._desiredComponents)
const;
327 private:
template <
typename T>
342 public:
template<
typename ...ComponentTypeTs>
344 bool(
const Entity &_entity,
345 const ComponentTypeTs *...)>>::type _f)
const;
359 public:
template<
typename ...ComponentTypeTs>
361 bool(
const Entity &_entity,
362 ComponentTypeTs *...)>>::type _f);
376 public:
template<
typename ...ComponentTypeTs>
378 bool(
const Entity &_entity,
379 const ComponentTypeTs *...)>>::type _f)
const;
393 public:
template<
typename ...ComponentTypeTs>
395 bool(
const Entity &_entity,
396 ComponentTypeTs *...)>>::type _f);
402 public:
template <
class Function,
class... ComponentTypeTs>
403 static void ForEach(Function _f,
const ComponentTypeTs &... _components);
419 public:
template <
typename... ComponentTypeTs>
421 bool(
const Entity &_entity,
422 ComponentTypeTs *...)>>::type _f);
436 public:
template <
typename... ComponentTypeTs>
438 bool(
const Entity &_entity,
439 const ComponentTypeTs *...)>>::type _f)
const;
451 public:
template<
typename ...ComponentTypeTs>
453 bool(
const Entity &_entity,
454 const ComponentTypeTs *...)>>::type _f)
const;
498 public:
bool HasNewEntities()
const;
502 public:
bool HasEntitiesMarkedForRemoval()
const;
507 public:
bool HasOneTimeComponentChanges()
const;
513 ComponentTypesWithPeriodicChanges()
const;
540 bool _full =
false)
const;
573 public:
void SetChanged(
588 public:
void SetEntityCreateOffset(uint64_t _offset);
593 protected:
void ClearNewlyCreatedEntities();
598 protected:
void ProcessRemoveEntityRequests();
601 protected:
void SetAllComponentsUnchanged();
609 private:
bool IsNewEntity(
const Entity _entity)
const;
614 private:
bool IsMarkedForRemoval(
const Entity _entity)
const;
619 private:
bool RemoveEntity(
const Entity _entity);
675 private:
template<
typename FirstComponent,
676 typename ...RemainingComponents,
678 sizeof...(RemainingComponents) == 0,
int>::type = 0>
679 void AddComponentsToView(detail::View &_view,
680 const Entity _entity)
const;
687 private:
template<
typename FirstComponent,
688 typename ...RemainingComponents,
690 sizeof...(RemainingComponents) != 0,
int>::type = 0>
691 void AddComponentsToView(detail::View &_view,
692 const Entity _entity)
const;
698 private:
template<
typename ...ComponentTypeTs>
699 detail::View &FindView()
const;
709 detail::View>::iterator &_iter)
const;
718 detail::View &&_view)
const;
722 private:
void UpdateViews(
const Entity _entity);
754 bool _full =
false)
const;
760 friend class SimulationRunner;
764 friend class NetworkManagerPrimary;
765 friend class NetworkManagerSecondary;
769 friend class detail::View;
775 #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: include/ignition/gazebo/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: include/ignition/gazebo/Types.hh:82
ComponentState
Possible states for a component.
Definition: include/ignition/gazebo/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...