Horus Doc || C++ Reference || Class Overview   Pixels   Images   Detector   Geometry   Registry || Doxygen's quick Index  

HxRegistry Class Reference

The registry. More...

#include <HxRegistry.h>

List of all members.

Public Methods

 HxRegistry ()
 Constructor. More...

 ~HxRegistry ()
 Destructor. More...

int import (HxString fileName)
 Import registry data from file. More...

int import (const char *argv[])
 Import registry data from argument strings. More...

int exportText (STD_OSTREAM &out) const
 Export registry data as text to stream. More...

int exportC (STD_OSTREAM &out, HxString label) const
 Export registry data in format for use with HxRegistryImporter. More...

HxRegKeyinsertKey (HxString path)
 Insert key. More...

void eraseKey (HxString path)
 Erase key. More...

HxRegKeyfindKey (HxString path) const
 Find key. More...

void insertValue (HxString path, const HxRegData &)
 Insert value. More...

void insertValue (HxString path, HxString data)
 Insert value. More...

void insertValue (HxString path, int data)
 Insert value. More...

void eraseValue (HxString path)
 Erase value. More...

HxString findValue (HxString path) const
 Find value. More...

int valueExists (HxString path) const
 Check whether value exists. More...

HxRegKeysetCursorKey (HxString path)
 Set cursor key. More...

HxRegKeysetCursorUp ()
 Move cursor key up. More...

HxRegKeygetCursorKey () const
 Get cursor key. More...

HxString getCursorName () const
 Get cursor name. More...

HxRegKeysetRootKey ()
 Set root key. More...

HxRegKeygetRootKey () const
 Get root key. More...

STD_OSTREAM & put (STD_OSTREAM &) const
 Put registry on stream. More...


Static Public Methods

HxRegistry & instance ()
 Access to the single instance of the registry. More...


Detailed Description

The registry.


Constructor & Destructor Documentation

HxRegistry::HxRegistry  
 

Constructor.

00028 {
00029     _rootKey = HxRegKey::createRootKey();
00030     _cursorKey = _rootKey;
00031 }

HxRegistry::~HxRegistry  
 

Destructor.

00041 {
00042     delete _rootKey;
00043 }


Member Function Documentation

HxRegistry & HxRegistry::instance   [static]
 

Access to the single instance of the registry.

00047 {
00048     static HxRegistry theRegistry;
00049     return theRegistry;
00050 }

int HxRegistry::import HxString    fileName
 

Import registry data from file.

00088 {
00089     STD_IFSTREAM inStream(fileName.c_str());
00090 
00091     if (!inStream) {
00092         HxEnvironment::instance()->errorStream()
00093             << "Cannot open file " << fileName << STD_ENDL;
00094         HxEnvironment::instance()->flush();
00095         return 0;
00096     }
00097 
00098     HxStreamCharReader  reader(inStream);
00099 
00100     HxRegParser::instance().setReader(reader);
00101     HxRegParser::instance().setFileName(fileName);
00102     HxRegParser::instance().setRegistry(*this);
00103     HxRegParser::instance().parse();
00104     return 1;
00105 }

int HxRegistry::import const char *    argv[]
 

Import registry data from argument strings.

00109 {
00110     if (!*argv)
00111         return 0;
00112     HxString fileName(argv[0]);
00113     fileName += "::";
00114     fileName += argv[1];
00115     argv += 2;
00116     HxArgvCharReader reader(argv);
00117 
00118     HxRegParser::instance().setReader(reader);
00119     HxRegParser::instance().setFileName(fileName);
00120     HxRegParser::instance().setRegistry(*this);
00121     HxRegParser::instance().parse();
00122     return 1;
00123 }

int HxRegistry::exportText STD_OSTREAM &    out const
 

Export registry data as text to stream.

00127 {
00128     _rootKey->put(out);
00129     return 1;
00130 }

int HxRegistry::exportC STD_OSTREAM &    out,
HxString    label
const
 

Export registry data in format for use with HxRegistryImporter.

00134 {
00135     out << "static const char* " << label << "[] = {" << STD_ENDL;
00136     out << "__FILE__" << "," << STD_ENDL;
00137     out << "\"" << label << "\"," << STD_ENDL;
00138     _rootKey->put(out, "", hxTrue);
00139     out << "(char*)0" << STD_ENDL << "};" << STD_ENDL;
00140     return 1;
00141 }

HxRegKey * HxRegistry::insertKey HxString    name
 

