LCOV - code coverage report
Current view: top level - /opt/artdaq/srcs/artdaq-mfextensions/ErrorHandler/MessageAnalyzer - ma_action.h (source / functions) Coverage Total Hit
Test: artdaq.info.cleaned Lines: 0.0 % 9 0
Test Date: 2025-09-04 00:45:34 Functions: 0.0 % 5 0

            Line data    Source code
       1              : #ifndef ERROR_HANDLER_MA_ACTION_H
       2              : #define ERROR_HANDLER_MA_ACTION_H
       3              : 
       4              : #include <map>
       5              : #include <string>
       6              : #include <vector>
       7              : 
       8              : #include "ErrorHandler/MessageAnalyzer/ma_types.h"
       9              : 
      10              : #include <fhiclcpp/ParameterSet.h>
      11              : 
      12              : #include <boost/any.hpp>
      13              : #include <boost/function.hpp>
      14              : 
      15              : namespace novadaq {
      16              : namespace errorhandler {
      17              : 
      18              : class ma_condition;
      19              : class ma_rule;
      20              : 
      21              : typedef std::vector<boost::any> anys_t;
      22              : typedef fhicl::ParameterSet pset_t;
      23              : 
      24              : /// base class - all customized fucntions are inherited from it
      25              : class ma_action
      26              : {
      27              : public:
      28            0 :         ma_action(ma_rule const *rule, pset_t const &pset = pset_t())
      29            0 :             : parent_rule(*rule), parameter(pset) {}
      30            0 :         virtual ~ma_action() {}
      31              : 
      32              :         virtual bool exec() = 0;
      33              : 
      34              : protected:
      35              :         ma_rule const &parent_rule;
      36              :         pset_t parameter;
      37              : 
      38              : private:
      39              : };
      40              : 
      41              : typedef std::vector<ma_action *> ma_actions;
      42              : 
      43              : typedef boost::function<ma_action *(ma_rule const *, pset_t const &)> gen_act_t;
      44              : 
      45              : struct ma_action_factory
      46              : {
      47              :         typedef std::map<std::string, gen_act_t> gen_map_t;
      48              : 
      49              : public:
      50              :         static void
      51              :         reg(std::string const &action_name, gen_act_t f);
      52              : 
      53              :         static ma_action *
      54              :         create_instance(std::string const &act_name, ma_rule const *rule, pset_t const &pset);
      55              : 
      56              : private:
      57              :         ma_action_factory(){};
      58              : 
      59              :         static gen_map_t &
      60            0 :         get_map()
      61              :         {
      62            0 :                 static gen_map_t map;
      63            0 :                 return map;
      64              :         }
      65              : };
      66              : 
      67              : struct ma_action_maker
      68              : {
      69            0 :         ma_action_maker(std::string const &act_name, gen_act_t f)
      70              :         {
      71            0 :                 ma_action_factory::reg(act_name, f);
      72            0 :         }
      73              : };
      74              : 
      75              : }  // end of namespace errorhandler
      76              : }  // end of namespace novadaq
      77              : 
      78              : // -------------------------------------------------
      79              : // Macro for registering the custom function
      80              : 
      81              : #define REG_MA_ACTION(act_name, class_name)                                     \
      82              :         ma_action *                                                                 \
      83              :             class_name##_maker_func(ma_rule const *r, fhicl::ParameterSet const &p) \
      84              :         {                                                                           \
      85              :                 return new class_name(r, p);                                            \
      86              :         }                                                                           \
      87              :         ma_action_maker                                                             \
      88              :             class_name##_maker_func_global_var(#act_name, class_name##_maker_func);
      89              : 
      90              : #endif
        

Generated by: LCOV version 2.0-1