GlsMenu
gls_menu_dictionary.h
Go to the documentation of this file.
1 
41 #if !defined(GLS_MENUDICTIONARY_H)
42 #define GLS_MENUDICTIONARY_H
43 
44 #ifdef WIN32
45 #pragma warning (disable:4786)
46 #endif
47 
48 #include <string>
49 #include <iomanip>
50 
51 #include "disti_metadata.h"
52 #include "gls_menu_data.h"
53 
54 //============================================================================
64 //============================================================================
65 class GlsMenuDictionary : public disti::DistiAttribDict
66 {
67 public:
68  //------------------------------------------------------------------------
81  //------------------------------------------------------------------------
82  std::string Expand(
83  const std::string& str,
84  const char* startDelim = "$(",
85  const char* endDelim = ")");
86 
87  //------------------------------------------------------------------------
95  //------------------------------------------------------------------------
96  template <class T>
97  void Attach(const std::string& name, T*& t)
98  {
99  GlsMenuData_T<T>* data =
100  dynamic_cast<GlsMenuData_T<T>*>(Get(disti::AttributeName(name)));
101  if (data)
102  data->Attach(t);
103  }
104 
105  //------------------------------------------------------------------------
116  //------------------------------------------------------------------------
117  template <class T>
118  bool Refer(const std::string& name, T& t)
119  {
120  bool success(false);
121  GlsMenuData_T<T>* data =
122  dynamic_cast<GlsMenuData_T<T>*>(Get(disti::AttributeName(name)));
123  if (data)
124  success = data->ReferTo(t);
125  return success;
126  }
127 
128  //------------------------------------------------------------------------
140  //------------------------------------------------------------------------
141  template <class T>
142  bool ReferCopy(const std::string& name, T& t)
143  {
144  bool success(false);
145  GlsMenuData_T<T>* data =
146  dynamic_cast<GlsMenuData_T<T>*>(Get(disti::AttributeName(name)));
147  if (data)
148  {
149  T currentVal = data->Value();
150  success = data->ReferTo(t);
151  if (success)
152  {
153  data->Value(currentVal);
154  }
155  }
156  return success;
157  }
158 };
159 
160 
161 #endif // GLS_MENUDICTIONARY_H
162 
This file defines all menu meta-data classes.
bool ReferCopy(const std::string &name, T &t)
virtual const T & Value() const
virtual void Attach(T *&data)
virtual bool ReferTo(T &data)
void Attach(const std::string &name, T *&t)
bool Refer(const std::string &name, T &t)
std::string Expand(const std::string &str, const char *startDelim="$(", const char *endDelim=")")