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);
110 public:
void PinEntity(
const Entity _entity,
bool _recursive =
true);
118 public:
void UnpinEntity(
const Entity _entity,
bool _recursive =
true);
122 public:
void UnpinAllEntities();
127 public:
void RequestRemoveEntities();
132 public:
bool HasEntity(
const Entity _entity)
const;
152 public:
bool SetParentEntity(
const Entity _child,
const Entity _parent);
163 public:
bool EntityHasComponent(
const Entity _entity,
171 public:
bool EntityHasComponentType(
const Entity _entity,
178 public:
bool EntityMatches(
Entity _entity,
186 public:
bool RemoveComponent(
194 public:
bool RemoveComponent(
202 public:
template<
typename ComponentTypeT>
203 bool RemoveComponent(
Entity _entity);
207 public:
void RebuildViews();
215 public:
template<
typename ComponentTypeT>
217 const ComponentTypeT &_data);
224 public:
template<
typename ComponentTypeT>
225 const ComponentTypeT *Component(
const Entity _entity)
const;
232 public:
template<
typename ComponentTypeT>
233 ComponentTypeT *Component(
const Entity _entity);
239 public:
template<
typename ComponentTypeT>
240 const ComponentTypeT *Component(
const ComponentKey &_key)
const;
246 public:
template<
typename ComponentTypeT>
257 public:
template<
typename ComponentTypeT>
258 ComponentTypeT *ComponentDefault(
Entity _entity,
259 const typename ComponentTypeT::Type &_default =
260 typename ComponentTypeT::Type());
270 public:
template<
typename ComponentTypeT>
271 std::optional<typename ComponentTypeT::Type> ComponentData(
272 const Entity _entity)
const;
284 public:
template<
typename ComponentTypeT>
285 bool SetComponentData(
const Entity _entity,
286 const typename ComponentTypeT::Type &_data);
297 public:
template<
typename ComponentTypeT>
298 const ComponentTypeT *First()
const;
303 public:
template<
typename ComponentTypeT>
304 ComponentTypeT *First();
317 public:
template<
typename ...ComponentTypeTs>
318 Entity EntityByComponents(
319 const ComponentTypeTs &..._desiredComponents)
const;
333 public:
template<
typename ...ComponentTypeTs>
335 const ComponentTypeTs &..._desiredComponents)
const;
352 public:
template<
typename ...ComponentTypeTs>
354 const ComponentTypeTs &..._desiredComponents)
const;
357 private:
template <
typename T>
372 public:
template<
typename ...ComponentTypeTs>
374 bool(
const Entity &_entity,
375 const ComponentTypeTs *...)>>::type _f)
const;
389 public:
template<
typename ...ComponentTypeTs>
391 bool(
const Entity &_entity,
392 ComponentTypeTs *...)>>::type _f);
406 public:
template<
typename ...ComponentTypeTs>
408 bool(
const Entity &_entity,
409 const ComponentTypeTs *...)>>::type _f)
const;
423 public:
template<
typename ...ComponentTypeTs>
425 bool(
const Entity &_entity,
426 ComponentTypeTs *...)>>::type _f);
432 public:
template <
class Function,
class... ComponentTypeTs>
433 static void ForEach(Function _f,
const ComponentTypeTs &... _components);
449 public:
template <
typename... ComponentTypeTs>
451 bool(
const Entity &_entity,
452 ComponentTypeTs *...)>>::type _f);
466 public:
template <
typename... ComponentTypeTs>
468 bool(
const Entity &_entity,
469 const ComponentTypeTs *...)>>::type _f)
const;
481 public:
template<
typename ...ComponentTypeTs>
483 bool(
const Entity &_entity,
484 const ComponentTypeTs *...)>>::type _f)
const;
526 public:
bool HasNewEntities()
const;
530 public:
bool HasEntitiesMarkedForRemoval()
const;
535 public:
bool HasOneTimeComponentChanges()
const;
541 ComponentTypesWithPeriodicChanges()
const;
568 bool _full =
false)
const;
599 public:
void SetChanged(
614 public:
void SetEntityCreateOffset(uint64_t _offset);
619 protected:
void ClearNewlyCreatedEntities();
623 protected:
void ClearRemovedComponents();
628 protected:
void ProcessRemoveEntityRequests();
631 protected:
void SetAllComponentsUnchanged();
639 private:
bool IsNewEntity(
const Entity _entity)
const;
644 private:
bool IsMarkedForRemoval(
const Entity _entity)
const;
649 private:
bool RemoveEntity(
const Entity _entity);
705 private:
template<
typename FirstComponent,
706 typename ...RemainingComponents,
708 sizeof...(RemainingComponents) == 0,
int>::type = 0>
709 void AddComponentsToView(detail::View &_view,
710 const Entity _entity)
const;
717 private:
template<
typename FirstComponent,
718 typename ...RemainingComponents,
720 sizeof...(RemainingComponents) != 0,
int>::type = 0>
721 void AddComponentsToView(detail::View &_view,
722 const Entity _entity)
const;
728 private:
template<
typename ...ComponentTypeTs>
729 detail::View &FindView()
const;
739 detail::View>::iterator &_iter)
const;
748 detail::View &&_view)
const;
752 private:
void UpdateViews(
const Entity _entity);
784 bool _full =
false)
const;
790 friend class SimulationRunner;
794 friend class NetworkManagerPrimary;
795 friend class NetworkManagerSecondary;
799 friend class detail::View;
805 #include "ignition/gazebo/detail/EntityComponentManager.hh" Responsible for running GUI systems as new states are received from the backend.
Definition: GuiRunner.hh:38
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...