gv_fsm 0.4.2 → 0.4.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/templates.rb +18 -6
  3. data/lib/version.rb +1 -1
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 36de89f3e2479b1f535f199601a58af93d53065aaff940143330244597e88a3d
4
- data.tar.gz: 58c148315536416ffb99555fb6e3a88253a2f83a6776a17691b5c39019aee4cb
3
+ metadata.gz: 6e2b60dc6b9b04ce5e69c1737103af124f756c56324a9c92193b35223acacf9e
4
+ data.tar.gz: 55ba355493f4e6ffe0ed6ea9a48174b1a478a024b6d07c6b3b4d4dafc9d4ebc3
5
5
  SHA512:
6
- metadata.gz: 514f56b578dc4093df80b45ed139a4f129e55a2441a2abb2b93f1dff3997782e0cb78e4df07720b06703a277f6df4a84374ded23d37b4ff55318411d393b87a3
7
- data.tar.gz: 429480975d005883b23862eec8c2f834e835dc7f6de2d404c980fe31a30947e3232fc45decde91e2eafd44a0a5cb5d7310c3382551090c77d9929156e16cbff3
6
+ metadata.gz: 871eaa5cf354c80f516d31878efb9bea108ee55b76a04f3b4715bdc317e2eb8cb9b1005646248f9cff7838cb168aac7d120b8d3388d4be3cbf6ddf237426a0e0
7
+ data.tar.gz: 39e534fe925ac412a12b88c02e29bbfb106e3460509a7a4a1bbc077f7a6074e7b35f1071fb10151e8e96a1d08706b729919978efc025ee7361d7f6a3b5fd7d87
data/lib/templates.rb CHANGED
@@ -457,12 +457,26 @@ public:
457
457
  }
458
458
  }
459
459
 
460
- // Run the FSM from a given state
461
- void run(<%= @prefix %>state_t state, operation_fun operation = nullptr) {
460
+
461
+ // Setup initial state links
462
+ void setup(state_t state) {
462
463
  <%= ns %>::<%= self.sigint %>_requested = false;
463
- <%= @prefix %>state_t prev_state = state;
464
464
  _state.first = state;
465
465
  _state.second = state;
466
+ }
467
+
468
+ // Evaluate the current state and update the next state
469
+ // to be used when main loop is customized (i.e., not using FSM::run())
470
+ state_t eval_state() {
471
+ (*this)(_state.first, _state.second);
472
+ _state.first = _state.second;
473
+ _state.second = (*this)(_state.second);
474
+ return _state.second;
475
+ }
476
+
477
+ // Run the FSM from a given state
478
+ void run(<%= @prefix %>state_t state, operation_fun operation = nullptr) {
479
+ setup(state);
466
480
  <% if sigint then -%>
467
481
  std::signal(SIGINT, [](int signum) {
468
482
  <% if log == :syslog then -%>
@@ -475,9 +489,7 @@ public:
475
489
  if (operation) {
476
490
  operation(*_data);
477
491
  }
478
- (*this)(_state.first, _state.second);
479
- _state.first = _state.second;
480
- _state.second = (*this)(_state.second);
492
+ eval_state();
481
493
  if (_timing_func) {
482
494
  _timing_func();
483
495
  }
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module GV_FSM
2
- VERSION = "0.4.2"
2
+ VERSION = "0.4.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gv_fsm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paolo Bosetti