ParameterGrp Class Reference

The parameter container class This is the base class of all classes handle parameter. More...

#include <Parameter.h>

Inheritance diagram for ParameterGrp:
Base::Handled Base::Subject< const char * > ParameterManager

List of all members.

Public Member Functions

const char * GetGroupName (void) const
 returns the name
void NotifyAll ()
 Notifies all observers for all entries except of sub-groups.
copy and insertation



void copyTo (Base::Reference< ParameterGrp >)
 make a deep copy to the other group
void exportTo (const char *FileName)
 export this group to a file
void importFrom (const char *FileName)
 import from a file to this group
void insert (const char *FileName)
 insert from a file to this group, overwrite only the similar
void insertTo (Base::Reference< ParameterGrp >)
 overwrite everithing similar, leaf the others allone
methods for String handling



std::string GetASCII (const char *Name, const char *pPreset=NULL) const
 read a string values
std::vector< std::pair
< std::string, std::string > > 
GetASCIIMap (const char *sFilter=NULL) const
 Same as GetASCIIs() but with key,value map.
std::vector< std::string > GetASCIIs (const char *sFilter=NULL) const
 Return all string elements in this group as a vector of strings Its also possible to set a filter criteria.
void RemoveASCII (const char *Name)
 remove a string value from this group
void SetASCII (const char *Name, const char *sValue)
 set a string value
methods for Blob handling (not implemented yet)



void GetBlob (const char *Name, void *pBuf, long lMaxLength, void *pPreset=NULL) const
 read blob values or give default
void RemoveBlob (const char *Name)
 remove a blob value from this group
void SetBlob (const char *Name, void *pValue, long lLength)
 set a blob value
methods for bool handling



bool GetBool (const char *Name, bool bPreset=false) const
 read bool values or give default
std::vector< std::pair
< std::string, bool > > 
GetBoolMap (const char *sFilter=NULL) const
 get a map with all bool values and the keys of this group
std::vector< bool > GetBools (const char *sFilter=NULL) const
 get a vector of all bool values in this group
void RemoveBool (const char *Name)
 remove a bool value from this group
void SetBool (const char *Name, bool bValue)
 set a bool value
methods for Float handling



double GetFloat (const char *Name, double dPreset=0.0) const
 set a float value
std::vector< std::pair
< std::string, double > > 
GetFloatMap (const char *sFilter=NULL) const
 get a map with all float values and the keys of this group
std::vector< double > GetFloats (const char *sFilter=NULL) const
 get a vector of all float values in this group
void RemoveFloat (const char *Name)
 remove a float value from this group
void SetFloat (const char *Name, double dValue)
 read float values or give default
methods for Int handling



long GetInt (const char *Name, long lPreset=0) const
 read bool values or give default
std::vector< std::pair
< std::string, long > > 
GetIntMap (const char *sFilter=NULL) const
 get a map with all int values and the keys of this group
std::vector< long > GetInts (const char *sFilter=NULL) const
 get a vector of all int values in this group
void RemoveInt (const char *Name)
 remove a int value from this group
void SetInt (const char *Name, long lValue)
 set a int value
methods for Unsigned Int handling



unsigned long GetUnsigned (const char *Name, unsigned long lPreset=0) const
 read uint values or give default
std::vector< std::pair
< std::string, unsigned long > > 
GetUnsignedMap (const char *sFilter=NULL) const
 get a map with all uint values and the keys of this group
std::vector< unsigned long > GetUnsigneds (const char *sFilter=NULL) const
 get a vector of all uint values in this group
void RemoveUnsigned (const char *Name)
 remove a uint value from this group
void SetUnsigned (const char *Name, unsigned long lValue)
 set a uint value

Static Public Member Functions

static void Init (void)

Protected Member Functions

Base::Reference< ParameterGrp_GetGroup (const char *Name)
 helper function for GetGroup
XERCES_CPP_NAMESPACE_QUALIFIER
DOMElement * 
FindElement (XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *Start, const char *Type, const char *Name=0L) const
 Find an element specified by Type and Name Search in the parent element Start for the first occourrence of an element of Type and with the attribute Name=Name.
