Utopia  2
Framework for studying models of complex & adaptive systems.
Public Types | Public Member Functions | Protected Member Functions | Private Attributes | Friends | List of all members
Utopia::Agent< Traits, Space, std::enable_if_t< Traits::mode==Update::sync > > Class Template Reference

Agent Specialisation for synchronous update. More...

#include <agent.hh>

Inheritance diagram for Utopia::Agent< Traits, Space, std::enable_if_t< Traits::mode==Update::sync > >:
Inheritance graph
[legend]
Collaboration diagram for Utopia::Agent< Traits, Space, std::enable_if_t< Traits::mode==Update::sync > >:
Collaboration graph
[legend]

Public Types

using Self = Agent< Traits, Space >
 The type of this agent. More...
 
using State = typename Traits::State
 The type of the state. More...
 
using Position = typename Space::SpaceVec
 The type of the position vector. More...
 
- Public Types inherited from Utopia::Entity< Agent< Traits, Space >, Traits >
using Traits = Traits
 The traits of this entity. More...
 
using Self = Entity< Agent< Traits, Space >, Traits >
 The type of this entity. More...
 
using State = typename Traits::State
 The type of the state of this entity. More...
 
using Tags = typename Traits::Tags
 The tags associated with this entity. More...
 
using CustomLinkContainers = typename Traits::template CustomLinks< EntityContainer< Agent< Traits, Space > > >
 A construct that has as members containers for custom-linked entities. More...
 

Public Member Functions

 Agent (const IndexType id, const State &initial_state, const Position &initial_pos)
 Construct an agent. More...
 
const Positionposition () const
 Return the current position of the agent. More...
 
const Positionposition_new () const
 Return the position buffer of the agent. More...
 
void update ()
 Update the position and the state. More...
 
- Public Member Functions inherited from Utopia::Entity< Agent< Traits, Space >, Traits >
 Entity (const IndexType id, const State initial_state)
 Construct an entity. More...
 
const IndexTypeid () const
 Return const reference to entity ID. More...
 
CustomLinkContainerscustom_links ()
 Return reference to custom link containers. More...
 
const CustomLinkContainerscustom_links () const
 Return const reference to custom link containers. More...
 

Protected Member Functions

void set_pos (const Position &pos)
 Set the position buffer of the (synchronously updated) agent. More...
 

Private Attributes

Position _pos
 The current position of the agent. More...
 
Position _pos_new
 The position buffer for the synchronous position update. More...
 

Friends

template<class T , class M >
class AgentManager
 Make the agent manager a (template) friend. More...
 

Additional Inherited Members

- Static Public Attributes inherited from Utopia::Entity< Agent< Traits, Space >, Traits >
static constexpr Update mode
 Whether this entity is updated synchronously. More...
 

Detailed Description

template<typename Traits, typename Space>
class Utopia::Agent< Traits, Space, std::enable_if_t< Traits::mode==Update::sync > >

Agent Specialisation for synchronous update.

Member Typedef Documentation

◆ Position

template<typename Traits , typename Space >
using Utopia::Agent< Traits, Space, std::enable_if_t< Traits::mode==Update::sync > >::Position = typename Space::SpaceVec

The type of the position vector.

◆ Self

template<typename Traits , typename Space >
using Utopia::Agent< Traits, Space, std::enable_if_t< Traits::mode==Update::sync > >::Self = Agent<Traits, Space>

The type of this agent.

◆ State

template<typename Traits , typename Space >
using Utopia::Agent< Traits, Space, std::enable_if_t< Traits::mode==Update::sync > >::State = typename Traits::State

The type of the state.

Constructor & Destructor Documentation

◆ Agent()

template<typename Traits , typename Space >
Utopia::Agent< Traits, Space, std::enable_if_t< Traits::mode==Update::sync > >::Agent ( const IndexType  id,
const State initial_state,
const Position initial_pos 
)
inline

Construct an agent.

Parameters
idThe id of this agent, ideally unique
initial_stateThe initial state
initial_posThe initial position

Member Function Documentation

◆ position()

template<typename Traits , typename Space >
const Position& Utopia::Agent< Traits, Space, std::enable_if_t< Traits::mode==Update::sync > >::position ( ) const
inline

Return the current position of the agent.

◆ position_new()

template<typename Traits , typename Space >
const Position& Utopia::Agent< Traits, Space, std::enable_if_t< Traits::mode==Update::sync > >::position_new ( ) const
inline

Return the position buffer of the agent.

◆ set_pos()

template<typename Traits , typename Space >
void Utopia::Agent< Traits, Space, std::enable_if_t< Traits::mode==Update::sync > >::set_pos ( const Position pos)
inlineprotected

Set the position buffer of the (synchronously updated) agent.

This function allows befriended classes to set the position of this agent.

Note
No check is carried out whether the new position is valid; this needs to happen in the construct that is aware of the space the agent resides in, i.e.: Utopia::AgentManager.
Parameters
posThe new position of the agent

◆ update()

template<typename Traits , typename Space >
void Utopia::Agent< Traits, Space, std::enable_if_t< Traits::mode==Update::sync > >::update ( )
inline

Update the position and the state.

Writes the buffer of state and position to the current state and position. This is necessary for the synchronous update mode only.

Friends And Related Function Documentation

◆ AgentManager

template<typename Traits , typename Space >
template<class T , class M >
friend class AgentManager
friend

Make the agent manager a (template) friend.

Member Data Documentation

◆ _pos

template<typename Traits , typename Space >
Position Utopia::Agent< Traits, Space, std::enable_if_t< Traits::mode==Update::sync > >::_pos
private

The current position of the agent.

◆ _pos_new

template<typename Traits , typename Space >
Position Utopia::Agent< Traits, Space, std::enable_if_t< Traits::mode==Update::sync > >::_pos_new
private

The position buffer for the synchronous position update.


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