LCOV - code coverage report
Current view: top level - src - Module.cpp (source / functions) Coverage Total Hit
Test: coverage.info.cleaned Lines: 68.5 % 54 37
Test Date: 2026-06-18 09:49:19 Functions: 64.3 % 14 9

            Line data    Source code
       1              : #include "crpropa/Module.h"
       2              : 
       3              : #include <typeinfo>
       4              : 
       5              : namespace crpropa {
       6              : 
       7          218 : Module::Module() {
       8              :         const std::type_info &info = typeid(*this);
       9          218 :         setDescription(info.name());
      10          218 : }
      11              : 
      12            0 : std::string Module::getDescription() const {
      13            0 :         return description;
      14              : }
      15              : 
      16          374 : void Module::setDescription(const std::string &d) {
      17          374 :         description = d;
      18          374 : }
      19              : 
      20           33 : AbstractCondition::AbstractCondition() :
      21           33 :                 makeRejectedInactive(true), makeAcceptedInactive(false), rejectFlagKey(
      22           33 :                                 "Rejected"), rejectFlagValue( typeid(*this).name() ) {
      23           33 : }
      24              : 
      25         1126 : void AbstractCondition::reject(Candidate *candidate) const {
      26         1126 :         if (!candidate)
      27              :                 return;
      28              : 
      29         1126 :         if (rejectAction.valid())
      30            5 :                 rejectAction->process(candidate);
      31              : 
      32         1126 :         if (!rejectFlagKey.empty())
      33         1126 :                 candidate->setProperty(rejectFlagKey, rejectFlagValue);
      34              : 
      35         1126 :         if (makeRejectedInactive)
      36         1125 :                 candidate->setActive(false);
      37              : }
      38              : 
      39            2 : void AbstractCondition::accept(Candidate *candidate) const {
      40            2 :         if (!candidate)
      41              :                 return;
      42              : 
      43            2 :         if (acceptAction.valid())
      44            2 :                 acceptAction->process(candidate);
      45              : 
      46            2 :         if (!acceptFlagKey.empty())
      47            0 :                 candidate->setProperty(acceptFlagKey, acceptFlagValue);
      48              : 
      49            2 :         if (makeAcceptedInactive)
      50            0 :                 candidate->setActive(false);
      51              : }
      52              : 
      53            1 : void AbstractCondition::setMakeRejectedInactive(bool deactivate) {
      54            1 :         makeRejectedInactive = deactivate;
      55            1 : }
      56              : 
      57            0 : void AbstractCondition::setMakeAcceptedInactive(bool deactivate) {
      58            0 :         makeAcceptedInactive = deactivate;
      59            0 : }
      60              : 
      61            1 : void AbstractCondition::onReject(Module *action) {
      62            1 :         rejectAction = action;
      63            1 : }
      64              : 
      65            1 : void AbstractCondition::onAccept(Module *action) {
      66            1 :         acceptAction = action;
      67            1 : }
      68              : 
      69            1 : void AbstractCondition::setRejectFlag(std::string key, std::string value) {
      70            1 :         rejectFlagKey = key;
      71            1 :         rejectFlagValue = value;
      72            1 : }
      73              : 
      74            0 : void AbstractCondition::setAcceptFlag(std::string key, std::string value) {
      75            0 :         acceptFlagKey = key;
      76            0 :         acceptFlagValue = value;
      77            0 : }
      78              : 
      79            0 : std::string AbstractCondition::getRejectFlag() {
      80            0 :         std::string out = rejectFlagKey + "&" + rejectFlagValue; 
      81            0 :         return out;
      82              : }
      83              : 
      84            0 : std::string AbstractCondition::getAcceptFlag() {
      85            0 :         std::string out = acceptFlagKey + "&" + acceptFlagValue;
      86            0 :         return out;
      87              : }
      88              : 
      89              : 
      90              : } // namespace crpropa
        

Generated by: LCOV version 2.0-1