GlsMenu  1.5.4
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 <iomanip>
49 # include <string>
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 = dynamic_cast<GlsMenuData_T<T>*>( Get( disti::AttributeName( name ) ) );
100  if( data )
101  data->Attach( t );
102  }
103 
104  //------------------------------------------------------------------------
115  //------------------------------------------------------------------------
116  template<class T>
117  bool Refer( const std::string& name, T& t )
118  {
119  bool success( false );
120  GlsMenuData_T<T>* data = dynamic_cast<GlsMenuData_T<T>*>( Get( disti::AttributeName( name ) ) );
121  if( data )
122  success = data->ReferTo( t );
123  return success;
124  }
125 
126  //------------------------------------------------------------------------
138  //------------------------------------------------------------------------
139  template<class T>
140  bool ReferCopy( const std::string& name, T& t )
141  {
142  bool success( false );
143  GlsMenuData_T<T>* data = dynamic_cast<GlsMenuData_T<T>*>( Get( disti::AttributeName( name ) ) );
144  if( data )
145  {
146  T currentVal = data->Value();
147  success = data->ReferTo( t );
148  if( success )
149  {
150  data->Value( currentVal );
151  }
152  }
153  return success;
154  }
155 };
156 
157 #endif // GLS_MENUDICTIONARY_H
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=")")