[014bc4] | 1 | /*
|
---|
| 2 | * controller_AddOn.hpp
|
---|
| 3 | *
|
---|
| 4 | * Created on: 01.06.2012
|
---|
| 5 | * Author: heber
|
---|
| 6 | */
|
---|
| 7 |
|
---|
| 8 | #ifndef CONTROLLER_ADDON_HPP_
|
---|
| 9 | #define CONTROLLER_ADDON_HPP_
|
---|
| 10 |
|
---|
| 11 | // include config.h
|
---|
| 12 | #ifdef HAVE_CONFIG_H
|
---|
| 13 | #include <config.h>
|
---|
| 14 | #endif
|
---|
| 15 |
|
---|
| 16 |
|
---|
| 17 | #include <boost/function.hpp>
|
---|
| 18 | #include <boost/program_options.hpp>
|
---|
| 19 |
|
---|
| 20 | class ControllerCommand;
|
---|
| 21 | class ControllerCommandRegistry;
|
---|
| 22 | class ControllerInfo;
|
---|
| 23 | class ControllerOptions;
|
---|
| 24 | class FragmentController;
|
---|
| 25 |
|
---|
| 26 | struct controller_AddOn;
|
---|
| 27 |
|
---|
| 28 | /** This is the allocator function for the specific controller addon structure.
|
---|
| 29 | *
|
---|
| 30 | * The implementation should reside in its own module such that it can be
|
---|
| 31 | * linked in unison with the \file controller.cpp and the derived implementation
|
---|
| 32 | * of controller_AddOn to the executable controller.
|
---|
| 33 | */
|
---|
| 34 | extern "C++" controller_AddOn *getAddOn();
|
---|
| 35 |
|
---|
| 36 | /** This is the structure that contains functions to extend the functionality
|
---|
| 37 | * of the basic controller with respect to certain jobs and commands.
|
---|
| 38 | *
|
---|
| 39 | * Here, we have four types of functions:
|
---|
| 40 | * -# Allocator: Required to allocate to specific function which contains
|
---|
| 41 | * extended member variables and parsing functions.
|
---|
| 42 | * -# Commands: Add more commands to the registry of the controller.
|
---|
| 43 | * -# Options: Add more command-line options to require additional information
|
---|
| 44 | * from the user.
|
---|
| 45 | * -# Parsers: Add parsing function to place parameter from command-line
|
---|
| 46 | * into internal structure allocated via Allocator.
|
---|
| 47 | *
|
---|
| 48 | * The allocated structure is the one which contains all information for the
|
---|
| 49 | * execution of these commands. Note that some defaults are already parsed
|
---|
| 50 | * and stored therein by the controller by default.
|
---|
| 51 | *
|
---|
| 52 | * \note All these functions are called within the basic controller, hence
|
---|
| 53 | * all parameters are instances of this basic controller.
|
---|
| 54 | */
|
---|
| 55 | struct controller_AddOn {
|
---|
| 56 | /** Function to allocate a derived variant of ControllerOptions which might
|
---|
| 57 | * be extended by own member variables and parsing functions.
|
---|
| 58 | *
|
---|
| 59 | * \return Pointer to allocated instance of ControllerOptions or derived.
|
---|
| 60 | */
|
---|
| 61 | virtual ControllerOptions *allocateControllerInfo()=0;
|
---|
| 62 |
|
---|
| 63 | /** Function to register new commands communicating with a server.
|
---|
| 64 | *
|
---|
| 65 | * \param registrator registrator function for the generated ControllerCommand
|
---|
| 66 | * \param controller access to controller to bind to its functions
|
---|
| 67 | * \param ControllerInfo All other options of the controller
|
---|
| 68 | */
|
---|
| 69 | virtual void addSpecificCommands(
|
---|
| 70 | boost::function<void (ControllerCommand *)> ®istrator,
|
---|
| 71 | FragmentController &controller,
|
---|
| 72 | ControllerOptions &ControllerInfo)=0;
|
---|
| 73 |
|
---|
| 74 | /** Function to add other command line options if more use input is required.
|
---|
| 75 | *
|
---|
| 76 | * \param option option_description entity that can be used to add another
|
---|
| 77 | * boost::program_options as follows:
|
---|
| 78 | * \code
|
---|
| 79 | * option("command,c", boost::program_options::, "description");
|
---|
| 80 | * \endcode
|
---|
| 81 | */
|
---|
| 82 | virtual void addSpecificOptions(
|
---|
| 83 | boost::program_options::options_description_easy_init option)=0;
|
---|
| 84 |
|
---|
| 85 | /** Function to add a parsing function for placing info from the command line
|
---|
| 86 | * option into \a ControllerInfo.
|
---|
| 87 | *
|
---|
| 88 | * \param ControllerInfo May be reinterpret_cast to true type as has been
|
---|
| 89 | * allocated in controller_AddOn::allocateControllerInfo.
|
---|
| 90 | * \param vm map of command line variables
|
---|
| 91 | * \return 0 - ok, else - some failure code (which leads to program exit)
|
---|
| 92 | */
|
---|
| 93 | virtual int addOtherParsings(
|
---|
| 94 | ControllerOptions &ControllerInfo,
|
---|
| 95 | boost::program_options::variables_map &vm)=0;
|
---|
| 96 | };
|
---|
| 97 |
|
---|
| 98 | #endif /* CONTROLLER_ADDON_HPP_ */
|
---|