MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
MayaFlux::Nexus::Perception< T > Class Template Reference

A value of any type, read from the world through the perception context and handed to its targets. More...

#include <Perception.hpp>

+ Collaboration diagram for MayaFlux::Nexus::Perception< T >:

Public Types

using Source = std::function< T(const PerceptionContext &)>
 
using Target = std::function< void(const T &)>
 

Public Member Functions

Perception & add_target (Target target)
 Add a target.
 
void clear_targets ()
 Remove every target.
 
void invoke (const PerceptionContext &ctx) const
 Read the value using ctx and hand it to every target.
 
 Perception (Source source)
 
size_t target_count () const
 Number of targets currently added.
 

Private Attributes

Source m_source
 
std::vector< Target > m_targets
 

Detailed Description

template<typename T>
class MayaFlux::Nexus::Perception< T >

A value of any type, read from the world through the perception context and handed to its targets.

T is whatever is sensed: a scalar from a node or buffer, a vector, a struct of readings, a Tendency, a DataVariant. The source reads it, using the context when it needs position or neighbours. A target is any callable taking const T& and decides where it lands, such as a cell the perception function reads. On each invoke the source runs once and every target gets the value, in the order they were added.

How many targets a Perception may have is decided by its owner: a Sensor keeps one, an Agent keeps as many as are added.

Definition at line 44 of file Perception.hpp.


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