BioDynaMo  v1.05.120-25dc9790
Classes | Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
bdm::AgentPointer< TAgent > Class Template Reference

#include <agent_pointer.h>

Collaboration diagram for bdm::AgentPointer< TAgent >:
[legend]

Classes

union  Data
 TODO. Replace with std::variant once we move to >= c++17. More...
 

Public Member Functions

 AgentPointer (const AgentUid &uid)
 
 AgentPointer (TAgent *agent)
 
 AgentPointer (std::nullptr_t)
 Allow AgentPointer<> ap = nullptr definitions. More...
 
 AgentPointer ()
 constructs an AgentPointer object representing a nullptr More...
 
 ~AgentPointer ()=default
 
uint64_t GetUidAsUint64 () const
 
AgentUid GetUid () const
 
bool operator== (std::nullptr_t) const
 
bool operator!= (std::nullptr_t) const
 
bool operator== (const AgentPointer &other) const
 
bool operator!= (const AgentPointer &other) const
 
template<typename TOtherAgent >
bool operator== (const TOtherAgent *other) const
 
template<typename TOtherAgent >
bool operator!= (const TOtherAgent *other) const
 
AgentPointeroperator= (std::nullptr_t)
 
TAgent * operator-> ()
 
const TAgent * operator-> () const
 
TAgent & operator* ()
 
const TAgent & operator* () const
 
 operator bool () const
 
 operator AgentPointer< Agent > () const
 
TAgent * Get ()
 
const TAgent * Get () const
 
bool operator< (const AgentPointer &other) const
 

Private Member Functions

template<typename TFrom , typename TTo >
std::enable_if< std::is_base_of< TFrom, TTo >::value, TTo * >::type Cast (TFrom *agent) const
 
template<typename TFrom , typename TTo >
std::enable_if<!std::is_base_of< TFrom, TTo >::value, TTo * >::type Cast (TFrom *agent) const
 
 BDM_CLASS_DEF_NV (AgentPointer, 3)
 

Private Attributes

Data d_ = {AgentUid()}
 

Friends

std::ostream & operator<< (std::ostream &str, const AgentPointer &agent_ptr)
 

Detailed Description

template<typename TAgent = Agent>
class bdm::AgentPointer< TAgent >

Agent pointer. Required to point to an agent throughout the whole simulation.
This class provides a common interface for different modes. See AgentPointerMode for more details. Benefit compared to AgentHandle is, that the compiler knows the type returned by Get and can therefore inline the code from the callee and perform optimizations.

Template Parameters
TAgentagent type

Definition at line 58 of file agent_pointer.h.

Constructor & Destructor Documentation

◆ AgentPointer() [1/4]

template<typename TAgent = Agent>
bdm::AgentPointer< TAgent >::AgentPointer ( const AgentUid uid)
inlineexplicit

Definition at line 60 of file agent_pointer.h.

◆ AgentPointer() [2/4]

template<typename TAgent = Agent>
bdm::AgentPointer< TAgent >::AgentPointer ( TAgent *  agent)
inlineexplicit

Definition at line 72 of file agent_pointer.h.

◆ AgentPointer() [3/4]

template<typename TAgent = Agent>
bdm::AgentPointer< TAgent >::AgentPointer ( std::nullptr_t  )
inline

Allow AgentPointer<> ap = nullptr definitions.

Definition at line 84 of file agent_pointer.h.

◆ AgentPointer() [4/4]

template<typename TAgent = Agent>
bdm::AgentPointer< TAgent >::AgentPointer ( )
inline

constructs an AgentPointer object representing a nullptr

Definition at line 87 of file agent_pointer.h.

◆ ~AgentPointer()

template<typename TAgent = Agent>
bdm::AgentPointer< TAgent >::~AgentPointer ( )
default

Member Function Documentation

◆ BDM_CLASS_DEF_NV()

template<typename TAgent = Agent>
bdm::AgentPointer< TAgent >::BDM_CLASS_DEF_NV ( AgentPointer< TAgent >  ,
 
)
private

◆ Cast() [1/2]

template<typename TAgent = Agent>
template<typename TFrom , typename TTo >
std::enable_if<std::is_base_of<TFrom, TTo>::value, TTo*>::type bdm::AgentPointer< TAgent >::Cast ( TFrom *  agent) const
inlineprivate

Definition at line 246 of file agent_pointer.h.

◆ Cast() [2/2]

template<typename TAgent = Agent>
template<typename TFrom , typename TTo >
std::enable_if<!std::is_base_of<TFrom, TTo>::value, TTo*>::type bdm::AgentPointer< TAgent >::Cast ( TFrom *  agent) const
inlineprivate

