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>
220 public:
template<
typename ComponentTypeT>
221 const ComponentTypeT *First()
const;
226 public:
template<
typename ComponentTypeT>
227 ComponentTypeT *First();
240 public:
template<
typename ...ComponentTypeTs>
241 Entity EntityByComponents(
242 const ComponentTypeTs &..._desiredComponents)
const;
256 public:
template<
typename ...ComponentTypeTs>
258 const ComponentTypeTs &..._desiredComponents)
const;
275 public:
template<
typename ...ComponentTypeTs>
277 const ComponentTypeTs &..._desiredComponents)
const;
280 private:
template <
typename T>
295 public:
template<
typename ...ComponentTypeTs>
297 bool(
const Entity &_entity,
298 const ComponentTypeTs *...)>>::type _f)
const;
312 public:
template<
typename ...ComponentTypeTs>
314 bool(
const Entity &_entity,
315 ComponentTypeTs *...)>>::type _f);
329 public:
template<
typename ...ComponentTypeTs>
331 bool(
const Entity &_entity,
332 const ComponentTypeTs *...)>>::type _f)
const;
346 public:
template<
typename ...ComponentTypeTs>
348 bool(
const Entity &_entity,
349 ComponentTypeTs *...)>>::type _f);
355 public:
template <
class Function,
class... ComponentTypeTs>
356 static void ForEach(Function _f,
const ComponentTypeTs &... _components);
369 public:
template <
typename... ComponentTypeTs>
371 bool(
const Entity &_entity,
372 ComponentTypeTs *...)>>::type _f);
385 public:
template <
typename... ComponentTypeTs>
387 bool(
const Entity &_entity,
388 const ComponentTypeTs *...)>>::type _f)
const;
400 public:
template<
typename ...ComponentTypeTs>
402 bool(
const Entity &_entity,
403 const ComponentTypeTs *...)>>::type _f)
const;
425 public: msgs::SerializedState State(
443 public: msgs::SerializedState ChangedState()
const;
447 public:
bool HasNewEntities()
const;
451 public:
bool HasEntitiesMarkedForRemoval()
const;
456 public:
bool HasOneTimeComponentChanges()
const;
466 public:
void SetState(
const msgs::SerializedState &_stateMsg);
478 protected:
void ClearNewlyCreatedEntities();
483 protected:
void ProcessRemoveEntityRequests();
491 private:
bool IsNewEntity(
const Entity _entity)
const;
496 private:
bool IsMarkedForRemoval(
const Entity _entity)
const;
501 private:
bool RemoveEntity(
const Entity _entity);
557 private:
template<
typename FirstComponent,
558 typename ...RemainingComponents,
560 sizeof...(RemainingComponents) == 0,
int>::type = 0>
561 void AddComponentsToView(detail::View &_view,
562 const Entity _entity)
const;
569 private:
template<
typename FirstComponent,
570 typename ...RemainingComponents,
572 sizeof...(RemainingComponents) != 0,
int>::type = 0>
573 void AddComponentsToView(detail::View &_view,
574 const Entity _entity)
const;
580 private:
template<
typename ...ComponentTypeTs>
581 detail::View &FindView()
const;
591 detail::View>::iterator &_iter)
const;
600 detail::View &&_view)
const;
604 private:
void UpdateViews(
const Entity _entity);
617 private:
void AddEntityToMessage(msgs::SerializedState &_msg,
628 friend class SimulationRunner;
632 friend class NetworkManagerPrimary;
633 friend class NetworkManagerSecondary;
637 friend class detail::View;
653 msgs::SerializedStateMap &_state,
656 bool _full =
false)
const;
673 public:
void ChangedState(msgs::SerializedStateMap &_state)
const;
683 public:
void SetState(
const msgs::SerializedStateMap &_stateMsg);
689 public:
void SetChanged(
694 protected:
void SetAllComponentsUnchanged();
705 private:
void AddEntityToMessage(msgs::SerializedStateMap &_msg,
708 bool _full =
false)
const;
714 #include "ignition/gazebo/detail/EntityComponentManager.hh" Definition: GuiRunner.hh:37
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...