XERCES_CPP_NAMESPACE_QUALIFIER
DOMElement * 
FindNextElement (XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *Prev, const char *Type) const
XERCES_CPP_NAMESPACE_QUALIFIER
DOMElement * 
FindOrCreateElement (XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *Start, const char *Type, const char *Name) const
 Find an element specified by Type and Name or create it if not found Search in the parent element Start for the first occourrence of an element of Type and with the attribute Name=Name.
 ParameterGrp (XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *GroupNode=0L, const char *sName=0L)
 constructor is protected (handle concept)
 ~ParameterGrp ()
 destructor is protected (handle concept)

Protected Attributes

std::string _cName
 the own name
std::map< std::string,Base::Reference
< ParameterGrp > > 
_GroupMap
 map of already exported groups
XERCES_CPP_NAMESPACE_QUALIFIER
DOMElement * 
_pGroupNode
 DOM Node of the Base node of this group.

Friends

class ParameterManager

methods for group handling



typedef Base::Reference
< ParameterGrp
handle
 type of the handle
void Clear (void)
 clears everithing in this group (all types)
Base::Reference< ParameterGrpGetGroup (const char *Name)
 get a handle to a sub group or creat one
std::vector< Base::Reference
< ParameterGrp > > 
GetGroups (void)
 get a vector of all sub groups in this group
bool HasGroup (const char *Name) const
 test if a special sub group is in this group
bool IsEmpty (void) const
 test if this group is emty
void RemoveGrp (const char *Name)
 remove a sub group from this group

Detailed Description

The parameter container class This is the base class of all classes handle parameter.

The class contains a map of key-value pairs in a grouping structure, not unlike the windows registry. It allows the user to set and retrieve values of the type float, long and string. Also it handles importing and exporting groups of parameters and enables streaming to a persistent medium via XML.

Its main task is making user parameter persitent, saving last used values in dialog boxes, setting and retrieving all kind of preferences and so on.
See also:
ParameterManager

Definition at line 82 of file Parameter.h.


Member Typedef Documentation

type of the handle

Definition at line 112 of file Parameter.h.


Constructor & Destructor Documentation

ParameterGrp::ParameterGrp ( XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *  GroupNode = 0L,
const char *  sName = 0L 
) [protected]

constructor is protected (handle concept)

Defauld construction Does not much.

Definition at line 199 of file Parameter.cpp.

References _cName.

Referenced by _GetGroup(), and GetGroups().

ParameterGrp::~ParameterGrp (  )  [protected]

destructor is protected (handle concept)

Destruction complete destruction of the object.

Definition at line 209 of file Parameter.cpp.


Member Function Documentation

Base::Reference< ParameterGrp > ParameterGrp::_GetGroup ( const char *  Name  )  [protected]

helper function for GetGroup

Definition at line 331 of file Parameter.cpp.

References _GroupMap, _pGroupNode, FindOrCreateElement(), and ParameterGrp().

Referenced by GetGroup().

void ParameterGrp::Clear ( void   ) 

clears everithing in this group (all types)

Definition at line 848 of file Parameter.cpp.

References _GroupMap, _pGroupNode, Base::Console(), Base::Subject< const char * >::Notify(), and Base::ConsoleSingleton::Warning().

void ParameterGrp::copyTo ( Base::Reference< ParameterGrp Grp  ) 

make a deep copy to the other group

Definition at line 216 of file Parameter.cpp.

References insertTo().

void ParameterGrp::exportTo ( const char *  FileName  ) 

export this group to a file

Definition at line 264 of file Parameter.cpp.

References ParameterManager::CreateDocument(), GetGroup(), insertTo(), and ParameterManager::SaveDocument().

XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * ParameterGrp::FindElement ( XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *  Start,
const char *  Type,
const char *  Name = 0L 
) const [protected]

Find an element specified by Type and Name Search in the parent element Start for the first occourrence of an element of Type and with the attribute Name=Name.

On success it returns the pointer to that element, otherwise NULL If the names not given he returns the first occourence fo Type.

Definition at line 879 of file Parameter.cpp.

Referenced by FindOrCreateElement(), GetASCII(), GetASCIIMap(), GetASCIIs(), GetBool(), GetBoolMap(), GetBools(), GetFloat(), GetFloatMap(), GetFloats(), GetGroups(), GetInt(), GetIntMap(), GetInts(), GetUnsigned(), GetUnsignedMap(), GetUnsigneds(), HasGroup(), ParameterManager::LoadDocument(), RemoveASCII(), RemoveBool(), RemoveFloat(), RemoveGrp(), RemoveInt(), and RemoveUnsigned().

XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * ParameterGrp::FindNextElement ( XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *  Prev,
const char *  Type 
) const [protected]
XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * ParameterGrp::FindOrCreateElement ( XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *  Start,
const char *  Type,
const char *  Name 
) const [protected]

Find an element specified by Type and Name or create it if not found Search in the parent element Start for the first occourrence of an element of Type and with the attribute Name=Name.

On success it returns the pointer to that element, otherwise it creates the element and returns the pointer.

Definition at line 916 of file Parameter.cpp.

References _pGroupNode, and FindElement().

Referenced by _GetGroup(), SetASCII(), SetBool(), SetFloat(), SetInt(), and SetUnsigned().

std::string ParameterGrp::GetASCII ( const char *  Name,
const char *  pPreset = NULL 
) const
std::vector< std::pair< std::string, std::string > > ParameterGrp::GetASCIIMap ( const char *  sFilter = NULL  )  const

Same as GetASCIIs() but with key,value map.

Definition at line 724 of file Parameter.cpp.

References _pGroupNode, FindElement(), and FindNextElement().

Referenced by insertTo(), and NotifyAll().

std::vector< std::string > ParameterGrp::GetASCIIs ( const char *  sFilter = NULL  )  const

Return all string elements in this group as a vector of strings Its also possible to set a filter criteria.

Parameters:
sFilter only strings which name includes sFilter are put in the vector
Returns:
std::vector of std::strings

Definition at line 702 of file Parameter.cpp.

References _pGroupNode, FindElement(), and FindNextElement().

void ParameterGrp::GetBlob ( const char *  Name,
void *  pBuf,
long  lMaxLength,
void *  pPreset = NULL 
) const

read blob values or give default

Definition at line 655 of file Parameter.cpp.

bool ParameterGrp::GetBool ( const char *  Name,
bool  bPreset = false 
) const

read bool values or give default

Definition at line 397 of file Parameter.cpp.

References _pGroupNode, and FindElement().

Referenced by Gui::View3DInventor::OnChange(), Gui::SplitView3DInventor::OnChange(), and Gui::DockWnd::ReportOutput::OnChange().

std::vector< std::pair< std::string, bool > > ParameterGrp::GetBoolMap ( const char *  sFilter = NULL  )  const

get a map with all bool values and the keys of this group

Definition at line 442 of file Parameter.cpp.

References _pGroupNode, FindElement(), and FindNextElement().

Referenced by insertTo(), and NotifyAll().

std::vector< bool > ParameterGrp::GetBools ( const char *  sFilter = NULL  )  const

get a vector of all bool values in this group

Definition at line 420 of file Parameter.cpp.

References _pGroupNode, FindElement(), and FindNextElement().

double ParameterGrp::GetFloat ( const char *  Name,
double  dPreset = 0.0 
) const

set a float value

Definition at line 586 of file Parameter.cpp.

References _pGroupNode, and FindElement().

Referenced by Gui::View3DInventor::OnChange(), and Gui::SplitView3DInventor::OnChange().

std::vector< std::pair< std::string, double > > ParameterGrp::GetFloatMap ( const char *  sFilter = NULL  )  const

get a map with all float values and the keys of this group

Definition at line 627 of file Parameter.cpp.

