diff --git a/apps/ccam/cheatsheet.c b/apps/ccam/cheatsheet.c new file mode 100644 index 0000000..749478d --- /dev/null +++ b/apps/ccam/cheatsheet.c @@ -0,0 +1,92 @@ +#include "rosa/deluxe/DeluxeContext.hpp" + +std::unique_ptr C = DeluxeContext::create("Deluxe"); +// sensor +C->createSensor(name, + // lambda function + [](std::pair I) -> void { + // automatically pushes its value to the + // connected agent + }); + +// --------------------------------------------------------------------------- +// communication with 1 other agent +// --------------------------------------------------------------------------- +// Handlerfunctions have to be the corresponding std::functions + +// singe input singe output +C->createAgent(Name, + Handlerfunction( + // lambda function + [](std::pair I) -> optional { + //... + // return {value}; + })); + +// multi input single output +C->createAgent(Name, + Handlerfunction( + // lambda function + [](std::pair, bool> I) + -> optional> { + //... + // DeluxeTuple output(value); + // return {output}; + })); + +// single input multi output +C->createAgent(Name, + Handlerfunction( + // lambda function + [](std::pair, bool> I) + -> optional> { + //... + // DeluxeTuple + // output(value1,value2); + // return {output}; + })); + +// multi in/out and handles results from master +C->createAgent( + Name, + // Master-input handler. + MasterHandlerfunction( + // lambda function + [](std::pair, bool> I) + -> void { // you can again return something to the master but i + // don't know at the moment the changes that would cause + // + //.. + }), + // input handler. + Handlerfunction( + // lambda function + [](std::pair, bool> I) + -> optional> { + //... + // DeluxeTuple + // output(value1,value2); + // return {output}; + })); + +// --------------------------------------------------------------------------- +// communication with n other agent +// --------------------------------------------------------------------------- + +// I don't know how it reacts if input 1 is a DeluxeTuple and input 2 is just a +// value I'm just using all with DeluxeTuples +C->createAgent( + Name, Handlerfunction( + // lambda function + [](std::pair, bool> I0, + std::pair, bool> I1, + std::pair, bool> I2, + ...) -> std::tuple>, + Optional>, + Optional>, + Optional>, ...>; + { + // ... + // return {{for_master}, {for_slave_1}, {for_slave_1}, + // {for_slave_1}}; + })); \ No newline at end of file