17 #ifndef AWALI_DYN_LOADING_HANDLER_HH 
   18 #define AWALI_DYN_LOADING_HANDLER_HH 
   22 #include <unordered_map> 
   38       void* 
get_handler(
const std::string name, 
const std::string group,
 
   39                         const std::string& static_context);
 
   41       void* 
get_handler(
const std::string name, 
const std::string group,
 
   42                         const std::string& static_context1,
 
   43                         const std::string& static_context2);
 
   45       void* 
get_handler(
const std::string name, 
const std::string& static_context);
 
   56     template<
typename RET_T, 
typename... ARGS_T>
 
   58     call0(std::string name, std::string group, std::string stat_ctx,
 
   61         typedef RET_T (*bridge_t)(ARGS_T...);
 
   62         bridge_t bridge = (bridge_t) 
get_handler(name, group, stat_ctx);
 
   63         return bridge(args...);
 
   67     template<
typename RET_T, 
typename ARG1_T, 
typename... ARGS_T>
 
   69     call1(std::string name, std::string group,
 
   70       ARG1_T arg1, ARGS_T... args)
 
   72       std::string stat_ctx = arg1->get_context()->sname();
 
   73       typedef RET_T (*bridge_t)(ARG1_T, ARGS_T...);
 
   74       bridge_t bridge = (bridge_t) 
get_handler(name, group, stat_ctx);
 
   75       return bridge(arg1, args...);
 
   79     template<
typename RET_T, 
typename ARG2_T, 
typename ARG1_T, 
 
   82     call2(std::string name, std::string group,
 
   83       ARG1_T arg1, ARG2_T arg2, ARGS_T... args)
 
   85       std::string stat_ctx1 = arg1->get_context()->sname();
 
   86       std::string stat_ctx2 = arg2->get_context()->sname();
 
   87       typedef RET_T (*bridge_t)(ARG1_T, ARG2_T, ARGS_T...);
 
   89       = (bridge_t) 
get_handler(name, group, stat_ctx1, stat_ctx2);
 
   90       return bridge(arg1, arg2, args...);
 
  101       template<
typename RET_T, 
typename ARG1_T>
 
  103       call_0_1(std::string name, std::string group, std::string stat_ctx,
 
  105           RET_T(*fct)(ARG1_T) = 
nullptr) 
 
  107         typedef RET_T (*bridge_t)(ARG1_T);
 
  108         bridge_t bridge = (bridge_t) 
get_handler(name, group, stat_ctx);
 
  109         return bridge(other1);
 
  112       template<
typename RET_T, 
typename ARG1_T, 
typename ARG2_T>
 
  114       call_0_2(std::string name, std::string group, std::string stat_ctx,
 
  115           ARG1_T other1, ARG2_T other2,
 
  116           RET_T(*fct)(ARG1_T, ARG2_T) = 
nullptr) 
 
  118         typedef RET_T (*bridge_t)(ARG1_T, ARG2_T);
 
  119         bridge_t bridge = (bridge_t) 
get_handler(name, group, stat_ctx);
 
  120         return bridge(other1, other2);
 
  123       template<
typename RET_T, 
typename ARG1_T, 
typename ARG2_T, 
typename 
  126       call_0_3(std::string name, std::string group, std::string stat_ctx,
 
  127           ARG1_T other1, ARG2_T other2, ARG3_T other3,
 
  128           RET_T(*fct)(ARG1_T, ARG2_T, ARG3_T) = 
nullptr) 
 
  130         typedef RET_T (*bridge_t)(ARG1_T, ARG2_T, ARG3_T);
 
  131         bridge_t bridge = (bridge_t) 
get_handler(name, group, stat_ctx);
 
  132         return bridge(other1, other2, other3);
 
  135       template<
typename RET_T, 
typename ARG1_T>
 
  137       call_1_0(std::string name, std::string group, ARG1_T aut,
 
  138           RET_T(*fct)(ARG1_T) = 
nullptr) 
 
  140         std::string stat_ctx = aut->get_context()->sname();
 
  141         typedef RET_T (*bridge_t)(ARG1_T);
 
  142         bridge_t bridge = (bridge_t) 
get_handler(name, group, stat_ctx);
 
  147       template<
typename RET_T, 
typename ARG1_T, 
typename ARG2_T>
 
  149       call_1_1(std::string name, std::string group, ARG1_T aut1, 
 
  150           ARG2_T other1, RET_T(*fct)(ARG1_T, ARG2_T) = 
nullptr) 
 
  152         std::string stat_ctx = aut1->get_context()->sname();
 
  153         typedef RET_T (*bridge_t)(ARG1_T,ARG2_T);
 
  154         bridge_t bridge = (bridge_t) 
get_handler(name, group, stat_ctx);
 
  155         return bridge(aut1, other1);
 
  158       template<
typename RET_T, 
typename ARG1_T, 
typename ARG2_T, 
 
  161       call_1_2(std::string name, std::string group, ARG1_T aut1, 
 
  162           ARG2_T other1, ARG3_T other2, RET_T(*fct)(ARG1_T, ARG2_T, ARG3_T) = 
nullptr) 
 
  164         std::string stat_ctx = aut1->get_context()->sname();
 
  165         typedef RET_T (*bridge_t)(ARG1_T,ARG2_T,ARG3_T);
 
  166         bridge_t bridge = (bridge_t) 
get_handler(name, group, stat_ctx);
 
  167         return bridge(aut1, other1, other2);
 
  170       template<
typename RET_T, 
typename ARG1_T, 
typename ARG2_T, 
 
  171           typename ARG3_T, 
typename ARG4_T>
 
  173       call_1_3(std::string name, std::string group, ARG1_T aut1, 
 
  174           ARG2_T other1, ARG3_T other2, ARG4_T other3,
 
  175           RET_T(*fct)(ARG1_T, ARG2_T, ARG3_T, ARG4_T) = 
nullptr) 
 
  177         std::string stat_ctx = aut1->get_context()->sname();
 
  178         typedef RET_T (*bridge_t)(ARG1_T,ARG2_T,ARG3_T,ARG4_T);
 
  179         bridge_t bridge = (bridge_t) 
get_handler(name, group, stat_ctx);
 
  180         return bridge(aut1, other1, other2, other3);
 
  183       template<
typename RET_T, 
typename ARG1_T, 
typename ARG2_T, 
 
  184           typename ARG3_T, 
typename ARG4_T, 
typename ARG5_T>
 
  186       call_1_4(std::string name, std::string group, ARG1_T aut1, 
 
  187           ARG2_T other1, ARG3_T other2, ARG4_T other3, ARG5_T other4,
 
  188           RET_T(*fct)(ARG1_T, ARG2_T, ARG3_T, ARG4_T, ARG5_T) = 
nullptr) 
 
  190         std::string stat_ctx = aut1->get_context()->sname();
 
  191         typedef RET_T (*bridge_t)(ARG1_T,ARG2_T,ARG3_T,ARG4_T, ARG5_T);
 
  192         bridge_t bridge = (bridge_t) 
get_handler(name, group, stat_ctx);
 
  193         return bridge(aut1, other1, other2, other3, other4);
 
  196       template<
typename RET_T, 
typename ARG1_T, 
typename ARG2_T>
 
  198       call_2_0(std::string name, std::string group, ARG1_T aut1,
 
  199         ARG2_T aut2, RET_T(*fct)(ARG1_T, ARG2_T) = 
nullptr)
 
  201         std::string stat_ctx1 = aut1->get_context()->sname();
 
  202         std::string stat_ctx2 = aut2->get_context()->sname();
 
  203         typedef RET_T (*bridge_t)(ARG1_T, ARG2_T);
 
  205         = (bridge_t) 
get_handler(name, group, stat_ctx1, stat_ctx2);
 
  206         return bridge(aut1, aut2);
 
  209       template<
typename RET_T, 
typename ARG1_T, 
typename ARG2_T, 
 
  212       call_2_1(std::string name, std::string group, ARG1_T aut1,
 
  213         ARG2_T aut2, ARG3_T other1, RET_T(*fct)(ARG1_T, ARG2_T, ARG3_T) = 
nullptr)
 
  215         std::string stat_ctx1 = aut1->get_context()->sname();
 
  216         std::string stat_ctx2 = aut2->get_context()->sname();
 
  217         typedef RET_T (*bridge_t)(ARG1_T, ARG2_T, ARG3_T);
 
  219         = (bridge_t) 
get_handler(name, group, stat_ctx1, stat_ctx2);
 
  220         return bridge(aut1, aut2, other1);
 
  223       template<
typename TYPERET, 
typename ARG1, 
typename ARG2,
 
  224         TYPERET(*FCT)(ARG1,ARG2)>
 
  225       TYPERET 
call_tdc2(std::string name, std::string group, ARG1 aut1, ARG2 aut2) 
 
  227         std::string stat_ctx1 = aut1->get_context()->sname();
 
  228         std::string stat_ctx2 = aut2->get_context()->sname();
 
  229         std::string stat_ctx = stat_ctx1+
"_"+stat_ctx2;
 
  230         typedef TYPERET (*bridge_t)(ARG1, ARG2);
 
  231         static std::unordered_map<std::string, void*> bridges;
 
  232         auto it = bridges.find(stat_ctx);
 
  233         if(it == bridges.end()) {
 
  234           auto bridge = (bridge_t) 
get_handler(name, group, stat_ctx1, stat_ctx2);
 
  235           bridges.emplace(stat_ctx, (
void*) bridge);
 
  236           return bridge(aut1, aut2);
 
  239           return ((bridge_t)it->second)(aut1, aut2);
 
  333 #define HANDLER_EXTERN extern 
  335 #undef HANDLER_EXTERN 
RET_T call_0_1(std::string name, std::string group, std::string stat_ctx, ARG1_T other1, RET_T(*fct)(ARG1_T)=nullptr)
Definition: handler.hh:103
 
RET_T call_0_3(std::string name, std::string group, std::string stat_ctx, ARG1_T other1, ARG2_T other2, ARG3_T other3, RET_T(*fct)(ARG1_T, ARG2_T, ARG3_T)=nullptr)
Definition: handler.hh:126
 
RET_T call_2_0(std::string name, std::string group, ARG1_T aut1, ARG2_T aut2, RET_T(*fct)(ARG1_T, ARG2_T)=nullptr)
Definition: handler.hh:198
 
RET_T call_1_1(std::string name, std::string group, ARG1_T aut1, ARG2_T other1, RET_T(*fct)(ARG1_T, ARG2_T)=nullptr)
Definition: handler.hh:149
 
RET_T call0(std::string name, std::string group, std::string stat_ctx, ARGS_T... args)
Definition: handler.hh:58
 
RET_T call_1_2(std::string name, std::string group, ARG1_T aut1, ARG2_T other1, ARG3_T other2, RET_T(*fct)(ARG1_T, ARG2_T, ARG3_T)=nullptr)
Definition: handler.hh:161
 
RET_T call2(std::string name, std::string group, ARG1_T arg1, ARG2_T arg2, ARGS_T... args)
Definition: handler.hh:82
 
RET_T call_1_3(std::string name, std::string group, ARG1_T aut1, ARG2_T other1, ARG3_T other2, ARG4_T other3, RET_T(*fct)(ARG1_T, ARG2_T, ARG3_T, ARG4_T)=nullptr)
Definition: handler.hh:173
 
RET_T call_1_4(std::string name, std::string group, ARG1_T aut1, ARG2_T other1, ARG3_T other2, ARG4_T other3, ARG5_T other4, RET_T(*fct)(ARG1_T, ARG2_T, ARG3_T, ARG4_T, ARG5_T)=nullptr)
Definition: handler.hh:186
 
RET_T call_0_2(std::string name, std::string group, std::string stat_ctx, ARG1_T other1, ARG2_T other2, RET_T(*fct)(ARG1_T, ARG2_T)=nullptr)
Definition: handler.hh:114
 
void * get_handler(const std::string name, const std::string group, const std::string &static_context)
 
TYPERET call_tdc2(std::string name, std::string group, ARG1 aut1, ARG2 aut2)
Definition: handler.hh:225
 
RET_T call1(std::string name, std::string group, ARG1_T arg1, ARGS_T... args)
Definition: handler.hh:69
 
RET_T call_2_1(std::string name, std::string group, ARG1_T aut1, ARG2_T aut2, ARG3_T other1, RET_T(*fct)(ARG1_T, ARG2_T, ARG3_T)=nullptr)
Definition: handler.hh:212
 
RET_T call_1_0(std::string name, std::string group, ARG1_T aut, RET_T(*fct)(ARG1_T)=nullptr)
Definition: handler.hh:137
 
Main namespace of Awali.
Definition: ato.hh:22