The Command class builds the syntactic template for a specific command defined in a CommandParams struct. More...
#include <command.h>
Public Member Functions | |
Command () | |
Command default constructor. More... | |
Command (const CommandParams &cmdParams, const std::shared_ptr< Syntax > syntax, const std::unordered_map< std::string, std::shared_ptr< CommandOptions >> &options) | |
Command constructor. More... | |
void | generateCommand (const Parameter::ParameterMap &inputParams, std::string &out) |
Generates a command string from the internal template given all necessary parameter values. More... | |
void | generateCommand (const Parameter::ParameterMap &inputParams, const std::vector< std::string > &options, std::string &out) |
Generates a command string from the internal template given all necessary parameter values and options. This method is able to take an options list as an additional argument to modify its internal command template. More... | |
const std::string & | getName () const |
Getter for the unique name attribute. More... | |
const bool | verifyResponse (const Parameter::ParameterMap &inputParams, const std::string &responseOrig, Parameter::ParameterMap &outputParams) |
Verifies a given response based on the internal template given all necessary input parameter values. More... | |
const bool | verifyResponse (const Parameter::ParameterMap &inputParams, const std::vector< std::string > &options, const std::string &responseOrig, Parameter::ParameterMap &outputParams) |
Verifies a given response based on the internal template given all necessary input parameter values and options. This method is able to take an options list as an additional argument to verify a modified command template. More... | |
Private Types | |
typedef void(Command::* | insertInstruction) (const int &, const Parameter::ParameterMap &, std::string &out) |
Command template building function pointer type. More... | |
Private Member Functions | |
void | insertCmdKeyword (const int &index, const Parameter::ParameterMap &input, std::string &out) |
Command template building function for a keyword token. More... | |
void | insertCmdParameter (const int &index, const Parameter::ParameterMap &input, std::string &out) |
Command template building function for a parameter token. More... | |
Private Attributes | |
bool | cmdHasParams |
bool | cmdHasResponse |
std::vector< std::string > | cmdKeyWords |
std::vector< std::string > | cmdParameter |
std::unordered_set< std::string > | cmdParameterSet |
std::vector< std::pair< int, insertInstruction > > | commandTemplate |
std::string | name |
std::unordered_map< std::string, std::shared_ptr< CommandOptions > > | options |
std::unordered_map< std::string, std::string > | parameterTypes |
bool | respHasParams |
std::vector< std::pair< std::string, bool > > | responseTemplate |
std::string | simpleResponse |
std::shared_ptr< Syntax > | syntax |
The Command class builds the syntactic template for a specific command defined in a CommandParams struct.
A Command object builds its command message given the required parameter values. It can also verfy if a given response is valid, given the input parameters of the previously sent command.
If a non empty CommandOptions list was given on initilization, a command object can change its command template based on required options.
|
private |
Command::Command | ( | ) |
Command default constructor.
Definition at line 9 of file command.cpp.
Command::Command | ( | const CommandParams & | cmdParams, |
const std::shared_ptr< Syntax > | syntax, | ||
const std::unordered_map< std::string, std::shared_ptr< CommandOptions >> & | options | ||
) |
Command constructor.
[in] | cmdParams | CommandParams struct that is used to configure a Command object. |
[in] | cmdResponsePrefix | Marks the beginning of a response. |
[in] | options | Map of possible options, that may modify this command. (first: name, second: CommandOptions) |
[in] | optionsPrefix | Marks the appearance of an option within a command template. |
std::exception |
Definition at line 11 of file command.cpp.
void Command::generateCommand | ( | const Parameter::ParameterMap & | inputParams, |
std::string & | out | ||
) |
Generates a command string from the internal template given all necessary parameter values.
[in] | inputParams | Input parameter map, containing all necessary parameter values and types to create a command. |
[out] | out | Generated command string. |
std::exception |
Definition at line 88 of file command.cpp.
void Command::generateCommand | ( | const Parameter::ParameterMap & | inputParams, |
const std::vector< std::string > & | options, | ||
std::string & | out | ||
) |
Generates a command string from the internal template given all necessary parameter values and options. This method is able to take an options list as an additional argument to modify its internal command template.
[in] | inputParams | Input parameter map, containing all necessary parameter values and types to create a command, including parameter values required by given options. |
[in] | options | List of options, to be applied to a command. |
[out] | out | Generated command string. |
std::exception |
Definition at line 102 of file command.cpp.
const std::string & Command::getName | ( | ) | const |
Getter for the unique name attribute.
Definition at line 373 of file command.cpp.
|
private |
Command template building function for a keyword token.
[in] | index | Index of the keyword in the cmdKeyWords list. |
[in] | input | Pointer to a ParameterMap object, unused in this function. |
[out] | out | Output string, containing the keyword. |
Definition at line 375 of file command.cpp.
|
private |
Command template building function for a parameter token.
[in] | index | Index of the parameter in the cmdParameter list. |
[in] | input | Pointer to a ParameterMap object, used to get the required parameter value. |
[out] | out | Output string, containing the parameter value as string. |
Definition at line 386 of file command.cpp.
const bool Command::verifyResponse | ( | const Parameter::ParameterMap & | inputParams, |
const std::string & | responseOrig, | ||
Parameter::ParameterMap & | outputParams | ||
) |
Verifies a given response based on the internal template given all necessary input parameter values.
[in] | inputParams | Input parameter map, containing all necessary parameter values and types to verify a response. |
[in] | responseOrig | Response on command to be verified. |
[out] | outputParams | If the command requested returned parameters, those will be put here. |
std::exception |
Definition at line 134 of file command.cpp.
const bool Command::verifyResponse | ( | const Parameter::ParameterMap & | inputParams, |
const std::vector< std::string > & | options, | ||
const std::string & | responseOrig, | ||
Parameter::ParameterMap & | outputParams | ||
) |
Verifies a given response based on the internal template given all necessary input parameter values and options. This method is able to take an options list as an additional argument to verify a modified command template.
[in] | inputParams | Input parameter map, containing all necessary parameter values and types to verify a response, including parameter values required by given options. |
[in] | options | List of options, which have been applied to a command. |
[in] | responseOrig | Response on command to be verified. |
[out] | outputParams | If the command or command options requested returned parameters, those will be put here. |
std::exception |
Definition at line 208 of file command.cpp.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
Map of possible options, that may modify this command. (first: name, second: CommandOptions)
|
private |
|
private |
|
private |
|
private |
|
private |