]> git.sesse.net Git - casparcg/blob - dependencies64/RxCpp/README.md
[general] Abstracted the concept of a key only frame so that readers of const_frame...
[casparcg] / dependencies64 / RxCpp / README.md
1 [![Build Status](https://travis-ci.org/Reactive-Extensions/RxCpp.png)](https://travis-ci.org/Reactive-Extensions/RxCpp)
2
3 # Reactive Extensions:
4
5 * Rx.NET: The Reactive Extensions (Rx) is a library for composing asynchronous and event-based programs using observable sequences and LINQ-style query operators.
6 * RxJS: The Reactive Extensions for JavaScript (RxJS) is a library for composing asynchronous and event-based programs using observable sequences and LINQ-style query operators in JavaScript which can target both the browser and Node.js.
7 * RxCpp: The Reactive Extensions for Native (RxC) is a library for composing asynchronous and event-based programs using observable sequences and LINQ-style query operators in both C and C++.
8
9 # Interactive Extensions
10 * Ix: The Interactive Extensions (Ix) is a .NET library which extends LINQ to Objects to provide many of the operators available in Rx but targeted for IEnumerable<T>.
11 * IxJS: An implementation of LINQ to Objects and the Interactive Extensions (Ix) in JavaScript.
12 * Ix++: An implantation of LINQ for Native Developers in C++
13
14 # Applications:
15 * Tx: a set of code samples showing how to use LINQ to events, such as real-time standing queries and queries on past history from trace and log files, which targets ETW, Windows Event Logs and SQL Server Extended Events.
16 * LINQ2Charts: an example for Rx bindings.  Similar to existing APIs like LINQ to XML, it allows developers to use LINQ to create/change/update charts in an easy way and avoid having to deal with XML or other underneath data structures. We would love to see more Rx bindings like this one.
17
18 #Building RxCpp
19
20 * RxCpp is regularly tested on OSX and Windows.
21 * RxCpp is regularly built with Clang and VC
22 * RxCpp depends on the latest compiler releases.
23 * RxCpp has an experimental build with gcc.
24
25 RxCpp uses CMake to create build files for several platforms and IDE's
26
27 ###Ide builds
28 ####XCode
29 ```
30 mkdir projects/build
31 cd projects/build
32 cmake -G"Xcode" ../CMake -B.
33 ```
34
35 ####Visual Studio 13
36 ```
37 mkdir projects\build
38 cd projects\build
39 cmake -G"Visual Studio 12" ..\CMake -B.
40 ```
41 * Note: open in VC2013 and upgrade to the 2013 toolset
42
43 ###makefile builds
44
45 ####OSX
46 ```
47 mkdir projects/build
48 cd projects/build
49 cmake -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=RelWithDebInfo -B. ../CMake
50 make
51 ```
52
53 ####Linux --- Clang
54 ```
55 mkdir projects/build
56 cd projects/build
57 cmake -G"Unix Makefiles" -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=RelWithDebInfo -B. ../CMake
58 make
59 ```
60
61 ####Linux --- GCC
62 ```
63 mkdir projects/build
64 cd projects/build
65 cmake -G"Unix Makefiles" -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCMAKE_BUILD_TYPE=RelWithDebInfo -B. ../CMake
66 make
67 ```
68
69 ####Windows
70 ```
71 mkdir projects\build
72 cd projects\build
73 cmake -G"NMake Makefiles" -DCMAKE_BUILD_TYPE=RelWithDebInfo -B. ..\CMake
74 nmake
75 ```
76
77 The build only produces a test binary.
78
79 #Running tests
80
81 * You can use the CMake test runner ```ctest```
82 * You can run the test binary directly ```rxcppv2_test```
83 * Tests can be selected by name or tag
84 Example of by-tag
85
86 ```rxcppv2_test [perf]```
87
88 #Using RxCpp
89 Add ```Rx/v2/src``` to the include paths
90
91 ```
92 #include "rxcpp/rx.hpp"
93 // create alias' to simplify code
94 // these are owned by the user so that
95 // conflicts can be managed by the user.
96 namespace rx=rxcpp;
97 namespace rxu=rxcpp::util;
98 namespace rxsc=rxcpp::schedulers;
99 namespace rxsub=rxcpp::subjects;
100
101 // At this time, RxCpp will fail to compile if the contents
102 // of the std namespace are merged into the global namespace
103 // DO NOT USE: 'using namespace std;'
104
105 #ifdef UNICODE
106 int wmain(int argc, wchar_t** argv)
107 #else
108 int main(int argc, char** argv)
109 #endif
110 {
111     int c = 0;
112
113     auto triples =
114         rx::observable<>::range(1)
115             .concat_map(
116                 [&c](int z){
117                     return rx::observable<>::range(1, z)
118                         .concat_map(
119                             [=, &c](int x){
120                                 return rx::observable<>::range(x, z)
121                                     .filter([=, &c](int y){++c; return x*x + y*y == z*z;})
122                                     .map([=](int y){return std::make_tuple(x, y, z);})
123                                     // forget type to workaround lambda deduction bug on msvc 2013
124                                     .as_dynamic();},
125                             [](int x, std::tuple<int,int,int> triplet){return triplet;})
126                         // forget type to workaround lambda deduction bug on msvc 2013
127                         .as_dynamic();},
128                 [](int z, std::tuple<int,int,int> triplet){return triplet;});
129
130     int ct = 0;
131
132     triples
133         .take(100)
134         .subscribe(rxu::apply_to([&ct](int x,int y,int z){
135             ++ct;
136         }));
137
138     std::cout << "concat_map pythagorian range : " << c << " filtered to, " << ct << " triplets" << std::endl;
139
140     return 0;
141 }
142 ```
143
144 #Contributing Code
145
146 Before submitting a feature or substantial code contribution please  discuss it with the team and ensure it follows the product roadmap. Note that all code submissions will be rigorously reviewed and tested by the Rx Team, and only those that meet an extremely high bar for both quality and design/roadmap appropriateness will be merged into the source.
147
148 You will need to submit a  Contributor License Agreement form before submitting your pull request. This needs to only be done once for any Microsoft OSS project. Fill in the [Contributor License Agreement](https://cla.msopentech.com/) (CLA).