[df32ee] | 1 | /*
|
---|
| 2 | * ActionTraits.hpp
|
---|
| 3 | *
|
---|
| 4 | * Created on: Oct 26, 2010
|
---|
| 5 | * Author: heber
|
---|
| 6 | */
|
---|
| 7 |
|
---|
| 8 | #ifndef ACTIONTRAITS_HPP_
|
---|
| 9 | #define ACTIONTRAITS_HPP_
|
---|
| 10 |
|
---|
| 11 | // include config.h
|
---|
| 12 | #ifdef HAVE_CONFIG_H
|
---|
| 13 | #include <config.h>
|
---|
| 14 | #endif
|
---|
| 15 |
|
---|
[53be34] | 16 | #include <map>
|
---|
[e4afb4] | 17 |
|
---|
| 18 | #include "Actions/OptionTrait.hpp"
|
---|
[df32ee] | 19 |
|
---|
| 20 | /** Interface for all ActionTraits.
|
---|
| 21 | * This class defines the interface, i.e. the common set of information that
|
---|
| 22 | * is stored in this traits for Action classes. It also defines a set of getter
|
---|
| 23 | * functions.
|
---|
| 24 | *
|
---|
| 25 | * Note that there are no setters. This is because the information is to be
|
---|
| 26 | * given in a specialized form of the templated class ActionTrait that derives
|
---|
| 27 | * from this interface.
|
---|
| 28 | *
|
---|
| 29 | */
|
---|
[e4afb4] | 30 | class ActionTraits : public OptionTrait {
|
---|
[df32ee] | 31 | public:
|
---|
[e4afb4] | 32 | ActionTraits(const ActionTraits &_Traits);
|
---|
[b59da6] | 33 | ActionTraits(const OptionTrait &_Traits, const std::string _MenuTitle = "", const int _MenuPosition = 0);
|
---|
[e4afb4] | 34 | explicit ActionTraits(const std::string &_token);
|
---|
[df32ee] | 35 | virtual ~ActionTraits();
|
---|
| 36 |
|
---|
[e4afb4] | 37 | typedef std::map< std::string, OptionTrait* > options_map;
|
---|
| 38 | typedef options_map::iterator options_iterator;
|
---|
| 39 | typedef options_map::const_iterator options_const_iterator;
|
---|
[53be34] | 40 |
|
---|
[e4afb4] | 41 | const std::string& getMenuName() const;
|
---|
[b59da6] | 42 | int getMenuPosition() const;
|
---|
[e4afb4] | 43 |
|
---|
| 44 | // getter for its options
|
---|
| 45 | OptionTrait const &getOption(const std::string &token) const;
|
---|
| 46 |
|
---|
| 47 | bool hasOption(const std::string &token) const;
|
---|
| 48 | bool hasOptions() const;
|
---|
[53be34] | 49 |
|
---|
| 50 | options_iterator getBeginIter();
|
---|
| 51 | options_iterator getEndIter();
|
---|
| 52 | options_const_iterator getBeginIter() const;
|
---|
| 53 | options_const_iterator getEndIter() const;
|
---|
[df32ee] | 54 |
|
---|
| 55 | protected:
|
---|
| 56 |
|
---|
| 57 | // internal information this trait contains
|
---|
[53be34] | 58 | std::string MenuTitle;
|
---|
| 59 | int MenuPosition;
|
---|
[e4afb4] | 60 | options_map Options;
|
---|
[df32ee] | 61 | };
|
---|
| 62 |
|
---|
| 63 | /* Templated class for ActionTraits to specialize.
|
---|
| 64 | * I.e. every action specializes its own ActionTrait and inherits the
|
---|
| 65 | * ActionTraits class as interface , e.g. Action called SuperAction:
|
---|
| 66 |
|
---|
| 67 | * ActionTrait<SuperAction> : public ActionTraits
|
---|
| 68 | *
|
---|
| 69 | * within the constructor of said ActionTrait<SuperAction> the specific
|
---|
| 70 | * information for this derived Action class is then given.
|
---|
| 71 | */
|
---|
| 72 | template <class T>
|
---|
| 73 | class ActionTrait : public ActionTraits {
|
---|
| 74 | public:
|
---|
| 75 | ActionTrait();
|
---|
| 76 | ~ActionTrait();
|
---|
| 77 | };
|
---|
| 78 |
|
---|
| 79 |
|
---|
| 80 | #endif /* ACTIONTRAITS_HPP_ */
|
---|