GlsMenu
|
#include <gls_menu_dictionary.h>
Public Types | |
typedef disti::DistiAttribDict::const_iterator | const_iterator |
typedef disti::DistiAttribDict::iterator | iterator |
Public Member Functions | |
std::string | Expand (const std::string &str, const char *startDelim="$(", const char *endDelim=")") |
template<class T > | |
void | Attach (const std::string &name, T *&t) |
template<class T > | |
bool | Refer (const std::string &name, T &t) |
template<class T > | |
bool | ReferCopy (const std::string &name, T &t) |
GlsMenuDictionary & | operator= (const disti::DistiAttribDict &dict) |
GlsMenuDictionary & | operator= (const GlsMenuDictionary &dict) |
void | CopyCommonValues (const disti::DistiAttribDict &dict) |
void | CopyCommonValues (const GlsMenuDictionary &dict) |
bool | operator== (const disti::DistiAttribDict &other) |
bool | operator== (const GlsMenuDictionary &other) |
virtual void | Add (disti::DistiAttributeBase *attr) |
const_iterator | Begin () const |
const_iterator | End () const |
iterator | Begin () |
iterator | End () |
int | Count () const |
int | Count (const disti::AttributeName &name) const |
void | Clear () |
virtual void | Delete (const disti::AttributeName &name) |
virtual void | ReadStrings (std::istream &instr) |
virtual void | Write (std::ostream &outstr, bool changedDataOnly=false) |
virtual bool | Read (std::istream &instr) |
bool | ReadAndCaptureMissing (std::istream &instr, std::stringstream *missingStream) |
virtual std::string | ValueString (const disti::AttributeName &name) const |
virtual void | ValueString (const disti::AttributeName &name, const std::string &val) |
long | ValueInt (const disti::AttributeName &name) const |
void | ValueInt (const disti::AttributeName &name, long val) |
virtual std::ostream & | WriteValue (const disti::AttributeName &name, std::ostream &outstr) |
virtual std::istream & | ReadValue (const disti::AttributeName &name, std::istream &instr) |
virtual disti::DistiAttributeBase * | Get (const disti::AttributeName &name) const |
virtual bool | IsEqual (const disti::AttributeName &name, const long val) const |
virtual void | Remove (const disti::AttributeName &name) |
Static Public Member Functions | |
static void | SpacingInc () |
static void | SpacingDec () |
static void | SpacingZero () |
static std::string | SpacingString () |
static bool | ScanToken (std::istream &instr, std::string &result) |
Private Attributes | |
disti::DistiAttribDict | _attribDict |
The GlsMenuDictionary provides a container for simulation meta-data used within a menuing system (a menu data dictionary). Using the dictionary provides the link between the menu scripts and the program's run-time code. The program can retrieve data items from the dictionary and alter their values programmatically to affect the states of menus. Conversely, the menu scripts can also alter data items within the dictionary that affect the states of menus and the states of displays in the program.
Definition at line 61 of file gls_menu_dictionary.h.
typedef disti::DistiAttribDict::const_iterator GlsMenuDictionary::const_iterator |
Definition at line 158 of file gls_menu_dictionary.h.
typedef disti::DistiAttribDict::iterator GlsMenuDictionary::iterator |
Definition at line 159 of file gls_menu_dictionary.h.
|
inlinevirtual |
Adds the specified Attribute to the list. The object passed in becomes the responsibility of this class, and should NOT be deleted by the caller. It will be deleted by this class as needed
Definition at line 194 of file gls_menu_dictionary.h.
References _attribDict.
Referenced by GlsMenu_T< MenuItem_t, GlsMFD::MenuItemId_t >::GlsMenu_T(), GlsMenuSet_T< MenuType_t, DataFactory_t >::GlsMenuSet_T(), GlsMFDMenu_T< MenuItem_t, Submenu_t, PageId_t >::GlsMFDMenu_T(), and GlsMFDSubmenu_T< MenuItemId_t >::GlsMFDSubmenu_T().
|
inline |
Attach a pointer to the dictionary data item. This allows the developer to dereference a "local" pointer to update or read the value of the item without having to perform a dictionary lookup and type cast for every access. t will be 0 upon a failure to attach.
Definition at line 93 of file gls_menu_dictionary.h.
References GlsMenuData_T< T >::Attach(), and Get().
|
inline |
Definition at line 196 of file gls_menu_dictionary.h.
References _attribDict.
Referenced by GlsMFDMenu_T< MenuItem_t, Submenu_t, PageId_t >::ReadValue().
|
inline |
Definition at line 198 of file gls_menu_dictionary.h.
References _attribDict.
|
inline |
Removes all elements in the list, deleting the data as it goes
Definition at line 208 of file gls_menu_dictionary.h.
References _attribDict.
|
inline |
Copies the values for all items which have matching names between this object and dict. All other values are ignored
Definition at line 181 of file gls_menu_dictionary.h.
References _attribDict.
Referenced by operator=().
|
inline |
Definition at line 182 of file gls_menu_dictionary.h.
References _attribDict.
|
inline |
Returns the current number of elements in the dictionary
Definition at line 202 of file gls_menu_dictionary.h.
References _attribDict.
|
inline |
Returns the number of elements with the same name in the dictionary
Definition at line 205 of file gls_menu_dictionary.h.
References _attribDict.
|
inlinevirtual |
Removes the attribute specified by name from the dictionary and deletes the data. This does actually delete the attribute.
Definition at line 213 of file gls_menu_dictionary.h.
References _attribDict.
|
inline |
Definition at line 197 of file gls_menu_dictionary.h.
References _attribDict.
Referenced by GlsMFDMenu_T< MenuItem_t, Submenu_t, PageId_t >::ReadValue(), and GlsMenuItem_T< State_t >::State().
|
inline |
Definition at line 199 of file gls_menu_dictionary.h.
References _attribDict.
std::string GlsMenuDictionary::Expand | ( | const std::string & | str, |
const char * | startDelim = "$(" , |
||
const char * | endDelim = ")" |
||
) |
Expands any "environment variables" found within the string str parameter. An environment variable is the name of a dictionary data item that should exist within the dictionary. The name should be delimited by startDelim and endDelim.
Eg. would represent a dictionary data item named "VarName" and whose value will be returned if found in the dictionary. If the value of 'VarName' is '1234', then: Expand("$(VarName)") will return the string 1234
Referenced by GlsMFDSubmenu_T< MenuItemId_t >::Label().
|
inlinevirtual |
Returns the DistiAttributeBase* for the specified name If not found it returns NULL
Definition at line 264 of file gls_menu_dictionary.h.
References _attribDict.
Referenced by Attach(), GlsMenuSet_T< MenuType_t, DataFactory_t >::IncData(), GlsMenuDataGroup_T< T >::Item(), GlsMenuHandlerGroup_T< Menu_t >::Item(), GlsMFDMenu_T< MenuItem_t, Submenu_t, PageId_t >::ReadValue(), Refer(), and ReferCopy().
|
inlinevirtual |
Retuns a comparison of val with ValueInt() of the attribute looked up by name Returns false if not found
Definition at line 269 of file gls_menu_dictionary.h.
References _attribDict.
|
inline |
Copies the values for all items which have matching names between this object and dict. All other values are ignored
Definition at line 166 of file gls_menu_dictionary.h.
References CopyCommonValues().
|
inline |
Definition at line 173 of file gls_menu_dictionary.h.
References CopyCommonValues().
|
inline |
Equality operator Compares length, names and values. order does not matter
Definition at line 187 of file gls_menu_dictionary.h.
References _attribDict.
|
inline |
Definition at line 188 of file gls_menu_dictionary.h.
References _attribDict.
|
inlinevirtual |
Reads multiple attributes from the stream expecting the form: "NAME: VALUE" Returns true if something was found and set.
Definition at line 233 of file gls_menu_dictionary.h.
References _attribDict.
Referenced by GlsMFDMenuSet_T< MenuType_t, DataFactory_t >::Read(), and GlsMenuSet_T< MenuType_t, DataFactory_t >::Read().
|
inline |
Reads multiple attributes from the stream expecting the form: "NAME: VALUE" missing stream is filled with attributes that were not in the dictionary Returns true if something was found and set.
Definition at line 239 of file gls_menu_dictionary.h.
References _attribDict.
|
inlinevirtual |
Reads a stream, expecting each line to be of the form NAME: SomeStringValue For each line a new DistiAttribute<std::string> is created, and the remaining line is placed as it's value. This is intended for special uses and is not considered the 'normal' mode of operation
Definition at line 221 of file gls_menu_dictionary.h.
References _attribDict.
|
inlinevirtual |
Calls ReadValue() for the attribute specified by name
Definition at line 260 of file gls_menu_dictionary.h.
References _attribDict.
|
inline |
Changes the dictionary so that an existing dictionary data item will refer to the "local" variable whose reference is passed as a parameter. This allows the developer to reference a "local" variable to update or read the value of the item without having to perform a dictionary lookup and type cast for every access. Changes to the variable will automatically be reflected in the dictionary.
The parameter t will maintain its current value.
Definition at line 113 of file gls_menu_dictionary.h.
References Get(), and GlsMenuData_T< T >::ReferTo().
|
inline |
Changes the dictionary so that an existing dictionary data item will refer to the "local" variable whose reference is passed as a parameter. This allows the developer to reference a "local" variable to update or read the value of the item without having to perform a dictionary lookup and type cast for every access. Changes to the variable will automatically be reflected in the dictionary.
The parameter t will be assigned the current value of the dictionary data item before the dictionary begins to refer to t.
Definition at line 136 of file gls_menu_dictionary.h.
References Get(), GlsMenuData_T< T >::ReferTo(), and GlsMenuData_T< T >::Value().
|
inlinevirtual |
Removes the attribute specified by name This does NOT actually delete the attribute, just removes it from the dictionary.
Definition at line 292 of file gls_menu_dictionary.h.
References _attribDict.
|
inlinestatic |
Static method used for parsing a stream Used internally and Exposed here so others can use it.
Definition at line 286 of file gls_menu_dictionary.h.
|
inlinestatic |
Static, Decrements the current spacing
Definition at line 275 of file gls_menu_dictionary.h.
|
inlinestatic |
Static, Increments the current spacing
Definition at line 272 of file gls_menu_dictionary.h.
|
inlinestatic |
Static, Returns a string containing the current spacing
Definition at line 281 of file gls_menu_dictionary.h.
|
inlinestatic |
Static, Sets the spacing to zero
Definition at line 278 of file gls_menu_dictionary.h.
|
inline |
Gets the ValueInt() of the named attribute
Definition at line 251 of file gls_menu_dictionary.h.
References _attribDict.
|
inline |
Sets the ValueInt() of the named attribute
Definition at line 254 of file gls_menu_dictionary.h.
References _attribDict.
|
inlinevirtual |
Returns the std::string value of the attribute specified by name Returns "" if not found Internally it uses ValueString() from the attribute
Definition at line 244 of file gls_menu_dictionary.h.
References _attribDict.
Referenced by GlsMenuSet_T< MenuType_t, DataFactory_t >::SetData(), GlsMenuSet_T< MenuType_t, DataFactory_t >::SetDataNoExpand(), and GlsMenuSet_T< MenuType_t, DataFactory_t >::ToggleData().
|
inlinevirtual |
Sets the attribute of named 'name' to the value of 'val' If name is not found, there is no indication
Definition at line 248 of file gls_menu_dictionary.h.
References _attribDict.
|
inlinevirtual |
Writes all items in the dictionary to the stream in the form: "NAME: VALUE" If changedDataOnly is true, only items which return ValueChanged() == true will be written.
Definition at line 228 of file gls_menu_dictionary.h.
References _attribDict.
Referenced by GlsMenuSet_T< MenuType_t, DataFactory_t >::Write().
|
inlinevirtual |
Calls WriteValue() for the attribute specified by name
Definition at line 257 of file gls_menu_dictionary.h.
References _attribDict.
|
private |
Definition at line 295 of file gls_menu_dictionary.h.
Referenced by Add(), Begin(), Clear(), CopyCommonValues(), Count(), Delete(), End(), Get(), IsEqual(), operator==(), Read(), ReadAndCaptureMissing(), ReadStrings(), ReadValue(), Remove(), ValueInt(), ValueString(), Write(), and WriteValue().