References _pGroupNode, FindElement(), and FindNextElement().

Referenced by insertTo(), and NotifyAll().

std::vector< double > ParameterGrp::GetFloats ( const char *  sFilter = NULL  )  const

get a vector of all float values in this group

Definition at line 608 of file Parameter.cpp.

References _pGroupNode, FindElement(), and FindNextElement().

Base::Reference< ParameterGrp > ParameterGrp::GetGroup ( const char *  Name  ) 
const char* ParameterGrp::GetGroupName ( void   )  const [inline]

returns the name

Definition at line 212 of file Parameter.h.

References _cName.

std::vector< Base::Reference< ParameterGrp > > ParameterGrp::GetGroups ( void   ) 

get a vector of all sub groups in this group

Definition at line 352 of file Parameter.cpp.

References _GroupMap, _pGroupNode, FindElement(), FindNextElement(), and ParameterGrp().

Referenced by insertTo(), and Gui::Dialog::DlgParameterImp::onChangeParameterSet().

long ParameterGrp::GetInt ( const char *  Name,
long  lPreset = 0 
) const

read bool values or give default

Definition at line 464 of file Parameter.cpp.

References _pGroupNode, and FindElement().

Referenced by Gui::View3DInventor::OnChange(), Gui::SplitView3DInventor::OnChange(), and Gui::DockWnd::ReportOutput::OnChange().

std::vector< std::pair< std::string, long > > ParameterGrp::GetIntMap ( const char *  sFilter = NULL  )  const

get a map with all int values and the keys of this group

Definition at line 505 of file Parameter.cpp.

References _pGroupNode, FindElement(), and FindNextElement().

Referenced by insertTo(), and NotifyAll().

std::vector< long > ParameterGrp::GetInts ( const char *  sFilter = NULL  )  const

get a vector of all int values in this group

Definition at line 486 of file Parameter.cpp.

References _pGroupNode, FindElement(), and FindNextElement().

unsigned long ParameterGrp::GetUnsigned ( const char *  Name,
unsigned long  lPreset = 0 
) const
std::vector< std::pair< std::string, unsigned long > > ParameterGrp::GetUnsignedMap ( const char *  sFilter = NULL  )  const

get a map with all uint values and the keys of this group

Definition at line 566 of file Parameter.cpp.

References _pGroupNode, FindElement(), and FindNextElement().

Referenced by insertTo(), and NotifyAll().

std::vector< unsigned long > ParameterGrp::GetUnsigneds ( const char *  sFilter = NULL  )  const

get a vector of all uint values in this group

Definition at line 547 of file Parameter.cpp.

References _pGroupNode, FindElement(), and FindNextElement().

bool ParameterGrp::HasGroup ( const char *  Name  )  const

test if a special sub group is in this group

Definition at line 386 of file Parameter.cpp.

References _GroupMap, _pGroupNode, and FindElement().

void ParameterGrp::importFrom ( const char *  FileName  ) 

import from a file to this group

Definition at line 276 of file Parameter.cpp.

References GetGroup(), and ParameterManager::LoadDocument().

static void ParameterGrp::Init ( void   )  [static]

Reimplemented in ParameterManager.

void ParameterGrp::insert ( const char *  FileName  ) 

insert from a file to this group, overwrite only the similar

Definition at line 286 of file Parameter.cpp.

References GetGroup(), and ParameterManager::LoadDocument().

void ParameterGrp::insertTo ( Base::Reference< ParameterGrp Grp  ) 

overwrite everithing similar, leaf the others allone

Definition at line 225 of file Parameter.cpp.

References GetASCIIMap(), GetBoolMap(), GetFloatMap(), GetGroups(), GetIntMap(), and GetUnsignedMap().

Referenced by copyTo(), and exportTo().

bool ParameterGrp::IsEmpty ( void   )  const

test if this group is emty

Definition at line 377 of file Parameter.cpp.

References _pGroupNode.

void ParameterGrp::NotifyAll (  ) 

Notifies all observers for all entries except of sub-groups.

Definition at line 932 of file Parameter.cpp.

References GetASCIIMap(), GetBoolMap(), GetFloatMap(), GetIntMap(), GetUnsignedMap(), and Base::Subject< const char * >::Notify().

void ParameterGrp::RemoveASCII ( const char *  Name  ) 

remove a string value from this group

Definition at line 765 of file Parameter.cpp.

References _pGroupNode, FindElement(), and Base::Subject< const char * >::Notify().

void ParameterGrp::RemoveBlob ( const char *  Name  ) 

remove a blob value from this group

Definition at line 793 of file Parameter.cpp.

void ParameterGrp::RemoveBool ( const char *  Name  ) 

remove a bool value from this group

Definition at line 779 of file Parameter.cpp.

References _pGroupNode, FindElement(), and Base::Subject< const char * >::Notify().

void ParameterGrp::RemoveFloat ( const char *  Name  ) 

remove a float value from this group

Definition at line 806 of file Parameter.cpp.

References _pGroupNode, FindElement(), and Base::Subject< const char * >::Notify().

void ParameterGrp::RemoveGrp ( const char *  Name  ) 

remove a sub group from this group

Definition at line 749 of file Parameter.cpp.

References _GroupMap, _pGroupNode, FindElement(), and Base::Subject< const char * >::Notify().

void ParameterGrp::RemoveInt ( const char *  Name  ) 

remove a int value from this group

Definition at line 820 of file Parameter.cpp.

References _pGroupNode, FindElement(), and Base::Subject< const char * >::Notify().

void ParameterGrp::RemoveUnsigned ( const char *  Name  ) 

remove a uint value from this group

Definition at line 834 of file Parameter.cpp.

References _pGroupNode, FindElement(), and Base::Subject< const char * >::Notify().

void ParameterGrp::SetASCII ( const char *  Name,
const char *  sValue 
)

set a string value

Definition at line 661 of file Parameter.cpp.

References _pGroupNode, FindOrCreateElement(), and Base::Subject< const char * >::Notify().

void ParameterGrp::SetBlob ( const char *  Name,
void *  pValue,
long  lLength 
)

set a blob value

Definition at line 649 of file Parameter.cpp.

void ParameterGrp::SetBool ( const char *  Name,
bool  bValue 
)

set a bool value

Definition at line 410 of file Parameter.cpp.

References _pGroupNode, FindOrCreateElement(), and Base::Subject< const char * >::Notify().

void ParameterGrp::SetFloat ( const char *  Name,
double  dValue 
)

read float values or give default

Definition at line 596 of file Parameter.cpp.

References _pGroupNode, FindOrCreateElement(), and Base::Subject< const char * >::Notify().

void ParameterGrp::SetInt ( const char *  Name,
long  lValue 
)

set a int value

Definition at line 474 of file Parameter.cpp.

References _pGroupNode, FindOrCreateElement(), and Base::Subject< const char * >::Notify().

void ParameterGrp::SetUnsigned ( const char *  Name,
unsigned long  lValue 
)

set a uint value

Definition at line 535 of file Parameter.cpp.

References _pGroupNode, FindOrCreateElement(), and Base::Subject< const char * >::Notify().


Friends And Related Function Documentation

friend class ParameterManager [friend]

Definition at line 209 of file Parameter.h.


Member Data Documentation

std::string ParameterGrp::_cName [protected]

the own name

Definition at line 249 of file Parameter.h.

Referenced by GetGroupName(), and ParameterGrp().

std::map<std::string ,Base::Reference<ParameterGrp> > ParameterGrp::_GroupMap [protected]

map of already exported groups

Definition at line 251 of file Parameter.h.

Referenced by _GetGroup(), Clear(), GetGroups(), HasGroup(), and RemoveGrp().

XERCES_CPP_NAMESPACE_QUALIFIER DOMElement* ParameterGrp::_pGroupNode [protected]

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

Generated on Wed Nov 23 19:01:38 2011 for FreeCAD by  doxygen 1.6.1