Insert key.

00145 {
00146     HxStringList            nameList;
00147     splitString(name, '/', std::back_inserter(nameList));
00148     HxStringListConstIter   namePtr = nameList.begin();
00149     HxRegKey*               key = _cursorKey;
00150 
00151     if ((namePtr != nameList.end()) && (*namePtr).empty()) {
00152         key = _rootKey;
00153         namePtr++;
00154     }
00155 
00156     for (;namePtr != nameList.end(); namePtr++) {
00157         if ((*namePtr).empty())
00158             continue;
00159         key = key->insertKey(*namePtr);
00160     }
00161     return key;
00162 }

void HxRegistry::eraseKey HxString    name
 

Erase key.

00166 {
00167     HxRegKey* key = findKey(name);
00168     if (key && (key != _rootKey)) {
00169         HxString baseName = key->getName();
00170         key = key->getParent();
00171         key->eraseKey(baseName);
00172     }
00173 }

HxRegKey * HxRegistry::findKey HxString    name const
 

Find key.

00177 {
00178     HxRegKey*               key = _cursorKey;
00179 
00180     if (!name.empty() && (name[0] == '/'))
00181         key = _rootKey;
00182 
00183     return key->findKey(name);
00184 }

void HxRegistry::insertValue HxString    path,
const HxRegData   data
 

Insert value.

00188 {
00189     HxStringList nameList;
00190     int n = splitString(path, '/', std::back_inserter(nameList));
00191     if (n <= 0)
00192         return;
00193     HxString name = nameList.back();
00194     if (name.empty())
00195         return;
00196     nameList.pop_back();
00197     HxRegKey* key = _rootKey->findKey(nameList.begin(), nameList.end());
00198     if (!key)
00199         return;
00200     key->insertValue(name, data);
00201 }

void HxRegistry::insertValue HxString    path,
HxString    data
[inline]
 

Insert value.

00109 {
00110     insertValue(path, HxRegData(data));
00111 }

void HxRegistry::insertValue HxString    path,
int    data
[inline]
 

Insert value.

00115 {
00116     insertValue(path, HxRegData(data));
00117 }

void HxRegistry::eraseValue HxString    path
 

Erase value.

00237 {
00238     HxStringList nameList;
00239     int n = splitString(path, '/', std::back_inserter(nameList));
00240     if (n <= 0)
00241         return;
00242     HxString name = nameList.back();
00243     if (name.empty())
00244         return;
00245     nameList.pop_back();
00246     HxRegKey* key = _rootKey->findKey(nameList.begin(), nameList.end());
00247     if (key)
00248         key->eraseValue(name);
00249 }

HxString HxRegistry::findValue HxString    path const
 

Find value.

00220 {
00221     const HxRegValue* val = doFindValue(path);
00222     if (val)
00223         return val->getData().toString();
00224     else
00225         return HxString("");
00226 }

int HxRegistry::valueExists HxString    path const
 

Check whether value exists.

00230 {
00231     const HxRegValue* val = doFindValue(path);
00232     return val ? 1 : 0;
00233 }

HxRegKey * HxRegistry::setCursorKey HxString    name
 

Set cursor key.

00253 {
00254     HxRegKey* key = findKey(name);
00255     if (key)
00256         _cursorKey = key;
00257     return key;
00258 }

HxRegKey * HxRegistry::setCursorUp  
 

Move cursor key up.

00262 {
00263     _cursorKey = _cursorKey->getParent();
00264     return _cursorKey;
00265 }

HxRegKey * HxRegistry::getCursorKey   const [inline]
 

Get cursor key.

00121 {
00122     return _cursorKey;
00123 }

HxString HxRegistry::getCursorName   const [inline]
 

Get cursor name.

00127 {
00128     return _cursorName;
00129 }

HxRegKey * HxRegistry::setRootKey   [inline]
 

Set root key.

00139 {
00140     return _cursorKey = _rootKey;
00141 }

HxRegKey * HxRegistry::getRootKey   const [inline]
 

Get root key.

00133 {
00134     return _rootKey;
00135 }

STD_OSTREAM & HxRegistry::put STD_OSTREAM &    os const
 

Put registry on stream.

00269 {
00270     return _rootKey->put(os);
00271 }


The documentation for this class was generated from the following files:
Generated on Tue Feb 3 14:19:07 2004 for C++Reference by doxygen1.2.12 written by Dimitri van Heesch, © 1997-2001