template.cpp 1.68 KB
Newer Older
Savva Golubitsky's avatar
Savva Golubitsky committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
#include <libtools.h>
#include <anymap.h>
#include <thread>

typedef std::function<int(com::Anymap)> IntFunc;
typedef std::function<bool(com::Anymap)> BoolFunc;
typedef std::function<std::list<bool>(com::Anymap)> BoolListFunc;  

IntFunc LoadEntry(std::string lib, std::string func) {
    DllHandle handler;
    return com::lib::loadFunction<int (com::Anymap), DllHandle>(lib.c_str(), func.c_str(), handler);
}

BoolFunc LoadPred(std::string lib, std::string func) {
    DllHandle handler;
    return com::lib::loadFunction<int (com::Anymap), DllHandle>(lib.c_str(), func.c_str(), handler);
}

BoolListFunc LoadSelector(std::string lib, std::string func){
    DllHandle handler;
    return com::lib::loadFunction<std::list<bool> (com::Anymap), DllHandle>(lib.c_str(), func.c_str(), handler);
}


int main(int argc, char const *argv[])
{
    auto data = com::Anymap();
    auto predFunc = LoadPred("libprinters", "ReturnTrue"); 
    auto entrFunc = LoadEntry("libprinters", "PrintHello");
    auto selector = LoadSelector("libprinters", "ThreeTrue");
    std::list<bool> ST_selector_val;
    if (!predFunc(data)) {
        std::cout<<"Predicate returned FALSE on state ${}\n"; 
        goto TERM;
    }
    entrFunc(data);

SELECTOR:
    ST_selector_val = selector(data);
    for (int i=0; i<ST_selector_val.size(); i++) {
        std::thread thr();
        goto TERM;
        //if (ST_selector_val.begin+0) {
        //    ST_selector_val.begin+0 = !ST_selector_val.begin+0;
        //    goto TERM;
        //}
        //if (ST_selector_val.begin+1) {
        //    ST_selector_val.begin+1 = !ST_selector_val.begin+1;
        //    goto SELECTOR;
        //}
    }



TERM:
    std::cout<<"Termination!\n"; 
    return 0;
}