Definition at line 252 of file agent_pointer.h.

◆ Get() [1/2]

template<typename TAgent = Agent>
TAgent* bdm::AgentPointer< TAgent >::Get ( )
inline

Definition at line 224 of file agent_pointer.h.

◆ Get() [2/2]

template<typename TAgent = Agent>
const TAgent* bdm::AgentPointer< TAgent >::Get ( ) const
inline

Definition at line 226 of file agent_pointer.h.

◆ GetUid()

template<typename TAgent = Agent>
AgentUid bdm::AgentPointer< TAgent >::GetUid ( ) const
inline

Definition at line 102 of file agent_pointer.h.

◆ GetUidAsUint64()

template<typename TAgent = Agent>
uint64_t bdm::AgentPointer< TAgent >::GetUidAsUint64 ( ) const
inline

Definition at line 91 of file agent_pointer.h.

◆ operator AgentPointer< Agent >()

template<typename TAgent = Agent>
bdm::AgentPointer< TAgent >::operator AgentPointer< Agent > ( ) const
inline

Definition at line 216 of file agent_pointer.h.

◆ operator bool()

template<typename TAgent = Agent>
bdm::AgentPointer< TAgent >::operator bool ( ) const
inline

Definition at line 214 of file agent_pointer.h.

◆ operator!=() [1/3]

template<typename TAgent = Agent>
bool bdm::AgentPointer< TAgent >::operator!= ( const AgentPointer< TAgent > &  other) const
inline

Definition at line 135 of file agent_pointer.h.

◆ operator!=() [2/3]

template<typename TAgent = Agent>
template<typename TOtherAgent >
bool bdm::AgentPointer< TAgent >::operator!= ( const TOtherAgent *  other) const
inline

Definition at line 163 of file agent_pointer.h.

◆ operator!=() [3/3]

template<typename TAgent = Agent>
bool bdm::AgentPointer< TAgent >::operator!= ( std::nullptr_t  ) const
inline

Not equal operator that enables the following statement agent_ptr != nullptr;

Definition at line 125 of file agent_pointer.h.

◆ operator*() [1/2]

template<typename TAgent = Agent>
TAgent& bdm::AgentPointer< TAgent >::operator* ( )
inline

Definition at line 210 of file agent_pointer.h.

◆ operator*() [2/2]

template<typename TAgent = Agent>
const TAgent& bdm::AgentPointer< TAgent >::operator* ( ) const
inline

Definition at line 212 of file agent_pointer.h.

◆ operator->() [1/2]

template<typename TAgent = Agent>
TAgent* bdm::AgentPointer< TAgent >::operator-> ( )
inline

Definition at line 178 of file agent_pointer.h.

◆ operator->() [2/2]

template<typename TAgent = Agent>
const TAgent* bdm::AgentPointer< TAgent >::operator-> ( ) const
inline

Definition at line 191 of file agent_pointer.h.

◆ operator<()

template<typename TAgent = Agent>
bool bdm::AgentPointer< TAgent >::operator< ( const AgentPointer< TAgent > &  other) const
inline

Definition at line 228 of file agent_pointer.h.

◆ operator=()

template<typename TAgent = Agent>
AgentPointer& bdm::AgentPointer< TAgent >::operator= ( std::nullptr_t  )
inline

Assignment operator that changes the internal representation to nullptr. Makes the following statement possible agent_ptr = nullptr;

Definition at line 169 of file agent_pointer.h.

◆ operator==() [1/3]

template<typename TAgent = Agent>
bool bdm::AgentPointer< TAgent >::operator== ( const AgentPointer< TAgent > &  other) const
inline

Definition at line 127 of file agent_pointer.h.

◆ operator==() [2/3]

template<typename TAgent = Agent>
template<typename TOtherAgent >
bool bdm::AgentPointer< TAgent >::operator== ( const TOtherAgent *  other) const
inline

Definition at line 144 of file agent_pointer.h.

◆ operator==() [3/3]

template<typename TAgent = Agent>
bool bdm::AgentPointer< TAgent >::operator== ( std::nullptr_t  ) const
inline

Equals operator that enables the following statement agent_ptr == nullptr;

Definition at line 115 of file agent_pointer.h.

Friends And Related Function Documentation

◆ operator<<

template<typename TAgent = Agent>
std::ostream& operator<< ( std::ostream &  str,
const AgentPointer< TAgent > &  agent_ptr 
)
friend

Definition at line 204 of file agent_pointer.h.

Member Data Documentation

◆ d_

template<typename TAgent = Agent>
Data bdm::AgentPointer< TAgent >::d_ = {AgentUid()}
private

Definition at line 243 of file agent_pointer.h.


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