Wolframe, 0.0.3

Command handler module

The configuration of the command handler module example is defined in a descriptive way. If you want to learn more about how to define a configuration by declaring first the data members and then the description for introspection, you will find an example at Descriptive configuration declaration example

#include "cmdbind/commandHandlerUnit.hpp"
#include <vector>
class MyCommandHandlerConfig
{
public:
// ... define your configuration data members here
static const _Wolframe::serialize::StructDescriptionBase* getStructDescription()
{
// ... return your introspection description reference of the configuration here
}
MyCommandHandlerConfig( const char* classname, const char* title, const char* logprefix, const char* subsection)
:_Wolframe::serialize::DescriptiveConfiguration( title, "authentication", logprefix, getStructDescription())
{
setBasePtr( (void*)this); // ... mandatory to set pointer to start of configuration
}
};
class MyCommandHandlerUnit
{
public:
// ... your command handler unit definition is here
MyCommandHandlerUnit( const MyCommandHandlerConfig* cfg)
{
// ... required constructor from configuration
}
{
// ... load your command handler programs here
}
virtual std::vector<std::string> commands() const
{
// ... return the commands of the command handler here
}
virtual _Wolframe::cmdbind::CommandHandler* createCommandHandler( const std::string& cmdname, const std::string& docformat)
{
// ... create and return an instance of a command handler for executing the command cmdname here
}
};
WF_MODULE_BEGIN( "MyCommandHandler", "my command handler short description")
WF_COMMAND_HANDLER( "MyCommandHandler", "cmdhandler", "mycmd", MyCommandHandlerUnit, MyCommandHandlerConfig)