| 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 | namespace MoleCuilder {
 | 
|---|
| 21 | 
 | 
|---|
| 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 |  */
 | 
|---|
| 32 | class ActionTraits : public OptionTrait {
 | 
|---|
| 33 | public:
 | 
|---|
| 34 |   ActionTraits(const ActionTraits &_Traits);
 | 
|---|
| 35 |   ActionTraits(const OptionTrait &_Traits, const std::string _MenuTitle = "", const int _MenuPosition = 0);
 | 
|---|
| 36 |   explicit ActionTraits(const std::string &_token);
 | 
|---|
| 37 |   virtual ~ActionTraits();
 | 
|---|
| 38 | 
 | 
|---|
| 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;
 | 
|---|
| 42 | 
 | 
|---|
| 43 |   const std::string& getMenuName() const;
 | 
|---|
| 44 |   int getMenuPosition() const;
 | 
|---|
| 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;
 | 
|---|
| 51 | 
 | 
|---|
| 52 |   options_iterator getBeginIter();
 | 
|---|
| 53 |   options_iterator getEndIter();
 | 
|---|
| 54 |   options_const_iterator getBeginIter() const;
 | 
|---|
| 55 |   options_const_iterator getEndIter() const;
 | 
|---|
| 56 | 
 | 
|---|
| 57 | protected:
 | 
|---|
| 58 | 
 | 
|---|
| 59 |   // internal information this trait contains
 | 
|---|
| 60 |   std::string MenuTitle;
 | 
|---|
| 61 |   int MenuPosition;
 | 
|---|
| 62 |   options_map Options;
 | 
|---|
| 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 | 
 | 
|---|
| 81 | }
 | 
|---|
| 82 | 
 | 
|---|
| 83 | #endif /* ACTIONTRAITS_HPP_ */
 | 
|---|