gz/sim/EntityComponentManager.hh
void Each(typename identity< std::function< bool(const Entity &_entity, const ComponentTypeTs *...)>>::type _f) const
Get all entities which contain given component types, as well as the components. Note that an entity ...
bool EntityMatches(Entity _entity, const std::set< ComponentTypeId > &_types) const
Get whether an entity has all the given component types.
std::unordered_set< Entity > Descendants(Entity _entity) const
Get all entities which are descendants of a given entity, including the entity itself.
uint64_t Entity
An Entity identifies a single object in simulation such as a model, link, or light....
Definition: gz/sim/Entity.hh:59
bool RemoveComponent(const Entity _entity, const ComponentKey &_key)
Remove a component from an entity based on a key.
This library is part of the Ignition Robotics project.
The EntityComponentManager constructs, deletes, and returns components and entities....
Definition: gz/sim/EntityComponentManager.hh:65
bool HasOneTimeComponentChanges() const
Get whether there are one-time component changes. These changes do not happen frequently and should b...
void EachRemoved(typename identity< std::function< bool(const Entity &_entity, const ComponentTypeTs *...)>>::type _f) const
Get all entities which contain given component types and are about to be removed, as well as the comp...
STL class.
Entity EntityByComponents(const ComponentTypeTs &..._desiredComponents) const
Get an entity which matches the value of all the given components. For example, the following will re...
friend class SimulationRunner
Definition: gz/sim/EntityComponentManager.hh:761
Component< Entity, class ParentEntityTag > ParentEntity
This component holds an entity's parent entity.
Definition: gz/sim/components/ParentEntity.hh:41
const ComponentTypeT * First() const
The first component instance of the specified type.
std::unordered_set< ComponentTypeId > ComponentTypesWithPeriodicChanges() const
Get the components types that are marked as periodic changes.
std::vector< Entity > ChildrenByComponents(Entity _parent, const ComponentTypeTs &..._desiredComponents) const
Get all entities which match the value of all the given components and are immediate children of a gi...
size_t EntityCount() const
Get the number of entities on the server.
void SetState(const msgs::SerializedState &_stateMsg)
Set the absolute state of the ECM from a serialized message. Entities / components that are in the ne...
void ClearNewlyCreatedEntities()
Clear the list of newly added entities so that a call to EachAdded after this will have no entities t...
Entity ParentEntity(const Entity _entity) const
Get the first parent of the given entity.
bool EntityHasComponentType(const Entity _entity, const ComponentTypeId &_typeId) const
Check whether an entity has a specific component type.
bool EntityHasComponent(const Entity _entity, const ComponentKey &_key) const
Check whether an entity has a specific component.
std::optional< typename ComponentTypeT::Type > ComponentData(const Entity _entity) const
Get the data from a component.
bool SetComponentData(const Entity _entity, const typename ComponentTypeT::Type &_data)
Set the data from a component.
msgs::SerializedState ChangedState() const
Get a message with the serialized state of all entities and components that are changing in the curre...
std::unordered_set< ComponentTypeId > ComponentTypes(Entity _entity) const
Get the type IDs of all components attached to an entity.
bool SetParentEntity(const Entity _child, const Entity _parent)
Set the parent of an entity.
ComponentState
Possible states for a component.
Definition: include/gz/sim/Types.hh:64
ComponentKey CreateComponent(const Entity _entity, const ComponentTypeT &_data)
Create a component of a particular type. This will copy the _data parameter.
std::vector< Entity > EntitiesByComponents(const ComponentTypeTs &..._desiredComponents) const
Get all entities which match the value of all the given components. For example, the following will r...
const ComponentTypeT * Component(const Entity _entity) const
Get a component assigned to an entity based on a component type.
Base class for all components.
Definition: gz/sim/components/Component.hh:230
STL class.
void SetEntityCreateOffset(uint64_t _offset)
All future entities will have an id that starts at _offset. This can be used to avoid entity id colli...
bool HasEntity(const Entity _entity) const
Get whether an Entity exists.
EntityComponentManager()
Constructor.
void RequestRemoveEntities()
Request to remove all entities. This will insert the request into a queue. The queue is processed tow...
@ OneTimeChange
Component value has suffered a one-time change. This indicates to systems that this change must be pr...
int ComponentId
A unique identifier for a component instance. The uniqueness of a ComponentId is scoped to the compon...
Definition: include/gz/sim/Types.hh:82
~EntityComponentManager()
Destructor.
void RequestRemoveEntity(const Entity _entity, bool _recursive=true)
Request an entity deletion. This will insert the request into a queue. The queue is processed toward ...
friend class NetworkManagerSecondary
Definition: gz/sim/EntityComponentManager.hh:766
bool HasComponentType(const ComponentTypeId _typeId) const
Get whether a component type has ever been created.
void SetAllComponentsUnchanged()
Mark all components as not changed.
void SetChanged(const Entity _entity, const ComponentTypeId _type, gz::sim::ComponentState _c=ComponentState::OneTimeChange)
Set the changed state of a component.
const EntityGraph & Entities() const
Get a graph with all the entities. Entities are vertices and edges point from parent to children.
static void ForEach(Function _f, const ComponentTypeTs &... _components)
Call a function for each parameter in a pack.
msgs::SerializedState State(const std::unordered_set< Entity > &_entities={}, const std::unordered_set< ComponentTypeId > &_types={}) const
Get a message with the serialized state of the given entities and components.
Responsible for running GUI systems as new states are received from the backend.
Definition: gz/sim/gui/GuiRunner.hh:40
class IGNITION_GAZEBO_HIDDEN EntityComponentManagerPrivate
Definition: gz/sim/EntityComponentManager.hh:50
bool HasNewEntities() const
Get whether there are new entities.
friend class NetworkManagerPrimary
Definition: gz/sim/EntityComponentManager.hh:765
ComponentTypeT * ComponentDefault(Entity _entity, const typename ComponentTypeT::Type &_default=typename ComponentTypeT::Type())
Get a mutable component assigned to an entity based on a component type. If the component doesn't exi...
gz::sim::ComponentState ComponentState(const Entity _entity, const ComponentTypeId _typeId) const
Get a component's state.
bool HasEntitiesMarkedForRemoval() const
Get whether there are any entities marked to be removed.
void ProcessRemoveEntityRequests()
Process all entity remove requests. This will remove entities and their components....
uint64_t ComponentTypeId
A unique identifier for a component type. A component type must be derived from components::BaseCompo...
Definition: include/gz/sim/Types.hh:87
void EachNew(typename identity< std::function< bool(const Entity &_entity, ComponentTypeTs *...)>>::type _f)
Get all newly created entities which contain given component types, as well as the components....
STL class.
void RebuildViews()
Rebuild all the views. This could be an expensive operation.
void EachNoCache(typename identity< std::function< bool(const Entity &_entity, const ComponentTypeTs *...)>>::type _f) const
A version of Each() that doesn't use a cache. The cached version, Each(), is preferred....