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 |
|
---|
16 | #include <map>
|
---|
17 |
|
---|
18 | #include "Actions/OptionTrait.hpp"
|
---|
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 | */
|
---|
30 | class ActionTraits : public OptionTrait {
|
---|
31 | public:
|
---|
32 | ActionTraits(const ActionTraits &_Traits);
|
---|
33 | ActionTraits(const OptionTrait &_Traits, const std::string _MenuTitle = "", const int _MenuPosition = 0);
|
---|
34 | explicit ActionTraits(const std::string &_token);
|
---|
35 | virtual ~ActionTraits();
|
---|
36 |
|
---|
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;
|
---|
40 |
|
---|
41 | const std::string& getMenuName() const;
|
---|
42 | int getMenuPosition() const;
|
---|
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;
|
---|
49 |
|
---|
50 | options_iterator getBeginIter();
|
---|
51 | options_iterator getEndIter();
|
---|
52 | options_const_iterator getBeginIter() const;
|
---|
53 | options_const_iterator getEndIter() const;
|
---|
54 |
|
---|
55 | protected:
|
---|
56 |
|
---|
57 | // internal information this trait contains
|
---|
58 | std::string MenuTitle;
|
---|
59 | int MenuPosition;
|
---|
60 | options_map Options;
|
---|
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_ */
|
---|