• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

jharwell / rcppsw / 7670959353

26 Jan 2024 04:49PM UTC coverage: 89.072% (+0.3%) from 88.788%
7670959353

push

github

jharwell
refactor(#326): Add automatic log4cxx client logger name calculation

- Deduced from typeid()
- Ensures that the name of the logger for a class is ALWAYS the same as the
  fully qualified name, reducing refactoring errors. Principle of Least Surprise.

30 of 32 new or added lines in 8 files covered. (93.75%)

8 existing lines in 4 files now uncovered.

1296 of 1455 relevant lines covered (89.07%)

512.55 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

33.33
/src/patterns/state_machine/hfsm.cpp
1
/**
2
 * \file hfsm.cpp
3
 *
4
 * \copyright 2017 John Harwell, All rights reserved.
5
 *
6
 * SPDX-License-Identifier: MIT
7
 */
8

9
/*******************************************************************************
10
 * Includes
11
 ******************************************************************************/
12
#include "rcppsw/patterns/fsm/hfsm.hpp"
13

14
/*******************************************************************************
15
 * Namespaces/Decls
16
 ******************************************************************************/
17
namespace rcppsw::patterns::fsm {
18

19
/*******************************************************************************
20
 * Member Functions
21
 ******************************************************************************/
22
void hfsm::state_engine_step(const state_map_row* const c_row) {
60✔
23
  ER_ASSERT(nullptr != c_row->state(), "null state?");
60✔
24
  ER_TRACE("Invoking state action: state%d, data=%p",
120✔
25
           current_state(),
26
           reinterpret_cast<const void*>(event_data()));
30✔
27
  auto* state = static_cast<const hfsm_state*>(c_row->state());
60✔
28
  int rval = event_signal::ekUNHANDLED;
60✔
29
  while (rval != event_signal::ekHANDLED) {
60✔
30
    rval = state->invoke_state_action(this, event_data());
90✔
31

32
    if (event_signal::ekHANDLED == rval) {
60✔
33
      break;
30✔
34
    }
35
    /*
36
     * It is possible that we have gotten the HANDLED signal from a parent state
37
     * of a child that returned UNHANDLED. As such, we need to change both the
38
     * event type and the signal of the event so execution can continue
39
     * normally.
40
     */
41
    state = static_cast<hfsm_state*>(state->parent());
×
42
    event_data()->type(event_type::ekCHILD);
×
UNCOV
43
    event_data()->signal(rval);
30✔
44
  } /* while() */
45
} /* state_engine_step() */
60✔
46

47
void hfsm::state_engine_step(const state_map_ex_row* const c_row_ex) {
×
48
  ER_ASSERT(nullptr != c_row_ex->state(), "null state?");
×
49
  ER_TRACE("Invoking state action: state%d, data=%p",
×
50
           current_state(),
51
           reinterpret_cast<const void*>(event_data()));
52
  auto* state = static_cast<const hfsm_state*>(c_row_ex->state());
×
53
  int rval = event_signal::ekUNHANDLED;
×
54
  while (rval != event_signal::ekHANDLED) {
×
55
    rval = state->invoke_state_action(this, event_data());
×
56

57
    if (event_signal::ekHANDLED == rval) {
×
UNCOV
58
      break;
59
    }
60
    /*
61
     * It is possible that we have gotten the HANDLED signal from a parent state
62
     * of a child that returned UNHANDLED. As such, we need to change both the
63
     * event type and the signal of the event so execution can continue
64
     * normally.
65
     */
66
    state = static_cast<hfsm_state*>(state->parent());
×
67
    event_data()->type(event_type::ekCHILD);
×
68
    event_data()->signal(rval);
×
69
  } /* while() */
70
} /* state_engine_step() */
×
71

72
void hfsm::change_parent(uint8_t state,
×
73
                         rcppsw::patterns::fsm::state* new_parent) {
74
  auto* row = state_map(state);
×
75
  auto* row_ex = state_map_ex(state);
×
76

77
  ER_ASSERT(!(nullptr == row && nullptr == row_ex), "Both state maps are NULL!");
×
78

79
  if (nullptr != row) {
×
80
    auto* self = static_cast<hfsm_state*>(row->state());
×
81
    self->parent(new_parent);
×
82
  } else {
83
    auto* self = static_cast<hfsm_state*>(row_ex->state());
×
84
    self->parent(new_parent);
×
85
  }
86
} /* change_parent() */
×
87

88
} /* namespace rcppsw::patterns::fsm */
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc