Handling Custom Returns in C++¶
The C++ API allows users to return custom objects from their workflows.
To do so, the user must create a functor object which overloads the operator() function. Lemon provides two implementations for C++ streams (such as std::cout) and associative arrays (such as std::map). These two examples are given below to guide users in the creation of their own custom functors for new types. It is recommended that the user use C++ templates to obtain the most flexible implementations.
Functor to stream workflow results to an ostream object
This is a template functor which streams workflow results to a
collector. This class is typically used to stream text results from workflows to the
std::coutobject. Any class which derives from
Construct a print_combine which streams results to
This contructor will create a
print_combineobject which streams results to
collector. This argument must derive from the
std::ostreamclass and therefore provide an overload to the
<<operator. Common examples of
std::coutand friends. All workflow results are streamed to the
collectafter all entries have been evaluated.
collector: An object for each workflow objects will be streamed to
Functor to combine the results of a workflow into a map
This is a template functor which opens combines the results of a workflow into a single map object. Use this class only when the work flow returns a map oject or other type of associative array.
Construct a map_combine class which fills the
This constructor will copy all results to the
collectorobject. This operation is performed when the workflow completes for all entries.
collector: A map like object to store results in.
This feature is under current development for the Python API, but is not yet supported. Instead, users should store the results of their workflows in the self object and rely on the finalize function to analyze the result.