Atoms Crowd  4.1.0
Atoms::AgentsPool Class Reference

Agents pool. More...

#include <AgentsPool.h>

Public Member Functions

std::vector< Agent * > reserve (unsigned int numAgents, const std::string &affinity="")
 Creates the given number of agents and returns them. More...
 
void clear ()
 Clears all the agents.
 
void reset ()
 Reset the map and move the agents to the cache.
 
void clearCache ()
 Delete the cache.
 
Agentagent (unsigned int id)
 Gets an agent by its global id. More...
 
std::vector< int > agentIds ()
 Gets all agent global ids.
 
void deleteAgent (unsigned int id)
 Delete an agent.
 
void deleteAgents (const std::vector< unsigned int > &ids)
 Delete agents.
 
size_t numAgents () const
 Gets the number of agents.
 
AtomsPtr< AgentcreateEmptyAgent () const
 Create and agent without saving it inside the pool.
 
void setNumAgentsOffset (unsigned int offset)
 
unsigned int numAgentsOffset () const
 

Static Public Member Functions

static AgentsPoolinstance ()
 Singleton access.
 

Detailed Description

Agents pool.

This is the container of all the agents of your simulation. Every agent is generated by this class and a pointer to the new agents is returned. The agents must be created and destroyed by this class only! Every agent created has a unique id stored in the "id" metadata.

Member Function Documentation

◆ agent()

Agent* Atoms::AgentsPool::agent ( unsigned int  id)

Gets an agent by its global id.

Parameters
idAgent global id

◆ reserve()

std::vector<Agent*> Atoms::AgentsPool::reserve ( unsigned int  numAgents,
const std::string &  affinity = "" 
)

Creates the given number of agents and returns them.

Parameters
numAgentsNumber of agents to create
Returns
Vector of pointers to the new agents

The documentation for this class was generated from the following file: