/* * ControllerCommand.hpp * * Created on: 01.06.2012 * Author: heber */ #ifndef CONTROLLERCOMMAND_HPP_ #define CONTROLLERCOMMAND_HPP_ // include config.h #ifdef HAVE_CONFIG_H #include #endif #include #include #include /** ControllerCommand associates a single name with a certain deque of * (conntroller) commands. * * The ControllerCommand can be used as follows: * \code * ControllerCommand command; * for (ControllerCommand::const_iterator iter = command.begin(); * iter != command.end(); ++iter) { * ... * // execute current command * (*iter)(); * ... * } * \endcode * */ struct ControllerCommand { public: //!> commands are simply bound functions typedef boost::function commands_t; //!> typedef for deque with commands_t to execute typedef std::deque queue_t; //!> convenience constant iterator to queue_t typedef std::deque::const_iterator const_iterator; /** Constructor of class ControllerCommand. * * \param _name name of this command * \param _commands command queue to associated with this command */ ControllerCommand(const std::string &_name, const queue_t &_commands) : name(_name), commands(_commands) {} /** Destructor of class ControllerCommand. * */ ControllerCommand() {} /** Getter for begin of deque. * * \return iterator pointing at first command */ const_iterator begin() const { return commands.begin(); } /** Getter for one after end of command deque. * * \return iterator at one position after last command */ const_iterator end() const { return commands.end(); } /** Getter for internal name of this ControllerCommand. * * \note this is required for Repository pattern. * * \return name of this ControllerCommand */ const std::string &getName() const { return name; } private: //!> name of this ControllerCommand const std::string name; //!> commands to execute const queue_t commands; }; #endif /* CONTROLLERCOMMAND_HPP_ */