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