State Machine  0.4.0
This repository contains packages for creating and running general purpose state machines.
state_machine::NestedName Class Reference

#include <NestedName.hpp>

Public Member Functions

 NestedName ()=default
 
 ~NestedName ()=default
 
NestedNameaddInnerStateName (const std::string &name)
 
NestedNameaddOuterStateName (const std::string &name)
 
NestedNameremoveInnermostState ()
 
NestedNameremoveOutermostState ()
 
std::string getNameOfInnermostState () const
 
std::string getNameOfOutermostState () const
 
std::string getNameOfState (const size_t nesting) const
 
Impl::const_iterator getInwardsIteratorBegin () const
 
Impl::const_iterator getInwardsIteratorEnd () const
 
Impl::const_reverse_iterator getOutwardsIteratorBegin () const
 
Impl::const_reverse_iterator getOutwardsIteratorEnd () const
 
size_t getNumberOfNestings () const
 
bool empty () const
 
void clear ()
 
bool fromString (const std::string &string, const std::string &delimiter=STATE_MACHINE_NESTED_NAME_DEFAULT_DELIMITER)
 
std::string toString (const std::string &delimiter=STATE_MACHINE_NESTED_NAME_DEFAULT_DELIMITER) const
 
bool operator== (const NestedName &other) const
 
bool operator< (const NestedName &other) const
 

Protected Types

using Impl = std::deque< std::string >
 

Protected Attributes

Impl impl_
 

Detailed Description

Each state in the state machine has a name. These names must be unique within a container, but not within the entire state machine. For functions which require a non-ambiguous identifier of a state (e.g. for setting the initial state of a state machine), the state's nested name is used. The nested name contains the name of the state, and all its parent states, and therefore is unique within a state machine.

Member Typedef Documentation

◆ Impl

using state_machine::NestedName::Impl = std::deque<std::string>
protected

Constructor & Destructor Documentation

◆ NestedName()

state_machine::NestedName::NestedName ( )
default

Constructor.

◆ ~NestedName()

state_machine::NestedName::~NestedName ( )
default

Destructor.

Member Function Documentation

◆ addInnerStateName()

NestedName & state_machine::NestedName::addInnerStateName ( const std::string &  name)

Add the name of the inner state.

Parameters
nameName of the state to add.
Returns
Reference to this nested name.

◆ addOuterStateName()

NestedName & state_machine::NestedName::addOuterStateName ( const std::string &  name)

Add the name of the outer state.

Parameters
nameName of the state to add.
Returns
Reference to this nested name.

◆ clear()

void state_machine::NestedName::clear ( )

Clear the nested name.

◆ empty()

bool state_machine::NestedName::empty ( ) const

Check if the nested name is empty.

Returns
True if nested name is empty.

◆ fromString()

bool state_machine::NestedName::fromString ( const std::string &  string,
const std::string &  delimiter = STATE_MACHINE_NESTED_NAME_DEFAULT_DELIMITER 
)

Set the nested name from a string, where the name of the states are delimited by a delimiter. The string, if not empty, has to start with a delimiter.

Parameters
stringString.
delimiterDelimiter between state names.
Returns
True if successful.

◆ getInwardsIteratorBegin()

NestedName::Impl::const_iterator state_machine::NestedName::getInwardsIteratorBegin ( ) const

Get a constant inwards iterator pointing to the name of the outermost state.

Returns
Constant inwards iterator pointing to the name of the outermost state.

◆ getInwardsIteratorEnd()

NestedName::Impl::const_iterator state_machine::NestedName::getInwardsIteratorEnd ( ) const

Get an inwards iterator pointing to the name of the innermost state.

Returns
Inwards iterator pointing to the name of the innermost state.

◆ getNameOfInnermostState()

std::string state_machine::NestedName::getNameOfInnermostState ( ) const

Get the name of the innermost state. Prints an error if the nested name is empty.

Returns
Name of the innermost state. Empty string if the nested name is empty.

◆ getNameOfOutermostState()

std::string state_machine::NestedName::getNameOfOutermostState ( ) const

Get the name of the outermost state. Prints an error if the nested name is empty.

Returns
Name of the outermost state. Empty string if the nested name is empty.

◆ getNameOfState()

std::string state_machine::NestedName::getNameOfState ( const size_t  nesting) const

Get the name of the state at a certain level of nesting. Prints an error if the nested name is empty.

Parameters
nestingLevel of nesting. 0 for outermost state, getNumberOfNestings()-1 for innermost state.
Returns
Name of the state. Empty string if the nested name is empty.

◆ getNumberOfNestings()

size_t state_machine::NestedName::getNumberOfNestings ( ) const

Get the number of nestings. If it is 1, it is a simple name. If it is >1, it contains one or multiple parent state names.

Returns
Number of nestings.

◆ getOutwardsIteratorBegin()

NestedName::Impl::const_reverse_iterator state_machine::NestedName::getOutwardsIteratorBegin ( ) const

Get an inwards iterator pointing to the name of the innermost state.

Returns
Inwards iterator pointing to the name of the innermost state.

◆ getOutwardsIteratorEnd()

NestedName::Impl::const_reverse_iterator state_machine::NestedName::getOutwardsIteratorEnd ( ) const

Get an inwards iterator pointing to the name of the outermost state.

Returns
Inwards iterator pointing to the name of the outermost state.

◆ operator<()

bool state_machine::NestedName::operator< ( const NestedName other) const

Less than comparison operator. Internally compares the string representations of the two nested strings.

Parameters
otherNested name to compare to.
Returns
True if this is less than the other nested name.

◆ operator==()

bool state_machine::NestedName::operator== ( const NestedName other) const

Equal to comparison operator. Internally compares the string representations of the two nested strings.

Parameters
otherNested name to compare to.
Returns
True if this is equal to the other nested name.

◆ removeInnermostState()

NestedName & state_machine::NestedName::removeInnermostState ( )

Remove the innermost state's name.

Returns
Reference to this nested name.

◆ removeOutermostState()

NestedName & state_machine::NestedName::removeOutermostState ( )

Remove the outermost state's name.

Returns
Reference to this nested name.

◆ toString()

std::string state_machine::NestedName::toString ( const std::string &  delimiter = STATE_MACHINE_NESTED_NAME_DEFAULT_DELIMITER) const

Convert the nested name to a string, where the name of the states are delimited by a delimiter. The string, if not empty, will start with a delimiter.

Parameters
delimiterDelimiter between state names.
Returns
String.

Member Data Documentation

◆ impl_

Impl state_machine::NestedName::impl_
protected

Members set during execution.


The documentation for this class was generated from the following files: