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