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