Class simulation_framework::autonomy::cli::CliProvider
Last update: 22.04.2026
Definition: autonomy/cli/cli_provider/cli_provider.h (line 72)
Provides a command-line interface for simulation execution via dependency injection.
This class facilitates the creation of a command-line executable that executes a simulation on a specific simulation instance. The simulation instance is provided through a concrete implementation of the ISimInstanceCreator interface, enabling flexibility and modularity.
The design supports scenarios where different simulation instances need to be created dynamically based on the implementation of the ISimInstanceCreator.
An example of executable creation using CliProvider. See also: ISimInstanceCreator, core::SimulationParameters
#include "autonomy/cli/cli_provider/cli_provider.h"
#include "your_sim_instance_creator.h"
enum CliReturnCode
{
kSuccess = 0,
kParserError = 1,
kCliError = 2
};
int main(int argc, const char** argv)
{
auto cli_provider = std::make_unique<autonomy::cli::CliProvider>(
std::move(std::make_unique<YourSimInstanceCreator>()));
if (cli_provider->Parse(argc, argv))
{
if (!cli_provider->GetCommandLineInterface()->Execute())
{
return CliReturnCode::kCliError;
}
return CliReturnCode::kSuccess;
}
return CliReturnCode::kParserError;
}
Members
Public functions
Function CliProvider
simulation_framework::autonomy::cli::CliProvider::CliProvider(std::unique_ptr< ISimInstanceCreator > sim_instance_creator)
Construct CliProvider to execute simulation based on given instance through command line options or args.
Parameters:
- sim_instance_creator: An implementation of interface 'ISimInstanceCreator', showing how your simulation should be constructed
Parameters:
- std::unique_ptr< ISimInstanceCreator > sim_instance_creator
Return type:
Function ~CliProvider
simulation_framework::autonomy::cli::CliProvider::~CliProvider()=default
Default Destructor.
Return type:
Function GetCommandLineInterface
const std::unique_ptr< core::Cli > & simulation_framework::autonomy::cli::CliProvider::GetCommandLineInterface()
Accesser of Cli reference.
Returns:
The reference of 'core::Cli' object to let you do execution or enable the cli controller
Return type: const std::unique_ptr< core::Cli > &
Function GetCoreParameters
core::SimulationParameters simulation_framework::autonomy::cli::CliProvider::GetCoreParameters() const
Accesser of simulation parameters.
Returns:
The generic simulation parameters parsed from command line inputs
Return type: core::SimulationParameters
Function Parse
bool simulation_framework::autonomy::cli::CliProvider::Parse(int argc, const char **argv)
Parses command-line arguments.
Processes the arguments passed from the process main function, allowing the application to configure or initialize based on the provided input. This function typically interprets options, flags, and positional arguments supplied via the command line.
Parameters:
- argc: The number of arguments passed to the program, including the executable name.
- argv: An array of C-style strings representing the arguments.
Returns:
true if the arguments were successfully parsed; otherwise, false.
Parameters:
Return type: bool