Class YasminFactory

Class Documentation

class YasminFactory

Factory class to create state machines from XML files.

This class provides methods to parse XML files and create yasmin state machines, including states, concurrence, and nested state machines.

Public Functions

YasminFactory()

Constructs a YasminFactory instance.

Initializes the pluginlib class loader for yasmin::State classes.

~YasminFactory()

Destructor.

yasmin::State::SharedPtr create_state(tinyxml2::XMLElement *state_elem) const

Creates a state from an XML element.

Parameters:

state_elem – Pointer to the XML element defining the state.

Throws:

std::runtime_error – If the state type is unknown or required attributes are missing.

Returns:

A shared pointer to the created State.

yasmin::Concurrence::SharedPtr create_concurrence(tinyxml2::XMLElement *conc_elem)

Creates a concurrence from an XML element.

Parameters:

conc_elem – Pointer to the XML element defining the concurrence.

Throws:

std::runtime_error – If required attributes are missing or the XML structure is invalid.

Returns:

A shared pointer to the created Concurrence.

yasmin::StateMachine::SharedPtr create_sm(tinyxml2::XMLElement *root)

Recursively creates a state machine from an XML element.

Parameters:

root – Pointer to the XML element defining the state machine.

Throws:

std::runtime_error – If the XML structure is invalid.

Returns:

A shared pointer to the created StateMachine.

yasmin::StateMachine::SharedPtr create_sm_from_file(const std::string &xml_file)

Creates a state machine from an XML file.

Parameters:

xml_file – Path to the XML file defining the state machine.

Throws:

std::runtime_error – If the file cannot be loaded or the XML structure is invalid.

Returns:

A shared pointer to the created StateMachine.

void cleanup()

Explicitly cleanup the factory resources.

This method should be called before the plugin loader is destroyed to avoid class loader warnings.