-
Notifications
You must be signed in to change notification settings - Fork 488
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FSMA: Moved several non-trivial functions to the CC file.
This fixes the build on Windows MinGW, because the Fsm symbol was eliminated and thus missing during linking.
- Loading branch information
Showing
2 changed files
with
65 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// | ||
// Copyright (C) 2024 OpenSim Ltd. | ||
// | ||
// SPDX-License-Identifier: LGPL-3.0-or-later | ||
// | ||
|
||
#include "inet/common/FSMA.h" | ||
|
||
namespace inet { | ||
|
||
Register_Class(Fsm); | ||
|
||
void Fsm::copy(const Fsm &other) | ||
{ | ||
stateName = other.stateName; | ||
state = other.state; | ||
} | ||
|
||
Fsm& Fsm::operator=(const Fsm &vs) | ||
{ | ||
if (this == &vs) | ||
return *this; | ||
cOwnedObject::operator=(vs); | ||
copy(vs); | ||
return *this; | ||
} | ||
|
||
void Fsm::setState(int state, const char *stateName) | ||
{ | ||
this->state = state; | ||
this->stateName = stateName; | ||
if (stateChangedSignal != -1) | ||
cSimulation::getActiveSimulation()->getContextModule()->emit(stateChangedSignal, state); | ||
} | ||
|
||
void Fsm::insertDelayedAction(std::function<void()> action) | ||
{ | ||
delayedActions.push_back(action); | ||
} | ||
|
||
inline void Fsm::executeDelayedActions() | ||
{ | ||
auto actions = delayedActions; | ||
delayedActions.clear(); | ||
for (auto action : actions) | ||
action(); | ||
} | ||
|
||
std::string Fsm::str() const | ||
{ | ||
std::stringstream out; | ||
if (!stateName) | ||
out << "state: " << state; | ||
else | ||
out << "state: " << stateName << " (" << state << ")"; | ||
return out.str(); | ||
} | ||
|
||
} // namespace inet |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters