17 #ifndef IGNITION_GAZEBO_ENTITYCOMPONENTMANAGER_HH_ 18 #define IGNITION_GAZEBO_ENTITYCOMPONENTMANAGER_HH_ 29 #include <type_traits> 30 #include <unordered_set> 31 #include <unordered_map> 38 #include "ignition/gazebo/Export.hh" 42 #include "ignition/gazebo/detail/View.hh" 49 inline namespace IGNITION_GAZEBO_VERSION_NAMESPACE {
76 public:
Entity CreateEntity();
112 public:
size_t EntityCount()
const;
125 public:
void RequestRemoveEntity(
const Entity _entity,
126 bool _recursive =
true);
143 public:
void PinEntity(
const Entity _entity,
bool _recursive =
true);
151 public:
void UnpinEntity(
const Entity _entity,
bool _recursive =
true);
155 public:
void UnpinAllEntities();
160 public:
void RequestRemoveEntities();
165 public:
bool HasEntity(
const Entity _entity)
const;
185 public:
bool SetParentEntity(
const Entity _child,
const Entity _parent);
204 public:
bool EntityHasComponentType(
const Entity _entity,
211 public:
bool EntityMatches(
Entity _entity,
227 public:
bool RemoveComponent(
235 public:
template<
typename ComponentTypeT>
236 bool RemoveComponent(
Entity _entity);
240 public:
void RebuildViews();
250 public:
template<
typename ComponentTypeT>
251 ComponentTypeT *CreateComponent(
253 const ComponentTypeT &_data);
260 public:
template<
typename ComponentTypeT>
261 const ComponentTypeT *Component(
const Entity _entity)
const;
268 public:
template<
typename ComponentTypeT>
269 ComponentTypeT *Component(
const Entity _entity);
275 public:
template<
typename ComponentTypeT>
283 public:
template<
typename ComponentTypeT>
295 public:
template<
typename ComponentTypeT>
296 ComponentTypeT *ComponentDefault(
Entity _entity,
297 const typename ComponentTypeT::Type &_default =
298 typename ComponentTypeT::Type());
308 public:
template<
typename ComponentTypeT>
309 std::optional<typename ComponentTypeT::Type> ComponentData(
310 const Entity _entity)
const;
322 public:
template<
typename ComponentTypeT>
323 bool SetComponentData(
const Entity _entity,
324 const typename ComponentTypeT::Type &_data);
335 public:
template<
typename ComponentTypeT>
341 public:
template<
typename ComponentTypeT>
355 public:
template<
typename ...ComponentTypeTs>
356 Entity EntityByComponents(
357 const ComponentTypeTs &..._desiredComponents)
const;
371 public:
template<
typename ...ComponentTypeTs>
373 const ComponentTypeTs &..._desiredComponents)
const;
390 public:
template<
typename ...ComponentTypeTs>
392 const ComponentTypeTs &..._desiredComponents)
const;
395 private:
template <
typename T>
425 public:
template<
typename ...ComponentTypeTs>
427 bool(
const Entity &_entity,
428 const ComponentTypeTs *...)>>::type _f)
const;
442 public:
template<
typename ...ComponentTypeTs>
444 bool(
const Entity &_entity,
445 ComponentTypeTs *...)>>::type _f);
459 public:
template<
typename ...ComponentTypeTs>
461 bool(
const Entity &_entity,
462 const ComponentTypeTs *...)>>::type _f)
const;
476 public:
template<
typename ...ComponentTypeTs>
478 bool(
const Entity &_entity,
479 ComponentTypeTs *...)>>::type _f);
485 public:
template <
class Function,
class... ComponentTypeTs>
486 static void ForEach(Function _f,
const ComponentTypeTs &... _components);
502 public:
template <
typename... ComponentTypeTs>
504 bool(
const Entity &_entity,
505 ComponentTypeTs *...)>>::type _f);
519 public:
template <
typename... ComponentTypeTs>
521 bool(
const Entity &_entity,
522 const ComponentTypeTs *...)>>::type _f)
const;
534 public:
template<
typename ...ComponentTypeTs>
536 bool(
const Entity &_entity,
537 const ComponentTypeTs *...)>>::type _f)
const;
579 public:
bool HasNewEntities()
const;
583 public:
bool HasEntitiesMarkedForRemoval()
const;
588 public:
bool HasOneTimeComponentChanges()
const;
594 ComponentTypesWithPeriodicChanges()
const;
621 bool _full =
false)
const;
652 public:
void SetChanged(
667 public:
void SetEntityCreateOffset(uint64_t _offset);
672 protected:
void ClearNewlyCreatedEntities();
676 protected:
void ClearRemovedComponents();
681 protected:
void ProcessRemoveEntityRequests();
684 protected:
void SetAllComponentsUnchanged();
692 private:
bool IsNewEntity(
const Entity _entity)
const;
697 private:
bool IsMarkedForRemoval(
const Entity _entity)
const;
706 private:
bool CreateComponentImplementation(
733 private:
template<
typename ...ComponentTypeTs>
734 detail::View<ComponentTypeTs...> *FindView()
const;
751 private: detail::BaseView *AddView(
752 const detail::ComponentTypeKey &_types,
779 bool _full =
false)
const;
789 private:
void LockAddingEntitiesToViews(
bool _lock);
795 private:
bool LockAddingEntitiesToViews()
const;
800 friend class GuiRunner;
801 friend class SimulationRunner;
805 friend class NetworkManagerPrimary;
806 friend class NetworkManagerSecondary;
812 #include "ignition/gazebo/detail/EntityComponentManager.hh" 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:66
uint64_t ComponentTypeId
A unique identifier for a component type. A component type must be derived from components::BaseCompo...
Definition: Types.hh:90
class IGNITION_GAZEBO_HIDDEN EntityComponentManagerPrivate
Definition: EntityComponentManager.hh:51
#define IGN_DEPRECATED(version)
ComponentState
Possible states for a component.
Definition: Types.hh:65
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...