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

◆ operator>>

void operator>> ( std::shared_ptr< Nodes::Node ,
const NodeTimeSpec  
)
friend

Grants the stream operator access to private members.

This friendship declaration allows the stream operator to access the private members of NodeTimeSpec, which is necessary for implementing the node >> time syntax.

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}
NodeConfig & get_node_config()
Definition Config.cpp:44