LCOV - code coverage report
Current view: top level - include/crpropa - Module.h (source / functions) Coverage Total Hit
Test: coverage.info.cleaned Lines: 20.0 % 10 2
Test Date: 2026-06-18 09:49:19 Functions: 0.0 % 1 0

            Line data    Source code
       1              : #ifndef CRPROPA_MODULE_H
       2              : #define CRPROPA_MODULE_H
       3              : 
       4              : #include "crpropa/Candidate.h"
       5              : #include "crpropa/Referenced.h"
       6              : #include "crpropa/Common.h"
       7              : 
       8              : #include <string>
       9              : 
      10              : namespace crpropa {
      11              : 
      12              : class Candidate;
      13              : 
      14              : /**
      15              :  @class Module
      16              :  @brief Abstract base class for modules
      17              :  */
      18              : class Module: public Referenced {
      19              :         std::string description;
      20              : public:
      21              :         Module();
      22           42 :         virtual ~Module() {
      23           32 :         }
      24              :         virtual std::string getDescription() const;
      25              :         void setDescription(const std::string &description);
      26              :         virtual void process(Candidate *candidate) const = 0;
      27              :         inline void process(ref_ptr<Candidate> candidate) const {
      28            0 :                 process(candidate.get());
      29            0 :         }
      30              : };
      31              : 
      32              : 
      33              : /**
      34              :  @class AbstractCondition
      35              :  @brief Abstract Module providing common features for conditional modules.
      36              :  */
      37              : class AbstractCondition: public Module {
      38              : protected:
      39              :         ref_ptr<Module> rejectAction, acceptAction;
      40              :         bool makeRejectedInactive, makeAcceptedInactive;
      41              :         std::string rejectFlagKey, rejectFlagValue;
      42              :         std::string acceptFlagKey, acceptFlagValue;
      43              : 
      44              :         void reject(Candidate *candidate) const;
      45              :         inline void reject(ref_ptr<Candidate> candidate) const {
      46            0 :                 reject(candidate.get());
      47            0 :         }
      48              : 
      49              :         void accept(Candidate *candidate) const;
      50              :         inline void accept(ref_ptr<Candidate> candidate) const {
      51            0 :                 accept(candidate.get());
      52            0 :         }
      53              : 
      54              : public:
      55              :         AbstractCondition();
      56              :         void onReject(Module *rejectAction);
      57              :         void onAccept(Module *acceptAction);
      58              :         void setMakeRejectedInactive(bool makeInactive);
      59              :         void setMakeAcceptedInactive(bool makeInactive);
      60              :         void setRejectFlag(std::string key, std::string value);
      61              :         void setAcceptFlag(std::string key, std::string value);
      62              : 
      63              :         // return the reject flag (key & value), delimiter is the "&".
      64              :         std::string getRejectFlag();
      65              : 
      66              :         // return the accept flag (key & value), delimiter is the "&"
      67              :         std::string getAcceptFlag();
      68              : };
      69              : 
      70              : /**
      71              :  @class Deactivation
      72              :  @brief Direct deactivation of the candidate. Can be used for debuging.
      73              : */
      74            0 : class Deactivation: public AbstractCondition {
      75              :         public: 
      76            0 :                 void process(Candidate *cand) const { reject(cand); }
      77              : };
      78              : 
      79              : 
      80              : } // namespace crpropa
      81              : 
      82              : #endif /* CRPROPA_MODULE_H */
        

Generated by: LCOV version 2.0-1