36 unordered_map<jsonifier::vector<jsonifier::string>, unique_ptr<base_function>> functions{};
39 functions[functionNames] = std::move(baseFunction);
48 co_await newThreadAwaitable<void>();
49 base_function_arguments theArgsNewer{ theArgsNew };
50 unique_ptr<base_function> functionPointer{ getCommand(theArgsNewer.getCommandName()) };
51 if (!functionPointer.get()) {
55 functionPointer->execute(theArgsNew);
59 unique_ptr<base_function> command_controller::getCommand(jsonifier::string_view commandName) {
60 jsonifier::string functionName{};
62 if (commandName.size() > 0) {
63 for (
auto const& [keyFirst, value]: functions) {
64 for (
auto& key: keyFirst) {
65 if (key.find(convertToLowerCase(commandName)) != jsonifier::string::npos) {
67 functionName = convertToLowerCase(commandName.substr(0, key.size()));
74 unique_ptr<base_function> newValue = createFunction(functionName);
80 unique_ptr<base_function> command_controller::createFunction(jsonifier::string_view functionName) {
81 for (
auto& [key01, value01]: functions) {
82 for (
auto& value02: key01) {
83 if (functionName == value02) {
84 return value01->create();
A co_routine - representing a potentially asynchronous operation/function.
unordered_map< jsonifier::vector< jsonifier::string >, unique_ptr< base_function > > & getFunctions()
For returning the contained map of functions.
void registerFunction(const jsonifier::vector< jsonifier::string > &functionNames, unique_ptr< base_function > baseFunction)
Registers a function to be called.
Command data, for functions executed by the command_controller.
A smart pointer class that provides unique ownership semantics.
The main namespace for the forward-facing interfaces.
Base arguments for the command classes.