O'Reilly logo

C++ Reactive Programming by Peter Abraham, Praseed Pai

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The Streamulus library and its programming model

The Streamulus library, from Irit Katiel, is a library that makes the programming of event Streams easier with a programming model, which implements domain-specific embedded language (DSEL). To understand the programming model, let's inspect a program that Streams data into a class that aggregates received data:

#include "Streamulus.h" 
#include <ioStream> 
using namespace std; 
using namespace Streamulus; 
struct print {     
    static double temp; 
    print() { } 
    template<typename T> 
    T operator()(const T& value) const {  
        print::temp += value; 
        std::cout << print::temp << std::endl;  return value; 
     } 
}; 
double print::temp = 0; 

The preceding functor just accumulates the value passed into a static variable. For ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required