1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

state: port to C++

This commit is contained in:
Steffen Vogel 2021-10-04 21:21:17 +02:00
parent e90dc976a1
commit 0b3f24c47e
2 changed files with 5 additions and 12 deletions

View file

@ -23,6 +23,8 @@
#pragma once
#include <string>
/* Common states for most objects in VILLAScommon (paths, nodes, hooks, plugins) */
enum class State {
DESTROYED = 0,
@ -52,4 +54,4 @@ enum class State {
typedef int (*dtor_cb_t)(void *);
/** Convert state enum to human readable string. */
const char * state_print(enum State s);
std::string stateToString(enum State s);

View file

@ -25,46 +25,37 @@
#include <cstdlib>
const char * state_print(enum State s)
std::string stateToString(enum State s)
{
switch (s) {
case State::DESTROYED:
return "destroyed";
break;
case State::INITIALIZED:
return "initialized";
break;
case State::PARSED:
return "parsed";
break;
case State::CHECKED:
return "checked";
break;
case State::STARTED:
return "running";
break;
case State::STOPPED:
return "stopped";
break;
case State::PENDING_CONNECT:
return "pending-connect";
break;
case State::CONNECTED:
return "connected";
break;
case State::PAUSED:
return "paused";
break;
default:
return nullptr;
return "";
}
}