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;
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>
225 public:
template<
typename ComponentTypeT>
226 ComponentTypeT *ComponentDefault(
Entity _entity,
227 const typename ComponentTypeT::Type &_default =
228 typename ComponentTypeT::Type());
238 public:
template<
typename ComponentTypeT>
239 std::optional<typename ComponentTypeT::Type> ComponentData(
240 const Entity _entity)
const;
252 public:
template<
typename ComponentTypeT>
253 bool SetComponentData(
const Entity _entity,
254 const typename ComponentTypeT::Type &_data);
265 public:
template<
typename ComponentTypeT>
266 const ComponentTypeT *First()
const;
271 public:
template<
typename ComponentTypeT>
272 ComponentTypeT *First();
285 public:
template<
typename ...ComponentTypeTs>
286 Entity EntityByComponents(
287 const ComponentTypeTs &..._desiredComponents)
const;
301 public:
template<
typename ...ComponentTypeTs>
303 const ComponentTypeTs &..._desiredComponents)
const;
320 public:
template<
typename ...ComponentTypeTs>
322 const ComponentTypeTs &..._desiredComponents)
const;
325 private:
template <
typename T>
340 public:
template<
typename ...ComponentTypeTs>
342 bool(
const Entity &_entity,
343 const ComponentTypeTs *...)>>::type _f)
const;
357 public:
template<
typename ...ComponentTypeTs>
359 bool(
const Entity &_entity,
360 ComponentTypeTs *...)>>::type _f);
374 public:
template<
typename ...ComponentTypeTs>
376 bool(
const Entity &_entity,
377 const ComponentTypeTs *...)>>::type _f)
const;
391 public:
template<
typename ...ComponentTypeTs>
393 bool(
const Entity &_entity,
394 ComponentTypeTs *...)>>::type _f);
400 public:
template <
class Function,
class... ComponentTypeTs>
401 static void ForEach(Function _f,
const ComponentTypeTs &... _components);
414 public:
template <
typename... ComponentTypeTs>
416 bool(
const Entity &_entity,
417 ComponentTypeTs *...)>>::type _f);
430 public:
template <
typename... ComponentTypeTs>
432 bool(
const Entity &_entity,
433 const ComponentTypeTs *...)>>::type _f)
const;
445 public:
template<
typename ...ComponentTypeTs>
447 bool(
const Entity &_entity,
448 const ComponentTypeTs *...)>>::type _f)
const;
492 public:
bool HasNewEntities()
const;
496 public:
bool HasEntitiesMarkedForRemoval()
const;
501 public:
bool HasOneTimeComponentChanges()
const;
507 ComponentTypesWithPeriodicChanges()
const;
533 bool _full =
false)
const;
566 public:
void SetChanged(
581 public:
void SetEntityCreateOffset(uint64_t _offset);
586 protected:
void ClearNewlyCreatedEntities();
590 protected:
void ClearRemovedComponents();
595 protected:
void ProcessRemoveEntityRequests();
598 protected:
void SetAllComponentsUnchanged();
606 private:
bool IsNewEntity(
const Entity _entity)
const;
611 private:
bool IsMarkedForRemoval(
const Entity _entity)
const;
616 private:
bool RemoveEntity(
const Entity _entity);
672 private:
template<
typename FirstComponent,
673 typename ...RemainingComponents,
675 sizeof...(RemainingComponents) == 0,
int>::type = 0>
676 void AddComponentsToView(detail::View &_view,
677 const Entity _entity)
const;
684 private:
template<
typename FirstComponent,
685 typename ...RemainingComponents,
687 sizeof...(RemainingComponents) != 0,
int>::type = 0>
688 void AddComponentsToView(detail::View &_view,
689 const Entity _entity)
const;
695 private:
template<
typename ...ComponentTypeTs>
696 detail::View &FindView()
const;
706 detail::View>::iterator &_iter)
const;
715 detail::View &&_view)
const;
719 private:
void UpdateViews(
const Entity _entity);
751 bool _full =
false)
const;
757 friend class SimulationRunner;
761 friend class NetworkManagerPrimary;
762 friend class NetworkManagerSecondary;
766 friend class detail::View;
772 #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:64
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:49
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...