GlsMenu
GlsMenuDictionary Class Reference

#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)
 
GlsMenuDictionaryoperator= (const disti::DistiAttribDict &dict)
 
GlsMenuDictionaryoperator= (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
 

Detailed Description

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.

Member Typedef Documentation

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.

Member Function Documentation

virtual void GlsMenuDictionary::Add ( disti::DistiAttributeBase *  attr)
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().

template<class T >
void GlsMenuDictionary::Attach ( const std::string &  name,
T *&  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().

const_iterator GlsMenuDictionary::Begin ( ) const
inline
iterator GlsMenuDictionary::Begin ( )
inline

Definition at line 198 of file gls_menu_dictionary.h.

References _attribDict.

void GlsMenuDictionary::Clear ( )
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.

void GlsMenuDictionary::CopyCommonValues ( const disti::DistiAttribDict &  dict)
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=().

void GlsMenuDictionary::CopyCommonValues ( const GlsMenuDictionary dict)
inline

Definition at line 182 of file gls_menu_dictionary.h.

References _attribDict.

int GlsMenuDictionary::Count ( ) const
inline

Returns the current number of elements in the dictionary

Definition at line 202 of file gls_menu_dictionary.h.

References _attribDict.

int GlsMenuDictionary::Count ( const disti::AttributeName &  name) const
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.

virtual void GlsMenuDictionary::Delete ( const disti::AttributeName &  name)
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.

const_iterator GlsMenuDictionary::End ( ) const
inline
iterator GlsMenuDictionary::End ( )
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().

virtual disti::DistiAttributeBase* GlsMenuDictionary::Get ( const disti::AttributeName &  name) const
inlinevirtual
virtual bool GlsMenuDictionary::IsEqual ( const disti::AttributeName &  name,
const long  val 
) const
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.

GlsMenuDictionary& GlsMenuDictionary::operator= ( const disti::DistiAttribDict &  dict)
inline

Copies the values for all items which have matching names between this object and dict. All other values are ignored

Deprecated:
Use CopyCommonValues() instead.

Definition at line 166 of file gls_menu_dictionary.h.

References CopyCommonValues().

GlsMenuDictionary& GlsMenuDictionary::operator= ( const GlsMenuDictionary dict)
inline

Definition at line 173 of file gls_menu_dictionary.h.

References CopyCommonValues().

bool GlsMenuDictionary::operator== ( const disti::DistiAttribDict &  other)
inline

Equality operator Compares length, names and values. order does not matter

Definition at line 187 of file gls_menu_dictionary.h.

References _attribDict.

bool GlsMenuDictionary::operator== ( const GlsMenuDictionary other)
inline

Definition at line 188 of file gls_menu_dictionary.h.

References _attribDict.

virtual bool GlsMenuDictionary::Read ( std::istream &  instr)
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().

bool GlsMenuDictionary::ReadAndCaptureMissing ( std::istream &  instr,
std::stringstream *  missingStream 
)
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.

virtual void GlsMenuDictionary::ReadStrings ( std::istream &  instr)
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.

virtual std::istream& GlsMenuDictionary::ReadValue ( const disti::AttributeName &  name,
std::istream &  instr 
)
inlinevirtual

Calls ReadValue() for the attribute specified by name

Definition at line 260 of file gls_menu_dictionary.h.

References _attribDict.

template<class T >
bool GlsMenuDictionary::Refer ( const std::string &  name,
T &  t 
)
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().

template<class T >
bool GlsMenuDictionary::ReferCopy ( const std::string &  name,
T &  t 
)
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().

virtual void GlsMenuDictionary::Remove ( const disti::AttributeName &  name)
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.

static bool GlsMenuDictionary::ScanToken ( std::istream &  instr,
std::string &  result 
)
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.

static void GlsMenuDictionary::SpacingDec ( )
inlinestatic

Static, Decrements the current spacing

Definition at line 275 of file gls_menu_dictionary.h.

static void GlsMenuDictionary::SpacingInc ( )
inlinestatic

Static, Increments the current spacing

Definition at line 272 of file gls_menu_dictionary.h.

static std::string GlsMenuDictionary::SpacingString ( )
inlinestatic

Static, Returns a string containing the current spacing

Definition at line 281 of file gls_menu_dictionary.h.

static void GlsMenuDictionary::SpacingZero ( )
inlinestatic

Static, Sets the spacing to zero

Definition at line 278 of file gls_menu_dictionary.h.

long GlsMenuDictionary::ValueInt ( const disti::AttributeName &  name) const
inline

Gets the ValueInt() of the named attribute

Definition at line 251 of file gls_menu_dictionary.h.

References _attribDict.

void GlsMenuDictionary::ValueInt ( const disti::AttributeName &  name,
long  val 
)
inline

Sets the ValueInt() of the named attribute

Definition at line 254 of file gls_menu_dictionary.h.

References _attribDict.

virtual std::string GlsMenuDictionary::ValueString ( const disti::AttributeName &  name) const
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().

virtual void GlsMenuDictionary::ValueString ( const disti::AttributeName &  name,
const std::string &  val 
)
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.

virtual void GlsMenuDictionary::Write ( std::ostream &  outstr,
bool  changedDataOnly = false 
)
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().

virtual std::ostream& GlsMenuDictionary::WriteValue ( const disti::AttributeName &  name,
std::ostream &  outstr 
)
inlinevirtual

Calls WriteValue() for the attribute specified by name

Definition at line 257 of file gls_menu_dictionary.h.

References _attribDict.

Field Documentation

disti::DistiAttribDict GlsMenuDictionary::_attribDict
private

The documentation for this class was generated from the following file: