|
C++ YASMIN (Yet Another State MachINe)
|
Namespaces | |
| namespace | pybind11_utils |
Classes | |
| class | Blackboard |
| A thread-safe storage for key-value pairs of varying types. More... | |
| class | BlackboardPyWrapper |
| A wrapper around the C++ Blackboard that stores Python objects and native types. More... | |
| class | CbState |
| Represents a state that executes a callback function. More... | |
| class | Concurrence |
| Runs a series of states in parallel. More... | |
| class | PyState |
| Trampoline class to enable Python classes to inherit from C++ State. More... | |
| class | State |
| Represents a state in a state machine. More... | |
| class | StateMachine |
| A class that implements a state machine with a set of states, transitions, and callback mechanisms for state changes. More... | |
Typedefs | |
| typedef void(* | LogFunction) (LogLevel level, const char *file, const char *function, int line, const char *text) |
| Type definition for a logging function. | |
| using | StringSet = std::set<std::string> |
| Set of strings. | |
| using | StringMap = std::unordered_map<std::string, std::string> |
| Map from string to string. | |
| using | Outcomes = StringSet |
| Set of possible outcomes for states. | |
| using | StateOutcomeMap = StringMap |
| Map of state names to their outcomes. | |
| using | OutcomeMap = std::unordered_map<std::string, StateOutcomeMap> |
| Map of outcomes to state outcome maps. | |
| using | Transitions = StringMap |
| Map of transitions (string to string) | |
| using | TransitionsMap = std::unordered_map<std::string, Transitions> |
| Map of state names to transitions. | |
| using | Remappings = StringMap |
| Map of remappings (string to string) | |
| using | RemappingsMap = std::unordered_map<std::string, Remappings> |
| Map of keys to remappings. | |
| using | TypeRegistry = StringMap |
| Registry for type information. | |
| using | BlackboardPtr = std::shared_ptr<Blackboard> |
| Shared pointer to Blackboard. | |
| using | StatePtr = std::shared_ptr<State> |
| Shared pointer to State. | |
| using | StateMachinePtr = std::shared_ptr<StateMachine> |
| Shared pointer to StateMachine. | |
| using | ConcurrencePtr = std::shared_ptr<Concurrence> |
| Shared pointer to Concurrence. | |
| using | StateMap = std::unordered_map<std::string, std::shared_ptr<State>> |
| Map of state names to state pointers. | |
| using | CbStateCallback = std::function<std::string(std::shared_ptr<Blackboard>)> |
| Callback function type for CbState. | |
Enumerations | |
| enum | LogLevel { ERROR = 0 , WARN , INFO , DEBUG } |
| Enum representing different log levels for controlling log verbosity. More... | |
| enum class | StateStatus { IDLE , RUNNING , CANCELED , COMPLETED } |
| Enumeration representing the current status of a state. More... | |
Functions | |
| std::string | demangle_type (const std::string &mangled_name) |
| Demangle a C++ type name to a human-readable format. | |
| void | default_log_message (LogLevel level, const char *file, const char *function, int line, const char *text) |
| Default logging function. | |
| void | set_log_level (LogLevel new_log_level) |
| Sets the log level for the logs. | |
| const char * | log_level_to_name (LogLevel level) |
| Parse LogLevel to string. | |
| template<yasmin::LogLevel LEVEL> | |
| void | log_helper (const char *file, const char *function, int line, const char *text,...) |
| Variadic template function to log messages at different levels. | |
| const char * | extract_filename (const char *path) |
| Extracts the filename from a given file path. | |
| void | set_loggers (LogFunction log_message) |
| Sets custom logging functions for different log levels. | |
| void | set_default_loggers () |
| Sets the default logging function for all log levels. | |
Variables | |
| LogLevel | log_level = INFO |
| The current log level for the application. | |
| LogFunction | log_message = default_log_message |
| Pointer to the logging function. | |
| using yasmin::BlackboardPtr = std::shared_ptr<Blackboard> |
Shared pointer to Blackboard.
| using yasmin::CbStateCallback = std::function<std::string(std::shared_ptr<Blackboard>)> |
Callback function type for CbState.
| using yasmin::ConcurrencePtr = std::shared_ptr<Concurrence> |
Shared pointer to Concurrence.
| typedef void(* yasmin::LogFunction) (LogLevel level, const char *file, const char *function, int line, const char *text) |
Type definition for a logging function.
This type represents a function pointer that takes a file name, function name, line number, log message, and a variable number of additional arguments for formatting the log message.
| level | The log level of the message |
| file | The name of the source file where the log function is called. |
| function | The name of the function where the log function is called. |
| line | The line number in the source file where the log function is called. |
| text | The format string for the log message, similar to printf. |
| ... | Additional arguments for the format string. |
| using yasmin::OutcomeMap = std::unordered_map<std::string, StateOutcomeMap> |
Map of outcomes to state outcome maps.
| using yasmin::Outcomes = StringSet |
Set of possible outcomes for states.
| using yasmin::Remappings = StringMap |
Map of remappings (string to string)
| using yasmin::RemappingsMap = std::unordered_map<std::string, Remappings> |
Map of keys to remappings.
| using yasmin::StateMachinePtr = std::shared_ptr<StateMachine> |
Shared pointer to StateMachine.
| using yasmin::StateMap = std::unordered_map<std::string, std::shared_ptr<State>> |
Map of state names to state pointers.
| using yasmin::StateOutcomeMap = StringMap |
Map of state names to their outcomes.
| using yasmin::StatePtr = std::shared_ptr<State> |
Shared pointer to State.
| using yasmin::StringMap = std::unordered_map<std::string, std::string> |
Map from string to string.
| using yasmin::StringSet = std::set<std::string> |
Set of strings.
| using yasmin::Transitions = StringMap |
Map of transitions (string to string)
| using yasmin::TransitionsMap = std::unordered_map<std::string, Transitions> |
Map of state names to transitions.
| using yasmin::TypeRegistry = StringMap |
Registry for type information.
| enum yasmin::LogLevel |
Enum representing different log levels for controlling log verbosity.
This enum defines the severity levels of logs that can be used to control which log messages should be displayed. The levels are ordered from most severe to least severe. Only logs at or above the current log level will be shown.
|
strong |
| void yasmin::default_log_message | ( | LogLevel | level, |
| const char * | file, | ||
| const char * | function, | ||
| int | line, | ||
| const char * | text ) |
Default logging function.
| level | The log level as a string (e.g., "ERROR", "WARN", "INFO", "DEBUG"). |
| file | The source file where the log function is called. |
| function | The function where the log function is called. |
| line | The line number in the source file. |
| text | The format string for the log message. |
|
inline |
Demangle a C++ type name to a human-readable format.
| mangled_name | The mangled type name. |
|
inline |
Extracts the filename from a given file path.
This function takes a full path to a file and returns just the file name.
| path | The full path to the file. |
| void yasmin::log_helper | ( | const char * | file, |
| const char * | function, | ||
| int | line, | ||
| const char * | text, | ||
| ... ) |
Variadic template function to log messages at different levels.
This function wraps log_message and allows logging messages with different log levels while reducing redundant code. It provides a consistent logging format across all levels.
| LEVEL | The log level LogLevel (e.g., 0 -> "ERROR", 1 -> "WARN", 2 -> "INFO", 3 -> "DEBUG"). |
| file | The source file where the log function is called. |
| function | The function where the log function is called. |
| line | The line number in the source file. |
| text | The format string for the log message. |
| ... | Additional arguments for the format string. |
| const char * yasmin::log_level_to_name | ( | LogLevel | level | ) |
Parse LogLevel to string.
This function returns the name of a given log level.
| level | Log level. |
| void yasmin::set_default_loggers | ( | ) |
Sets the default logging function for all log levels.
This function initializes the logging function to the default implementations.
| void yasmin::set_log_level | ( | LogLevel | new_log_level | ) |
Sets the log level for the logs.
This function allows the user to specify the log level error, warning, info, or debug.
| new_log_level | Log level. |
| void yasmin::set_loggers | ( | LogFunction | log_message | ) |
Sets custom logging functions for different log levels.
This function allows the user to specify custom logging functions for error, warning, info, and debug logs. If a null function is provided for any log level, the default logging function will be used instead.
| error | Pointer to the custom error logging function. |
| warn | Pointer to the custom warning logging function. |
| info | Pointer to the custom info logging function. |
| debug | Pointer to the custom debug logging function. |
The current log level for the application.
This global variable holds the current log level, which determines the verbosity of the logs. Logs at or above this level will be displayed. The default level is set to INFO.
| LogFunction yasmin::log_message = default_log_message |
Pointer to the logging function.