MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ add_perception()

template<typename T >
std::shared_ptr< Perception< T > > MayaFlux::Nexus::Agent::add_perception ( typename Perception< T >::Source  source)
inline

Add a perception of any type, with as many targets as are wanted.

Template Parameters
TType the source returns; whatever the targets take.
Parameters
sourceReads the value, using the perception context.
Returns
The perception, to add its targets with Perception::add_target.

Runs on every perception before the perception function, so the function can use what the targets received. Typed perceptions are runtime objects and are not part of encoded state.

Definition at line 258 of file Agent.hpp.

259 {
260 auto perception = std::make_shared<Perception<T>>(std::move(source));
261 m_perceptions.emplace_back(perception,
262 [perception](const PerceptionContext& ctx) { perception->invoke(ctx); });
263 return perception;
264 }
std::vector< std::pair< std::shared_ptr< void >, PerceptionFn > > m_perceptions
Definition Agent.hpp:398