TDbiRegistry.cxx File Reference

#include <map>
#include <iomanip>
#include "TBuffer.h"
#include "TObject.h"
#include "TDbiRegistry.hxx"
#include "TDbiRegistryItem.hxx"
#include <UtilStream.hxx>
#include <TSK_DBI_Log.hxx>
#include <MsgFormat.h>
#include <typeinfo>
#include <iostream>
#include <sstream>
#include <cassert>
Include dependency graph for TDbiRegistry.cxx:

Go to the source code of this file.

Defines

#define REGISTRY_SET(TYPE)
#define REGISTRY_GET(TYPE)
#define REGISTRY_GET_TYPE(NAME, RETTYPE, TYPE)

Functions

 ClassImp (TDbiRegistry) TDbiRegistry
static std::istream & bail (std::istream &is)

Define Documentation

#define REGISTRY_GET ( TYPE   ) 
Value:
bool TDbiRegistry::Get(const char* key, TYPE & val) const           \
{                                                               \
    tRegMap::const_iterator mit = fMap.find(key);               \
    if (mit == fMap.end()) return false;                        \
    TDbiRegistryItemXxx<TYPE>* rix =                                \
        dynamic_cast<TDbiRegistryItemXxx<TYPE>*>(mit->second);      \
    if (rix == 0){                                              \
      SK_DBI_Severe( "Key " << key             \
                                   << " does not have type "    \
                                   << #TYPE << " as required"   \
                                   << "  ");                     \
      return false;                                             \
    }                                                           \
    val = *(rix->Get());                                        \
    return true;                                                \
}

Definition at line 301 of file TDbiRegistry.cxx.

#define REGISTRY_GET_TYPE ( NAME,
RETTYPE,
TYPE   ) 
Value:
RETTYPE TDbiRegistry::Get##NAME(const char* key) const                        \
{                                                                         \
    TYPE retval = 0;                                                      \
    if (Get(key,retval)) return retval;                                   \
    if (fErrorHandler) { fErrorHandler(); return 0; }                     \
    else {                                                                \
        SK_DBI_Warn(  "\nTDbiRegistry::GetTYPE: failed to get value for key \""      \
            << key << "\" from TDbiRegistry \"" << this->GetName()            \
            << "\".  Aborting\n\n");                                       \
        bool must_get_a_value = false;                                    \
        assert(must_get_a_value);                                         \
        return 0;                                                         \
    }                                                                     \
}

Definition at line 348 of file TDbiRegistry.cxx.

#define REGISTRY_SET ( TYPE   ) 
Value:
bool TDbiRegistry::Set(const char* key, TYPE val)                           \
{                                                                       \
    tRegMap::iterator mit = fMap.find(key);                             \
    if (mit != fMap.end()) {                                            \
        if (fValuesLocked) {                                            \
             SK_DBI_Warn(  "Set: Values are locked - not overwriting \""         \
               << key << "\" with \"" << val << "\" in registry \"" << this->GetName() << "\"\n");\
            return false;                                               \
        }                                                               \
        if (!dynamic_cast<TDbiRegistryItemXxx<TYPE>*>(mit->second)) {       \
            SK_DBI_Warn(  "Set: attempt to overwrite old value for key \""     \
                << key << "\" with different type value "               \
                << val << " in registry \"" << this->GetName() << "\"\n");\
            return false;                                               \
        }                                                               \
        delete mit->second;                                             \
        fMap.erase(mit);                                                \
    }                                                                   \
    else {                                                              \
        if (fKeysLocked) {                                              \
            SK_DBI_Warn(  "Set: Keys are locked - not adding `"               \
                 << key << "' to registry \"" << this->GetName() << "\"\n");\
            return false;                                               \
        }                                                               \
    }                                                                   \
    TDbiRegistryItem* ri = new TDbiRegistryItemXxx< TYPE >(new TYPE (val));     \
    fMap[key] = ri;                                                     \
    this->SetDirty();                                                   \
    return true;                                                        \
}

Definition at line 224 of file TDbiRegistry.cxx.


Function Documentation

static std::istream& bail ( std::istream &  is  )  [static]

Definition at line 478 of file TDbiRegistry.cxx.

References SK_DBI_Warn.

Referenced by TDbiRegistry::ReadStream().

00479 {
00480     SK_DBI_Warn(  "TDbiRegistry::Read(istream&) stream corrupted\n");
00481     return is;
00482 }

Here is the caller graph for this function:

ClassImp ( TDbiRegistry   ) 

Definition at line 23 of file TDbiRegistry.cxx.

References SK_DBI_Trace.

00030     : fValuesLocked(readonly),
00031       fKeysLocked(false),
00032       fErrorHandler(0)
00033 {
00034     SK_DBI_Trace( "Creating TDbiRegistry at " << (void * ) this << "  ");
00035     this->SetDirty();
00036 }


Generated on 11 Aug 2013 for SKDatabase by  doxygen 1.6.1