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

◆ operator>>() [3/4]

void MayaFlux::Kriya::operator>> ( std::shared_ptr< Nodes::Node node,
const NodeTimeSpec time_op 
)

Activates a processing node for a specific duration.

Grants the stream operator access to private members.

Parameters
nodeThe processing node to activate
time_opThe NodeTimeSpec specifying the duration

This operator overload implements the node >> Time(seconds) syntax, which activates a processing node for a specific duration. It's a more expressive way of representing timed activation compared to traditional function calls.

Example usage:

// Activate a processing node for 2 seconds
process_node >> Time(2.0);
NodeTimeSpec Time(double seconds)
Definition Operators.cpp:52

This is part of a broader pattern of using operator overloading to create a domain-specific language for computational flow programming within C++.

Definition at line 29 of file Operators.cpp.

30{
31 auto timer = std::make_shared<NodeTimer>(time_op.m_scheduler, time_op.m_graph_manager);
32
33 if (time_op.has_explicit_channels()) {
34 timer->play_for(node, time_op.get_seconds(), time_op.get_channels());
35 } else {
36 timer->play_for(node, time_op.get_seconds());
37 }
38
39 static std::vector<std::shared_ptr<NodeTimer>> active_timers;
40 active_timers.push_back(timer);
41
42 if (active_timers.size() > MayaFlux::Config::get_node_config().callback_cache_size) {
43 active_timers.erase(
44 std::remove_if(active_timers.begin(), active_timers.end(),
45 [](const std::shared_ptr<NodeTimer>& t) {
46 return !t->is_active();
47 }),
48 active_timers.end());
49 }
50}
bool has_explicit_channels() const
Checks if explicit channels were specified.
Definition Operators.hpp:73
Vruta::TaskScheduler & m_scheduler
Reference to the scheduler that will manage timing.
Definition Operators.hpp:98
Nodes::NodeGraphManager & m_graph_manager
Reference to the graph manager that will manage node connections.
double get_seconds() const
Gets the duration of this operation.
Definition Operators.hpp:63
const std::vector< uint32_t > & get_channels() const
Gets the list of channels to activate.
Definition Operators.hpp:82
NodeConfig & get_node_config()
Definition Config.cpp:44