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:58
#define IGN_DEPRECATED(version)
bool RemoveComponent(const Entity _entity, const ComponentKey &_key)
Remove a component from an entity based on a key.
This library is part of the Gazebo project.
STL class.
The EntityComponentManager constructs, deletes, and returns components and entities....
Definition: gz/sim/EntityComponentManager.hh:66
bool HasOneTimeComponentChanges() const
Get whether there are one-time component changes. These changes do not happen frequently and should b...
void PinEntity(const Entity _entity, bool _recursive=true)
Prevent an entity and optionally its children from being removed.
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:837
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. This function is now deprecated,...
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...
bool HasRemovedComponents() const
Return true if there are components marked for removal.
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...
friend class GuiRunner
Definition: gz/sim/EntityComponentManager.hh:836
Entity ParentEntity(const Entity _entity) const
Get the first parent of the given entity.
void UpdatePeriodicChangeCache(std::unordered_map< ComponentTypeId, std::unordered_set< Entity >> &) const
Get a cache of components with periodic changes.
void UnpinAllEntities()
Allow all previously pinned entities to be removed.
bool EntityHasComponentType(const Entity _entity, const ComponentTypeId &_typeId) const
Check whether an entity has a specific component type.
ComponentTypeT * CreateComponent(const Entity _entity, const ComponentTypeT &_data)
Create a component of a particular type. This will copy the _data parameter.
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:65
Entity Clone(Entity _entity, Entity _parent, const std::string &_name, bool _allowRename)
Clone an entity and its components. If the entity has any child entities, they will also be cloned....
bool HasPeriodicComponentChanges() const
Get whether there are periodic component changes. These changes may happen frequently and are process...
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.
void PeriodicStateFromCache(msgs::SerializedStateMap &_state, const std::unordered_map< ComponentTypeId, std::unordered_set< Entity >> &_cache) const
Populate a message with relevant changes to the state given a periodic change cache.
Base class for all components.
Definition: gz/sim/components/Component.hh:230
friend class SystemManager
Definition: gz/sim/EntityComponentManager.hh:840
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...
~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:845
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.
void ClearRemovedComponents()
Clear the list of removed components so that a call to RemoveComponent doesn't make the list grow ind...
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.
class IGNITION_GAZEBO_HIDDEN EntityComponentManagerPrivate
Definition: gz/sim/EntityComponentManager.hh:51
bool HasNewEntities() const
Get whether there are new entities.
void UnpinEntity(const Entity _entity, bool _recursive=true)
Allow an entity, and optionally its children, previously marked as pinned to be removed.
friend class NetworkManagerPrimary
Definition: gz/sim/EntityComponentManager.hh:844
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:90
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.
STL class.
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....