From ed0b918b9f46b4e12a8d24c1575e48e589991c39 Mon Sep 17 00:00:00 2001
From: Markus Frank <Markus.Frank@cern.ch>
Date: Fri, 11 Nov 2016 17:52:03 +0100
Subject: [PATCH] Improve generic conditions data binding

---
 DDCond/src/plugins/ConditionsPlugins.cpp      | 484 +++++++++---------
 .../plugins/ConditionsRepositoryParser.cpp    | 146 +++---
 DDCore/include/DD4hep/BuildType.h             |  47 ++
 DDCore/include/DD4hep/LCDD.h                  |  11 +-
 DDCore/include/DD4hep/OpaqueData.h            |   6 +-
 DDCore/include/DD4hep/Printout.h              |  15 +-
 .../include/DD4hep/objects/OpaqueData_inl.h   |  10 +-
 DDCore/src/BuildType.cpp                      |  50 ++
 DDCore/src/OpaqueDataBinder.cpp               |  14 +-
 DDCore/src/Printout.cpp                       |  31 +-
 DDCore/src/plugins/StandardPlugins.cpp        |  30 +-
 11 files changed, 493 insertions(+), 351 deletions(-)
 create mode 100644 DDCore/include/DD4hep/BuildType.h
 create mode 100644 DDCore/src/BuildType.cpp

diff --git a/DDCond/src/plugins/ConditionsPlugins.cpp b/DDCond/src/plugins/ConditionsPlugins.cpp
index 4e25dcdd5..8bf081549 100644
--- a/DDCond/src/plugins/ConditionsPlugins.cpp
+++ b/DDCond/src/plugins/ConditionsPlugins.cpp
@@ -25,6 +25,7 @@
 #include "DDCond/ConditionsInterna.h"
 #include "DDCond/ConditionsPool.h"
 #include "DDCond/ConditionsInterna.h"
+#include "DDCond/ConditionsRepository.h"
 
 using namespace std;
 using namespace DD4hep;
@@ -32,289 +33,310 @@ using namespace DD4hep::Conditions;
 using Geometry::DetElement;
 using Geometry::PlacedVolume;
 
-namespace {
-  /// Plugin function: Install the alignment manager as an extension to the central LCDD object
-  /**
-   *  Factory: DD4hep_ConditionsManagerInstaller
-   *
-   *  \author  M.Frank
-   *  \version 1.0
-   *  \date    01/04/2016
-   */
-  int ddcond_install_cond_mgr (LCDD& lcdd, int argc, char** argv)  {
-    Handle<ConditionsManagerObject> mgr(lcdd.extension<ConditionsManagerObject>(false));
-    if ( !mgr.isValid() )  {
-      ConditionsManager mgr_handle(lcdd);
-      lcdd.addExtension<ConditionsManagerObject>(mgr_handle.ptr());
-      printout(INFO,"ConditionsManager",
-               "+++ Successfully installed conditions manager instance to LCDD.");
-      mgr = mgr_handle;
-    }
-    if ( argc == 2 )  {
-      if ( ::strncmp(argv[0],"-handle",7)==0 )  {
-        Handle<NamedObject>* h = (Handle<NamedObject>*)argv[1];
-        *h = mgr;
-      }
+/// Plugin function: Install the alignment manager as an extension to the central LCDD object
+/**
+ *  Factory: DD4hep_ConditionsManagerInstaller
+ *
+ *  \author  M.Frank
+ *  \version 1.0
+ *  \date    01/04/2016
+ */
+static int ddcond_install_cond_mgr (LCDD& lcdd, int argc, char** argv)  {
+  Handle<ConditionsManagerObject> mgr(lcdd.extension<ConditionsManagerObject>(false));
+  if ( !mgr.isValid() )  {
+    ConditionsManager mgr_handle(lcdd);
+    lcdd.addExtension<ConditionsManagerObject>(mgr_handle.ptr());
+    printout(INFO,"ConditionsManager",
+             "+++ Successfully installed conditions manager instance to LCDD.");
+    mgr = mgr_handle;
+  }
+  if ( argc == 2 )  {
+    if ( ::strncmp(argv[0],"-handle",7)==0 )  {
+      Handle<NamedObject>* h = (Handle<NamedObject>*)argv[1];
+      *h = mgr;
     }
-    return 1;
   }
+  return 1;
 }
 DECLARE_APPLY(DD4hep_ConditionsManagerInstaller,ddcond_install_cond_mgr)
 // ======================================================================================
 
-namespace {
-
-  
-  /// Plugin function: Dump of all Conditions pool with or without conditions
-  /**
-   *  Factory: DD4hep_ConditionsPoolDump: Dump pools only
-   *  Factory: DD4hep_ConditionsDump: Dump pools and conditions
-   *
-   *  \author  M.Frank
-   *  \version 1.0
-   *  \date    01/04/2016
-   */
-  int ddcond_dump_conditions_functor(lcdd_t& lcdd, bool print_conditions, int argc, char** argv)   {
-    typedef std::vector<const IOVType*> _T;
-    typedef ConditionsIOVPool::Elements _E;
-    typedef RangeConditions _R;
-    ConditionsManager manager = ConditionsManager::from(lcdd);
-    ConditionsPrinter default_printer("");
-    Condition::Processor* printer = &default_printer;
+/// Plugin function: Dump of all Conditions pool with or without conditions
+/**
+ *  Factory: DD4hep_ConditionsPoolDump: Dump pools only
+ *  Factory: DD4hep_ConditionsDump: Dump pools and conditions
+ *
+ *  \author  M.Frank
+ *  \version 1.0
+ *  \date    01/04/2016
+ */
+static int ddcond_dump_conditions_functor(lcdd_t& lcdd, bool print_conditions, int argc, char** argv)   {
+  typedef std::vector<const IOVType*> _T;
+  typedef ConditionsIOVPool::Elements _E;
+  typedef RangeConditions _R;
+  ConditionsManager manager = ConditionsManager::from(lcdd);
+  ConditionsPrinter default_printer("");
+  Condition::Processor* printer = &default_printer;
     
-    if ( argc > 0 )   {
-      printer = (Condition::Processor*) argv[0];
-    }
+  if ( argc > 0 )   {
+    printer = (Condition::Processor*) argv[0];
+  }
 
-    const _T types = manager.iovTypesUsed();
-    for( _T::const_iterator i = types.begin(); i != types.end(); ++i )    {
-      const IOVType* type = *i;
-      if ( type )   {
-        ConditionsIOVPool* pool = manager.iovPool(*type);
-        if ( pool )  {
-          const _E& e = pool->elements;
-          printout(INFO,"CondPoolDump","+++ ConditionsIOVPool for type %s  [%d IOV element%s]",
-                   type->str().c_str(), int(e.size()),e.size()==1 ? "" : "s");
-          for (_E::const_iterator j=e.begin(); j != e.end(); ++j)  {
-            ConditionsPool* cp = (*j).second;
-            cp->print("");
-            if ( print_conditions )   {
-              _R rc;
-              cp->select_all(rc);
-              for(_R::const_iterator ic=rc.begin(); ic!=rc.end(); ++ic)  {
-                if ( printer )  {  (*printer)(*ic);                   }
-                else            {
-                  /* print_conditions<void>(rc);  */
-                }
+  const _T types = manager.iovTypesUsed();
+  for( _T::const_iterator i = types.begin(); i != types.end(); ++i )    {
+    const IOVType* type = *i;
+    if ( type )   {
+      ConditionsIOVPool* pool = manager.iovPool(*type);
+      if ( pool )  {
+        const _E& e = pool->elements;
+        printout(INFO,"CondPoolDump","+++ ConditionsIOVPool for type %s  [%d IOV element%s]",
+                 type->str().c_str(), int(e.size()),e.size()==1 ? "" : "s");
+        for (_E::const_iterator j=e.begin(); j != e.end(); ++j)  {
+          ConditionsPool* cp = (*j).second;
+          cp->print("");
+          if ( print_conditions )   {
+            _R rc;
+            cp->select_all(rc);
+            for(_R::const_iterator ic=rc.begin(); ic!=rc.end(); ++ic)  {
+              if ( printer )  {  (*printer)(*ic);                   }
+              else            {
+                /* print_conditions<void>(rc);  */
               }
             }
           }
         }
       }
     }
-    printout(INFO,"CondPoolDump","SUCCESS: +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
-    printout(INFO,"CondPoolDump","SUCCESS: +++ Conditions pools successfully dumped");
-    printout(INFO,"CondPoolDump","SUCCESS: +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
-    return 1;
-  }
-
-  int ddcond_dump_pools(LCDD& lcdd, int argc, char** argv)   {
-    return ddcond_dump_conditions_functor(lcdd,false, argc, argv);
-  }
-  int ddcond_dump_conditions(LCDD& lcdd, int argc, char** argv)   {
-    return ddcond_dump_conditions_functor(lcdd,true, argc, argv);
   }
+  printout(INFO,"CondPoolDump","SUCCESS: +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
+  printout(INFO,"CondPoolDump","SUCCESS: +++ Conditions pools successfully dumped");
+  printout(INFO,"CondPoolDump","SUCCESS: +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
+  return 1;
 }
 
+static int ddcond_dump_pools(LCDD& lcdd, int argc, char** argv)   {
+  return ddcond_dump_conditions_functor(lcdd,false, argc, argv);
+}
+static int ddcond_dump_conditions(LCDD& lcdd, int argc, char** argv)   {
+  return ddcond_dump_conditions_functor(lcdd,true, argc, argv);
+}
 DECLARE_APPLY(DD4hep_ConditionsPoolDump,ddcond_dump_pools)
 DECLARE_APPLY(DD4hep_ConditionsDump,ddcond_dump_conditions)
+
 // ======================================================================================
-namespace {
-  /// Plugin function: Dump of all Conditions associated to the detector elements
-  /**
-   *  Factory: DD4hep_DetElementConditionsDump
-   *
-   *  \author  M.Frank
-   *  \version 1.0
-   *  \date    01/04/2016
-   */
-  int ddcond_detelement_dump(LCDD& lcdd, int /* argc */, char** /* argv */)   {
-    struct Actor {
-      ConditionsManager manager;
-      ConditionsPrinter printer;
-      dd4hep_ptr<UserPool> user_pool;
-      const IOVType* iov_type;
+
+/// Plugin function: Dump of all Conditions associated to the detector elements
+/**
+ *  Factory: DD4hep_DetElementConditionsDump
+ *
+ *  \author  M.Frank
+ *  \version 1.0
+ *  \date    01/04/2016
+ */
+static int ddcond_detelement_dump(LCDD& lcdd, int /* argc */, char** /* argv */)   {
+  struct Actor {
+    ConditionsManager manager;
+    ConditionsPrinter printer;
+    dd4hep_ptr<UserPool> user_pool;
+    const IOVType* iov_type;
       
-      /// Standard constructor
-      Actor(ConditionsManager m)  : manager(m) {
-        iov_type = manager.iovType("run");
-        IOV  iov(iov_type);
-        iov.set(1500);
-        long num_updated = manager.prepare(iov, user_pool);
-        printout(INFO,"Conditions",
-                 "+++ ConditionsUpdate: Updated %ld conditions of type %s.",
-                 num_updated, iov_type ? iov_type->str().c_str() : "???");
-        user_pool->print("User pool");
-      }
-      /// Default destructor
-      ~Actor()   {
-        manager.clean(iov_type, 20);
-        user_pool->clear();
-        user_pool.release();
-      }
-      /// Dump method.
-      long dump(DetElement de,int level)   {
-        const DetElement::Children& children = de.children();
-        PlacedVolume place = de.placement();
-        char sens = place.volume().isSensitive() ? 'S' : ' ';
-        char fmt[128], tmp[32];
-        ::snprintf(tmp,sizeof(tmp),"%03d/",level+1);
-        ::snprintf(fmt,sizeof(fmt),"%03d %%-%ds %%s #Dau:%%d VolID:%%08X %%c",level+1,2*level+1);
-        printout(INFO,"DetectorDump",fmt,"",de.path().c_str(),int(children.size()),
-                 (unsigned long)de.volumeID(), sens);
-        if ( de.hasConditions() )  {
-          DetConditions conds(de);
-          Container cont = conds.conditions();
-          printer.setName(string(tmp)+de.name());
-          for(const auto& k : cont->keys )  {
-            Condition c = cont.get(k.first,*(user_pool.get()));
-            (printer)(c);
-          }
+    /// Standard constructor
+    Actor(ConditionsManager m)  : manager(m) {
+      iov_type = manager.iovType("run");
+      IOV  iov(iov_type);
+      iov.set(1500);
+      long num_updated = manager.prepare(iov, user_pool);
+      printout(INFO,"Conditions",
+               "+++ ConditionsUpdate: Updated %ld conditions of type %s.",
+               num_updated, iov_type ? iov_type->str().c_str() : "???");
+      user_pool->print("User pool");
+    }
+    /// Default destructor
+    ~Actor()   {
+      manager.clean(iov_type, 20);
+      user_pool->clear();
+      user_pool.release();
+    }
+    /// Dump method.
+    long dump(DetElement de,int level)   {
+      const DetElement::Children& children = de.children();
+      PlacedVolume place = de.placement();
+      char sens = place.volume().isSensitive() ? 'S' : ' ';
+      char fmt[128], tmp[32];
+      ::snprintf(tmp,sizeof(tmp),"%03d/",level+1);
+      ::snprintf(fmt,sizeof(fmt),"%03d %%-%ds %%s #Dau:%%d VolID:%%08X %%c",level+1,2*level+1);
+      printout(INFO,"DetectorDump",fmt,"",de.path().c_str(),int(children.size()),
+               (unsigned long)de.volumeID(), sens);
+      if ( de.hasConditions() )  {
+        DetConditions conds(de);
+        Container cont = conds.conditions();
+        printer.setName(string(tmp)+de.name());
+        for(const auto& k : cont->keys )  {
+          Condition c = cont.get(k.first,*(user_pool.get()));
+          (printer)(c);
         }
-        for (const auto& c : de.children() )
-          dump(c.second,level+1);
-        return 1;
       }
-    };
-    return Actor(ConditionsManager::from(lcdd)).dump(lcdd.world(),0);
-  }
+      for (const auto& c : de.children() )
+        dump(c.second,level+1);
+      return 1;
+    }
+  };
+  return Actor(ConditionsManager::from(lcdd)).dump(lcdd.world(),0);
 }
 DECLARE_APPLY(DD4hep_DetElementConditionsDump,ddcond_detelement_dump)
   
 // ======================================================================================
-namespace {
-  /// Plugin entry point.
-  static long ddcond_synchronize_conditions(lcdd_t& lcdd, int argc, char** argv) {
-    if ( argc > 0 )   {
-      string iov_type = argv[0];
-      IOV::Key::first_type iov_key = *(IOV::Key::first_type*)argv[1];
-      ConditionsManager    manager = ConditionsManager::from(lcdd);
-      const IOVType*       epoch   = manager.iovType(iov_type);
-      dd4hep_ptr<UserPool> user_pool;
-      IOV  iov(epoch);
 
-      iov.set(iov_key);
-      long num_updated = manager.prepare(iov, user_pool);
-      if ( iov_type == "epoch" )  {
-        char   c_evt[64];
-        struct tm evt;
-        ::gmtime_r(&iov_key, &evt);
-        ::strftime(c_evt,sizeof(c_evt),"%T %F",&evt);
-        printout(INFO,"Conditions",
-                 "+++ ConditionsUpdate: Updated %ld conditions... event time: %s",
-                 num_updated, c_evt);
-      }
-      else  {
-        printout(INFO,"Conditions",
-                 "+++ ConditionsUpdate: Updated %ld conditions... key[%s]: %ld",
-                 num_updated, iov_type.c_str(), iov_key);
-      }
-      user_pool->print("User pool");
-      manager.clean(epoch, 20);
-      user_pool->clear();
-      return 1;
+/// Plugin entry point: Synchronize conditions according to new IOV value
+/**
+ *  Factory: DD4hep_ConditionsSynchronize
+ *
+ *  \author  M.Frank
+ *  \version 1.0
+ *  \date    01/04/2016
+ */
+static long ddcond_synchronize_conditions(lcdd_t& lcdd, int argc, char** argv) {
+  if ( argc > 0 )   {
+    string iov_type = argv[0];
+    IOV::Key::first_type iov_key = *(IOV::Key::first_type*)argv[1];
+    ConditionsManager    manager = ConditionsManager::from(lcdd);
+    const IOVType*       epoch   = manager.iovType(iov_type);
+    dd4hep_ptr<UserPool> user_pool;
+    IOV  iov(epoch);
+
+    iov.set(iov_key);
+    long num_updated = manager.prepare(iov, user_pool);
+    if ( iov_type == "epoch" )  {
+      char   c_evt[64];
+      struct tm evt;
+      ::gmtime_r(&iov_key, &evt);
+      ::strftime(c_evt,sizeof(c_evt),"%T %F",&evt);
+      printout(INFO,"Conditions",
+               "+++ ConditionsUpdate: Updated %ld conditions... event time: %s",
+               num_updated, c_evt);
+    }
+    else  {
+      printout(INFO,"Conditions",
+               "+++ ConditionsUpdate: Updated %ld conditions... key[%s]: %ld",
+               num_updated, iov_type.c_str(), iov_key);
     }
-    except("Conditions","+++ Failed update conditions. No event time argument given!");
-    return 0;
+    user_pool->print("User pool");
+    manager.clean(epoch, 20);
+    user_pool->clear();
+    return 1;
   }
+  except("Conditions","+++ Failed update conditions. No event time argument given!");
+  return 0;
 }
 DECLARE_APPLY(DD4hep_ConditionsSynchronize,ddcond_synchronize_conditions)
 // ======================================================================================
 
-namespace {
-  /// Plugin entry point.
-  static long ddcond_clean_conditions(lcdd_t& lcdd, int argc, char** argv) {
-    if ( argc > 0 )   {
-      string iov_type = argv[0];
-      int max_age = *(int*)argv[1];
-      printout(INFO,"Conditions",
-               "+++ ConditionsUpdate: Cleaning conditions... type:%s max age:%d",
-               iov_type.c_str(), max_age);
-      ConditionsManager manager = ConditionsManager::from(lcdd);
-      const IOVType* epoch = manager.iovType(iov_type);
-      manager.clean(epoch, max_age);
-      return 1;
-    }
-    except("Conditions","+++ Failed cleaning conditions. Insufficient arguments!");
-    return 0;
+/// Plugin entry point: Clean conditions reposiory according to maximum age
+/**
+ *  Factory: DD4hep_ConditionsClean
+ *
+ *  \author  M.Frank
+ *  \version 1.0
+ *  \date    01/04/2016
+ */
+static long ddcond_clean_conditions(lcdd_t& lcdd, int argc, char** argv) {
+  if ( argc > 0 )   {
+    string iov_type = argv[0];
+    int max_age = *(int*)argv[1];
+    printout(INFO,"Conditions",
+             "+++ ConditionsUpdate: Cleaning conditions... type:%s max age:%d",
+             iov_type.c_str(), max_age);
+    ConditionsManager manager = ConditionsManager::from(lcdd);
+    const IOVType* epoch = manager.iovType(iov_type);
+    manager.clean(epoch, max_age);
+    return 1;
   }
+  except("Conditions","+++ Failed cleaning conditions. Insufficient arguments!");
+  return 0;
 }
 DECLARE_APPLY(DD4hep_ConditionsClean,ddcond_clean_conditions)
 // ======================================================================================
 
-#include "DDCond/ConditionsRepository.h"
-namespace {
-  /// Plugin entry point.
-  static long ddcond_create_repository(lcdd_t& lcdd, int argc, char** argv) {
-    if ( argc > 0 )   {
-      string output = argv[0];
-      printout(INFO,"Conditions",
-               "+++ ConditionsRepository: Creating %s",output.c_str());
-      ConditionsManager manager = ConditionsManager::from(lcdd);
-      ConditionsRepository().save(manager,output);
-      return 1;
-    }
-    except("Conditions","+++ Failed creating conditions repository. Insufficient arguments!");
-    return 0;
+/// Plugin entry point: Create repository csv file from loaded conditions
+/**
+ *  Factory: DD4hep_ConditionsCreateRepository
+ *
+ *  \author  M.Frank
+ *  \version 1.0
+ *  \date    01/04/2016
+ */
+static long ddcond_create_repository(lcdd_t& lcdd, int argc, char** argv) {
+  if ( argc > 0 )   {
+    string output = argv[0];
+    printout(INFO,"Conditions",
+             "+++ ConditionsRepository: Creating %s",output.c_str());
+    ConditionsManager manager = ConditionsManager::from(lcdd);
+    ConditionsRepository().save(manager,output);
+    return 1;
   }
+  except("Conditions","+++ Failed creating conditions repository. Insufficient arguments!");
+  return 0;
 }
 DECLARE_APPLY(DD4hep_ConditionsCreateRepository,ddcond_create_repository)
 // ======================================================================================
 
-namespace {
-  /// Plugin entry point.
-  static long ddcond_dump_repository(lcdd_t& lcdd, int argc, char** argv) {
-    if ( argc > 0 )   {
-      typedef ConditionsRepository::Data Data;
-      Data data;
-      string input = argv[0];
-      printout(INFO,"Conditions",
-               "+++ ConditionsRepository: Dumping %s",input.c_str());
-      ConditionsManager manager = ConditionsManager::from(lcdd);
-      if ( ConditionsRepository().load(input, data) )  {
-        printout(INFO,"Repository","%-8s  %-60s %-60s","Key","Name","Address");
-        for(Data::const_iterator i=data.begin(); i!=data.end(); ++i)  {
-          const ConditionsRepository::Entry& e = *i;
-          string add = e.address;
-          if ( add.length() > 80 ) add = e.address.substr(0,60) + "...";
-          printout(INFO,"Repository","%08X  %s",e.key,e.name.c_str());
-          printout(INFO,"Repository","          -> %s",e.address.c_str());
-        }
+/// Plugin entry point: Dump conditions repository csv file
+/**
+ *  Factory: DD4hep_ConditionsDumpRepository
+ *
+ *  \author  M.Frank
+ *  \version 1.0
+ *  \date    01/04/2016
+ */
+static long ddcond_dump_repository(lcdd_t& lcdd, int argc, char** argv) {
+  if ( argc > 0 )   {
+    typedef ConditionsRepository::Data Data;
+    Data data;
+    string input = argv[0];
+    printout(INFO,"Conditions",
+             "+++ ConditionsRepository: Dumping %s",input.c_str());
+    ConditionsManager manager = ConditionsManager::from(lcdd);
+    if ( ConditionsRepository().load(input, data) )  {
+      printout(INFO,"Repository","%-8s  %-60s %-60s","Key","Name","Address");
+      for(Data::const_iterator i=data.begin(); i!=data.end(); ++i)  {
+        const ConditionsRepository::Entry& e = *i;
+        string add = e.address;
+        if ( add.length() > 80 ) add = e.address.substr(0,60) + "...";
+        printout(INFO,"Repository","%08X  %s",e.key,e.name.c_str());
+        printout(INFO,"Repository","          -> %s",e.address.c_str());
       }
-      return 1;
     }
-    except("Conditions","+++ Failed dumping conditions repository. Insufficient arguments!");
-    return 0;
+    return 1;
   }
+  except("Conditions","+++ Failed dumping conditions repository. Insufficient arguments!");
+  return 0;
 }
 DECLARE_APPLY(DD4hep_ConditionsDumpRepository,ddcond_dump_repository)
 // ======================================================================================
 
-namespace {
-  /// Plugin entry point.
-  static long ddcond_load_repository(lcdd_t& lcdd, int argc, char** argv) {
-    if ( argc > 0 )   {
-      string input = argv[0];
-      printout(INFO,"Conditions",
-               "+++ ConditionsRepository: Loading %s",input.c_str());
-      ConditionsManager manager = ConditionsManager::from(lcdd);
-      ConditionsRepository::Data data;
-      ConditionsRepository().load(input, data);
-      return 1;
-    }
-    except("Conditions","+++ Failed loading conditions repository. Insufficient arguments!");
-    return 0;
+/// Plugin entry point: Load conditions repository csv file into conditions manager
+/**
+ *  Factory: DD4hep_ConditionsDumpRepository
+ *
+
+TO BE DONE!!!
+
+ *  \author  M.Frank
+ *  \version 1.0
+ *  \date    01/04/2016
+ */
+static long ddcond_load_repository(lcdd_t& lcdd, int argc, char** argv) {
+  if ( argc > 0 )   {
+    string input = argv[0];
+    printout(INFO,"Conditions",
+             "+++ ConditionsRepository: Loading %s",input.c_str());
+    ConditionsManager manager = ConditionsManager::from(lcdd);
+    ConditionsRepository::Data data;
+    ConditionsRepository().load(input, data);
+    return 1;
   }
+  except("Conditions","+++ Failed loading conditions repository. Insufficient arguments!");
+  return 0;
 }
 DECLARE_APPLY(DD4hep_ConditionsLoadRepository,ddcond_load_repository)
 // ======================================================================================
diff --git a/DDCond/src/plugins/ConditionsRepositoryParser.cpp b/DDCond/src/plugins/ConditionsRepositoryParser.cpp
index e07a07e04..1268dfe4b 100644
--- a/DDCond/src/plugins/ConditionsRepositoryParser.cpp
+++ b/DDCond/src/plugins/ConditionsRepositoryParser.cpp
@@ -44,8 +44,8 @@ namespace DD4hep  {
     class manager;
     class repository;
     class detelement;
-    class align_conditions;
-    class align_arbitrary;
+    class conditions;
+    class arbitrary;
     /// Conditions types
     class value;
     class mapping;
@@ -67,8 +67,8 @@ namespace DD4hep  {
   template <> void Converter<sequence>::operator()(xml_h e) const;
   template <> void Converter<mapping>::operator()(xml_h e) const;
   template <> void Converter<alignment>::operator()(xml_h e) const;
-  template <> void Converter<align_conditions>::operator()(xml_h seq)  const;
-  template <> void Converter<align_arbitrary>::operator()(xml_h seq)  const;
+  template <> void Converter<conditions>::operator()(xml_h seq)  const;
+  template <> void Converter<arbitrary>::operator()(xml_h seq)  const;
 }  
   
 using std::string;
@@ -82,6 +82,7 @@ using Geometry::DetElement;
 
 
 namespace {
+  static PrintLevel s_parseLevel = DEBUG;
   struct ConversionArg {
     DetElement         detector;
     ConditionsPool*    pool;
@@ -127,7 +128,7 @@ namespace {
     string add = XML::DocumentHandler::system_path(e);
     Condition cond(det.path()+"#"+nam, typ);
 
-    printout(INFO,"XMLConditions","++ Processing condition tag:%s name:%s type:%s [%s]",
+    printout(s_parseLevel,"XMLConditions","++ Processing condition tag:%s name:%s type:%s [%s]",
              tag.c_str(), nam.c_str(), typ.c_str(),
              Path(add).filename().c_str());
     cond->address  = add;
@@ -162,16 +163,16 @@ namespace DD4hep {
 
   /** Convert iov_type repository objects
    *
-   *  @author  M.Frank
-   *  @version 1.0
-   *  @date    01/04/2014
+   *  \author  M.Frank
+   *  \version 1.0
+   *  \date    01/04/2014
    */
   template <> void Converter<iov_type>::operator()(xml_h element) const {
     xml_dim_t e  = element;
     size_t id    = e.id();
     string nam   = e.nameStr();
     ConversionArg* arg  = _param<ConversionArg>();
-    printout(INFO,"XMLConditions","++ Registering IOV type: [%d]: %s",id,nam.c_str());
+    printout(s_parseLevel,"XMLConditions","++ Registering IOV type: [%d]: %s",id,nam.c_str());
     const IOVType* iov_type = arg->manager.registerIOVType(id,nam).second;
     if ( !iov_type )  {
       except("XMLConditions","Failed to register iov type: [%d]: %s",id,nam.c_str());
@@ -181,9 +182,9 @@ namespace DD4hep {
   /// Convert iov repository objects
   /**
    *
-   *  @author  M.Frank
-   *  @version 1.0
-   *  @date    01/04/2014
+   *  \author  M.Frank
+   *  \version 1.0
+   *  \date    01/04/2014
    */
   template <> void Converter<iov>::operator()(xml_h element) const {
     xml_dim_t e   = element;
@@ -191,18 +192,18 @@ namespace DD4hep {
     string    val = e.attr<string>(_U(validity));
     ConversionArg* arg  = _param<ConversionArg>();
     CurrentPool pool(arg);
-    printout(INFO,"XMLConditions","++ Reading IOV file: %s -> %s", val.c_str(), ref.c_str());
+    printout(s_parseLevel,"XMLConditions","++ Reading IOV file: %s -> %s", val.c_str(), ref.c_str());
     pool.set(arg->manager->registerIOV(val));
     XML::DocumentHolder doc(XML::DocumentHandler().load(element, element.attr_value(_U(ref))));
-    Converter<align_conditions>(lcdd,param,optional)(doc.root());
+    Converter<conditions>(lcdd,param,optional)(doc.root());
   }
 
   /// Convert manager repository objects
   /**
    *
-   *  @author  M.Frank
-   *  @version 1.0
-   *  @date    01/04/2014
+   *  \author  M.Frank
+   *  \version 1.0
+   *  \date    01/04/2014
    */
   template <> void Converter<manager>::operator()(xml_h element) const {
     ConversionArg* arg  = _param<ConversionArg>();
@@ -211,7 +212,7 @@ namespace DD4hep {
       string nam = d.nameStr();
       string val = d.valueStr();
       try  {
-        printout(INFO,"XMLConditions","++ Setup conditions Manager[%s] = %s",nam.c_str(),val.c_str());
+        printout(s_parseLevel,"XMLConditions","++ Setup conditions Manager[%s] = %s",nam.c_str(),val.c_str());
         arg->manager[nam] = val;
       }
       catch(const std::exception& e)  {
@@ -219,7 +220,7 @@ namespace DD4hep {
       }
     }
     arg->manager.initialize();
-    printout(INFO,"XMLConditions","++ Conditions Manager successfully initialized.");
+    printout(s_parseLevel,"XMLConditions","++ Conditions Manager successfully initialized.");
   }
 
   /// Convert rotation objects
@@ -227,15 +228,15 @@ namespace DD4hep {
    *
    *    <rotation x="0.5" y="0"  z="0"/>
    *
-   *  @author  M.Frank
-   *  @version 1.0
-   *  @date    01/04/2014
+   *  \author  M.Frank
+   *  \version 1.0
+   *  \date    01/04/2014
    */
   template <> void Converter<rotation>::operator()(xml_h e) const {
     xml_comp_t r(e);
     RotationZYX* v = (RotationZYX*)param;
     v->SetComponents(r.z(), r.y(), r.x());
-    printout(INFO,"XMLConditions",
+    printout(s_parseLevel,"XMLConditions",
              "++ Rotation:   x=%9.3f y=%9.3f   z=%9.3f  phi=%7.4f psi=%7.4f theta=%7.4f",
              r.x(), r.y(), r.z(), v->Phi(), v->Psi(), v->Theta());
   }
@@ -245,15 +246,15 @@ namespace DD4hep {
    *
    *    <position x="0.5" y="0"  z="0"/>
    *
-   *  @author  M.Frank
-   *  @version 1.0
-   *  @date    01/04/2014
+   *  \author  M.Frank
+   *  \version 1.0
+   *  \date    01/04/2014
    */
   template <> void Converter<position>::operator()(xml_h e) const {
     xml_comp_t p(e);
     Position* v = (Position*)param;
     v->SetXYZ(p.x(), p.y(), p.z());
-    printout(INFO,"XMLConditions","++ Position:   x=%9.3f y=%9.3f   z=%9.3f",
+    printout(s_parseLevel,"XMLConditions","++ Position:   x=%9.3f y=%9.3f   z=%9.3f",
              v->X(), v->Y(), v->Z());
   }
 
@@ -262,23 +263,23 @@ namespace DD4hep {
    *
    *    <pivot x="0.5" y="0"  z="0"/>
    *
-   *  @author  M.Frank
-   *  @version 1.0
-   *  @date    01/04/2014
+   *  \author  M.Frank
+   *  \version 1.0
+   *  \date    01/04/2014
    */
   template <> void Converter<pivot>::operator()(xml_h e) const {
     xml_comp_t p(e);
     double x,y,z;
     Translation3D* v = (Translation3D*)param;
     v->SetXYZ(x=p.x(), y=p.y(), z=p.z());
-    printout(INFO,"XMLConditions","++ Pivot:      x=%9.3f y=%9.3f   z=%9.3f",x,y,z);
+    printout(s_parseLevel,"XMLConditions","++ Pivot:      x=%9.3f y=%9.3f   z=%9.3f",x,y,z);
   }
 
   /// Convert conditions value objects (scalars)
   /**
-   *  @author  M.Frank
-   *  @version 1.0
-   *  @date    01/04/2014
+   *  \author  M.Frank
+   *  \version 1.0
+   *  \date    01/04/2014
    */
   template <> void Converter<value>::operator()(xml_h e) const {
     ConversionArg* arg = _param<ConversionArg>();
@@ -288,9 +289,9 @@ namespace DD4hep {
 
   /// Convert conditions sequence objects (unmapped containers)
   /**
-   *  @author  M.Frank
-   *  @version 1.0
-   *  @date    01/04/2014
+   *  \author  M.Frank
+   *  \version 1.0
+   *  \date    01/04/2014
    */
   template <> void Converter<sequence>::operator()(xml_h e) const {
     xml_dim_t      elt(e);
@@ -314,9 +315,9 @@ namespace DD4hep {
 
   /// Convert conditions STL maps
   /**
-   *  @author  M.Frank
-   *  @version 1.0
-   *  @date    01/04/2014
+   *  \author  M.Frank
+   *  \version 1.0
+   *  \date    01/04/2014
    */
   template <> void Converter<mapping>::operator()(xml_h e) const {
     xml_comp_t elt(e);
@@ -361,9 +362,9 @@ namespace DD4hep {
    *        <pivot    x="0" y="0"  z="100"/>
    *      </xx>
    *
-   *  @author  M.Frank
-   *  @version 1.0
-   *  @date    01/04/2014
+   *  \author  M.Frank
+   *  \version 1.0
+   *  \date    01/04/2014
    */
   template <> void Converter<alignment>::operator()(xml_h e) const {
     using Alignments::Delta;
@@ -402,9 +403,9 @@ namespace DD4hep {
 
   /** Convert detelement objects
    *
-   *  @author  M.Frank
-   *  @version 1.0
-   *  @date    01/04/2014
+   *  \author  M.Frank
+   *  \version 1.0
+   *  \date    01/04/2014
    */
   template <> void Converter<detelement>::operator()(xml_h e) const {
     xml_comp_t elt(e);
@@ -412,7 +413,7 @@ namespace DD4hep {
     CurrentDetector detector(arg);
     if ( elt.hasAttr(_U(path)) )  {
       detector.set(e.attr<string>(_U(path)));
-      printout(INFO,"XMLConditions","++ Processing condition for:%s",
+      printout(s_parseLevel,"XMLConditions","++ Processing condition for:%s",
                arg->detector.path().c_str());
     }
     if ( elt.hasAttr(_U(ref)) )  {
@@ -427,9 +428,9 @@ namespace DD4hep {
 
   /** Convert repository objects
    *
-   *  @author  M.Frank
-   *  @version 1.0
-   *  @date    01/04/2014
+   *  \author  M.Frank
+   *  \version 1.0
+   *  \date    01/04/2014
    */
   template <> void Converter<repository>::operator()(xml_h element) const {
     xml_coll_t(element,_UC(manager)).for_each(Converter<manager>(lcdd,param,optional));
@@ -439,11 +440,11 @@ namespace DD4hep {
 
   /** Convert any top level tag in the XML file
    *
-   *  @author  M.Frank
-   *  @version 1.0
-   *  @date    01/04/2014
+   *  \author  M.Frank
+   *  \version 1.0
+   *  \date    01/04/2014
    */
-  template <> void Converter<align_arbitrary>::operator()(xml_h e) const {
+  template <> void Converter<arbitrary>::operator()(xml_h e) const {
     xml_comp_t elt(e);
     string tag = elt.tag();
     if ( tag == "repository" )  
@@ -460,12 +461,26 @@ namespace DD4hep {
   }
 
   /// Convert alignment conditions entries
-  template <> void Converter<align_conditions>::operator()(xml_h e) const {
-    xml_coll_t(e,_U(star)).for_each(Converter<align_arbitrary>(lcdd,param,optional));
+  template <> void Converter<conditions>::operator()(xml_h e) const {
+    xml_coll_t(e,_U(star)).for_each(Converter<arbitrary>(lcdd,param,optional));
   }
 }
-#include "DD4hep/DD4hepUI.h"
 
+/** Basic entry point to set print level of this module.
+ *  \author  M.Frank
+ *  \version 1.0
+ *  \date    01/04/2014
+ */
+static long setup_repository_loglevel(lcdd_t& lcdd, int argc, char** argv)  {
+  if ( argc == 1 )  {
+    s_parseLevel = printLevel(argv[1]);
+    return 1;
+  }
+  return 0;
+}
+DECLARE_APPLY(DD4hep_ConditionsXMLRepositoryPrintLevel,setup_repository_loglevel)
+
+#include "DD4hep/DD4hepUI.h"
 /** Basic entry point to read alignment conditions files
  *
 
@@ -473,14 +488,15 @@ geoPluginRun -compact file:checkout/examples/AlignDet/compact/Telescope.xml  -vo
              -plugin DD4hepDetectorDump \
              -plugin DD4hepVolumeDump volids \
              -plugin DD4hepVolumeMgrTest all \
-             -plugin DD4hep_XMLAlignmentConditionsParser file:checkout/examples/Conditions/data/repository.xml \
-             -plugin DD4hep_ConditionsPoolDump
+             -plugin DD4hep_ConditionsXMLRepositoryParser file:checkout/examples/Conditions/data/repository.xml \
+             -plugin DD4hep_ConditionsPoolDump \
+             -plugin DD4hep_DetElementConditionsDump
 
- *  @author  M.Frank
- *  @version 1.0
- *  @date    01/04/2014
+ *  \author  M.Frank
+ *  \version 1.0
+ *  \date    01/04/2014
  */
-static long setup_alignment_Conditions(lcdd_t& lcdd, int argc, char** argv)  {
+static long setup_repository_Conditions(lcdd_t& lcdd, int argc, char** argv)  {
   if ( argc == 1 )  {
     //xml_h e = xml_h::Elt_t(argv[0]);
     DD4hepUI ui(lcdd);
@@ -488,10 +504,10 @@ static long setup_alignment_Conditions(lcdd_t& lcdd, int argc, char** argv)  {
     ConditionsManager mgr = ui.conditionsMgr();
     ConversionArg args(lcdd.world(), mgr);
     XML::DocumentHolder doc(XML::DocumentHandler().load(fname));
-    (DD4hep::Converter<align_conditions>(lcdd,&args))(doc.root());
+    (DD4hep::Converter<conditions>(lcdd,&args))(doc.root());
     return 1;
   }
   except("XML_DOC_READER","Invalid number of arguments to interprete conditions: %d != %d.",argc,1);
   return 0;
 }
-DECLARE_APPLY(DD4hep_XMLAlignmentConditionsParser,setup_alignment_Conditions)
+DECLARE_APPLY(DD4hep_ConditionsXMLRepositoryParser,setup_repository_Conditions)
diff --git a/DDCore/include/DD4hep/BuildType.h b/DDCore/include/DD4hep/BuildType.h
new file mode 100644
index 000000000..d3bffb03c
--- /dev/null
+++ b/DDCore/include/DD4hep/BuildType.h
@@ -0,0 +1,47 @@
+//==========================================================================
+//  AIDA Detector description implementation for LCD
+//--------------------------------------------------------------------------
+// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
+// All rights reserved.
+//
+// For the licensing terms see $DD4hepINSTALL/LICENSE.
+// For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
+//
+//  \author   Markus Frank
+//  \date     2016-02-02
+//  \version  1.0
+//
+//==========================================================================
+#ifndef DD4HEP_BUILDTYPES_H 
+#define DD4HEP_BUILDTYPES_H 1
+
+// C/C++ include files
+#include <string>
+
+
+/// Namespace for the AIDA detector description toolkit
+namespace DD4hep {
+
+  /// Detector description build types.
+  /** enum LCDDBuildType LCDD.h  DD4hep/LCDD.h
+   * The corresponding flag is ONLY valid while parsing the
+   * compact description. If no eometry, ie. at all other times
+   * the accessor to the flag returns BUILD_NONE.
+   */
+  enum LCDDBuildType {
+    BUILD_NONE = 0,
+    BUILD_DEFAULT = 1,
+    BUILD_SIMU = BUILD_DEFAULT,
+    BUILD_RECO,
+    BUILD_DISPLAY,
+    BUILD_ENVELOPE
+  };
+
+  /// Translate string representation of the geometry build type to value
+  LCDDBuildType buildType(const char* value);
+
+  /// Translate string representation of the geometry build type to value
+  LCDDBuildType buildType(const std::string& value);
+
+} /* End namespace DD4hep             */
+#endif  // DD4HEP_BUILDTYPES_H
diff --git a/DDCore/include/DD4hep/LCDD.h b/DDCore/include/DD4hep/LCDD.h
index 5d981c00d..fc0741980 100644
--- a/DDCore/include/DD4hep/LCDD.h
+++ b/DDCore/include/DD4hep/LCDD.h
@@ -33,6 +33,7 @@
 #include "DD4hep/Segmentations.h"
 #include "DD4hep/VolumeManager.h"
 #include "DD4hep/NamedObject.h"
+#include "DD4hep/BuildType.h"
 
 // C/C++ include files
 #include <map>
@@ -56,16 +57,6 @@ namespace DD4hep {
   // Foward declarations
   class NamedObject;
 
-  /// Detector description build types.
-  /** enum LCDDBuildType LCDD.h  DD4hep/LCDD.h
-   * The corresponding flag is ONLY valid while parsing the
-   * compact description. If no eometry, ie. at all other times
-   * the accessor to the flag returns BUILD_NONE.
-   */
-  enum LCDDBuildType {
-    BUILD_NONE = 0, BUILD_DEFAULT = 1, BUILD_SIMU = BUILD_DEFAULT, BUILD_RECO, BUILD_DISPLAY, BUILD_ENVELOPE
-  };
-
   /// Namespace for the AIDA detector description toolkit supporting XML utilities
   namespace XML {
     class UriReader;
diff --git a/DDCore/include/DD4hep/OpaqueData.h b/DDCore/include/DD4hep/OpaqueData.h
index 394458981..76ea989ed 100644
--- a/DDCore/include/DD4hep/OpaqueData.h
+++ b/DDCore/include/DD4hep/OpaqueData.h
@@ -79,7 +79,8 @@ namespace DD4hep {
    *  \ingroup DD4HEP_CONDITIONS
    */
   class OpaqueDataBlock : public OpaqueData   {
-  private:
+
+  protected:
     enum {
       PLAIN_DATA = 1<<0,
       ALLOC_DATA = 1<<1,
@@ -114,9 +115,6 @@ namespace DD4hep {
     template <typename T> T& bind();
     /// Bind data value [Equivalent to set(value)]
     template <typename T> T& bind(const std::string& value);
-    /// Bind data value. Ugly, but some compilers otherwise do not recognize the function in templates
-    template <typename T> void bind(const T*);
-
     /// Set data value
     void assign(const void* ptr,const std::type_info& typ);
     /// Bind grammar and assign value
diff --git a/DDCore/include/DD4hep/Printout.h b/DDCore/include/DD4hep/Printout.h
index d7aee3e41..a754e905b 100644
--- a/DDCore/include/DD4hep/Printout.h
+++ b/DDCore/include/DD4hep/Printout.h
@@ -45,7 +45,14 @@ namespace DD4hep {
   }
 
   enum PrintLevel {
-    NOLOG = 0, VERBOSE=1, DEBUG=2, INFO=3, WARNING=4, ERROR=5, FATAL=6, ALWAYS
+    NOLOG    = 0,
+    VERBOSE  = 1,
+    DEBUG    = 2,
+    INFO     = 3,
+    WARNING  = 4,
+    ERROR    = 5,
+    FATAL    = 6,
+    ALWAYS   = 7
   };
 
 #ifndef __CINT__
@@ -197,6 +204,12 @@ namespace DD4hep {
   /// Access the current printer level
   PrintLevel printLevel();
 
+  /// Translate the printer level from string to value
+  PrintLevel printLevel(const char* value);
+
+  /// Translate the printer level from string to value
+  PrintLevel printLevel(const std::string& value);
+
   /// Helper class template to implement ASCII object dumps
   /** @class Printer Conversions.h  DD4hep/compact/Conversions.h
    *
diff --git a/DDCore/include/DD4hep/objects/OpaqueData_inl.h b/DDCore/include/DD4hep/objects/OpaqueData_inl.h
index 236454dc8..be035e98e 100644
--- a/DDCore/include/DD4hep/objects/OpaqueData_inl.h
+++ b/DDCore/include/DD4hep/objects/OpaqueData_inl.h
@@ -38,26 +38,25 @@ namespace DD4hep {
       t->~T();
     }
   }
+
   /// Generic getter. Specify the exact type, not a polymorph type
   template <typename T> T& OpaqueData::get() {
     if (!grammar || (grammar->type() != typeid(T))) { throw std::bad_cast(); }
     return *(T*)pointer;
   }
+
   /// Generic getter (const version). Specify the exact type, not a polymorph type
   template <typename T> const T& OpaqueData::get() const {
     if (!grammar || (grammar->type() != typeid(T))) { throw std::bad_cast(); }
     return *(T*)pointer;
   }
+
   /// Bind data value
   template <typename T> T& OpaqueDataBlock::bind()  {
     this->bind(&BasicGrammar::instance<T>(),opaqueCopyObject<T>,opaqueDestructObject<T>);
     return *(new(this->pointer) T());
   }
-  /// Bind data value. Ugly, but some compilers otherwise do not recognize the function in templates
-  template <typename T> void OpaqueDataBlock::bind(const T*)  {
-    this->bind(&BasicGrammar::instance<T>(),opaqueCopyObject<T>,opaqueDestructObject<T>);
-    new(this->pointer) T();
-  }
+
   /// Bind grammar and assign value
   template <typename T> T& OpaqueDataBlock::bind(const std::string& value)   {
     T& ret = this->bind<T>();
@@ -67,6 +66,7 @@ namespace DD4hep {
     }
     return ret;
   }
+
   /// Bind grammar and assign value
   template <typename T> T& OpaqueDataBlock::set(const std::string& value)   {
     T& ret = this->bind<T>();
diff --git a/DDCore/src/BuildType.cpp b/DDCore/src/BuildType.cpp
new file mode 100644
index 000000000..d18d3866c
--- /dev/null
+++ b/DDCore/src/BuildType.cpp
@@ -0,0 +1,50 @@
+//==========================================================================
+//  AIDA Detector description implementation for LCD
+//--------------------------------------------------------------------------
+// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
+// All rights reserved.
+//
+// For the licensing terms see $DD4hepINSTALL/LICENSE.
+// For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
+//
+// Author     : M.Frank
+//
+//==========================================================================
+
+// Framework includes
+#include "DD4hep/BuildType.h"
+
+// C/C++ include files
+#include <stdexcept>
+#include <cstring>
+#include <string>
+
+/// Translate string representation of the geometry build type to value
+DD4hep::LCDDBuildType DD4hep::buildType(const char* value)   {
+  if ( !value )
+    return BUILD_DEFAULT;
+  else if ( strncmp(value,"BUILD_DEFAULT",9)==0 )
+    return BUILD_DEFAULT;
+  else if ( strncmp(value,"BUILD_SIMU",9)==0 )
+    return BUILD_SIMU;
+  else if ( strcmp(value,"1")==0 )
+    return BUILD_SIMU;
+  else if ( strncmp(value,"BUILD_RECO",9)==0 )
+    return BUILD_RECO;
+  else if ( strcmp(value,"2")==0 )
+    return BUILD_RECO;
+  else if ( strncmp(value,"BUILD_DISPLAY",9)==0 )
+    return BUILD_DISPLAY;
+  else if ( strcmp(value,"3")==0 )
+    return BUILD_DISPLAY;
+  else if ( strncmp(value,"BUILD_ENVELOPE",9)==0 )
+    return BUILD_ENVELOPE;
+  else if ( strcmp(value,"4")==0 )
+    return BUILD_ENVELOPE;
+  throw std::runtime_error(std::string("Invalid build type value: ")+value);
+}
+
+/// Translate string representation of the geometry build type to value
+DD4hep::LCDDBuildType DD4hep::buildType(const std::string& value)   {
+  return buildType(value.c_str());
+}
diff --git a/DDCore/src/OpaqueDataBinder.cpp b/DDCore/src/OpaqueDataBinder.cpp
index 2c55e5c7f..80762d04d 100644
--- a/DDCore/src/OpaqueDataBinder.cpp
+++ b/DDCore/src/OpaqueDataBinder.cpp
@@ -30,23 +30,23 @@ namespace DD4hep {
 
   /// Helper class to bind string values to C++ data objects (primitive or complex)
   template <typename T, typename Q> bool ValueBinder::bind(T& object, const string& val, const Q*) const
-  {  object.bind<Q>(val);            return true;  }
+  {  object.template bind<Q>(val);            return true;  }
 
   /// Helper class to bind string values to a STL vector of data objects (primitive or complex)
   template <typename T, typename Q> bool VectorBinder::bind(T& object, const string& val, const Q*) const
-  {  object.bind<vector<Q> >(val);   return true;  }
+  {  object.template bind<vector<Q> >(val);   return true;  }
 
   /// Helper class to bind string values to a STL list of data objects (primitive or complex)
   template <typename T, typename Q> bool ListBinder::bind(T& object, const string& val, const Q*) const
-  {  object.bind<list<Q> >(val);     return true;  }
+  {  object.template bind<list<Q> >(val);     return true;  }
 
   /// Helper class to bind string values to a STL set of data objects (primitive or complex)
   template <typename T, typename Q> bool SetBinder::bind(T& object, const string& val, const Q*) const
-  {  object.bind<set<Q> >(val);      return true;  }
+  {  object.template bind<set<Q> >(val);      return true;  }
 
   /// Helper class to bind STL map objects
   template <typename T, typename Q> bool MapBinder::bind(T& object, const Q*) const
-  {  object.bind((const Q*)0);       return true;  }
+  {  object.template bind<Q>();               return true;  }
 
   /// Binding function for scalar items. See the implementation function for the concrete instantiations
   template <typename BINDER, typename T> 
@@ -118,7 +118,7 @@ namespace DD4hep {
                               const VAL*)
   {
     typedef map<KEY,VAL> map_t;
-    map_t& m = object.get<map_t>();
+    map_t& m = object.template get<map_t>();
     VAL v;
     if ( !BasicGrammar::instance<VAL>().fromString(&v, val) )  {
       except("OpaqueDataBinder","++ Failed to convert conditions map entry.");
@@ -169,7 +169,7 @@ namespace DD4hep {
   {
     typedef map<KEY,VAL> map_t;
     pair<KEY,VAL> entry;
-    map_t& m = object.get<map_t>();
+    map_t& m = object.template get<map_t>();
     if ( !BasicGrammar::instance<pair<KEY,VAL> >().fromString(&entry,data) )  {
       except("OpaqueDataBinder","++ Failed to convert conditions map entry.");
     }
diff --git a/DDCore/src/Printout.cpp b/DDCore/src/Printout.cpp
index 34f6af1be..071b5138b 100644
--- a/DDCore/src/Printout.cpp
+++ b/DDCore/src/Printout.cpp
@@ -1,4 +1,3 @@
-// $Id: $
 //==========================================================================
 //  AIDA Detector description implementation for LCD
 //--------------------------------------------------------------------------
@@ -16,6 +15,7 @@
 #include "DD4hep/Printout.h"
 
 // C/C++ include files
+#include <cstring>
 #include <cstdarg>
 #include <stdexcept>
 
@@ -304,6 +304,35 @@ DD4hep::PrintLevel DD4hep::printLevel()  {
   return print_lvl;
 }
 
+/// Translate the printer level from string to value
+DD4hep::PrintLevel DD4hep::printLevel(const char* value)  {
+  if ( !value ) except("Printout","Invalid printlevel requested");
+  // Explicit values
+  if ( strcmp(value,"NOLOG")   == 0 ) return DD4hep::NOLOG;
+  if ( strcmp(value,"VERBOSE") == 0 ) return DD4hep::VERBOSE;
+  if ( strcmp(value,"DEBUG")   == 0 ) return DD4hep::DEBUG;
+  if ( strcmp(value,"INFO")    == 0 ) return DD4hep::INFO;
+  if ( strcmp(value,"WARNING") == 0 ) return DD4hep::WARNING;
+  if ( strcmp(value,"ERROR")   == 0 ) return DD4hep::ERROR;
+  if ( strcmp(value,"FATAL")   == 0 ) return DD4hep::FATAL;
+  if ( strcmp(value,"ALWAYS")  == 0 ) return DD4hep::ALWAYS;
+  // Numeric values
+  if ( strcmp(value,"0")       == 0 ) return DD4hep::NOLOG;
+  if ( strcmp(value,"1")       == 0 ) return DD4hep::VERBOSE;
+  if ( strcmp(value,"2")       == 0 ) return DD4hep::DEBUG;
+  if ( strcmp(value,"3")       == 0 ) return DD4hep::INFO;
+  if ( strcmp(value,"4")       == 0 ) return DD4hep::WARNING;
+  if ( strcmp(value,"5")       == 0 ) return DD4hep::ERROR;
+  if ( strcmp(value,"6")       == 0 ) return DD4hep::FATAL;
+  if ( strcmp(value,"7")       == 0 ) return DD4hep::ALWAYS;
+  except("Printout","Unknown printlevel requested:%s",value);
+}
+
+/// Translate the printer level from string to value
+DD4hep::PrintLevel DD4hep::printLevel(const std::string& value)  {
+  return printLevel(value.c_str());
+}
+
 /// Set new printout format for the 3 fields: source-level-message. All 3 are strings
 string DD4hep::setPrintFormat(const string& new_format) {
   string old = print_fmt;
diff --git a/DDCore/src/plugins/StandardPlugins.cpp b/DDCore/src/plugins/StandardPlugins.cpp
index 28de2bd07..8b3c74e7c 100644
--- a/DDCore/src/plugins/StandardPlugins.cpp
+++ b/DDCore/src/plugins/StandardPlugins.cpp
@@ -35,30 +35,6 @@ using namespace std;
 using namespace DD4hep;
 using namespace DD4hep::Geometry;
 
-static LCDDBuildType build_type(const char* value)   {
-  if ( !value )
-    return BUILD_DEFAULT;
-  else if ( strcmp(value,"BUILD_DEFAULT")==0 )
-    return BUILD_DEFAULT;
-  else if ( strcmp(value,"BUILD_SIMU")==0 )
-    return BUILD_SIMU;
-  else if ( strcmp(value,"1")==0 )
-    return BUILD_SIMU;
-  else if ( strcmp(value,"BUILD_RECO")==0 )
-    return BUILD_RECO;
-  else if ( strcmp(value,"2")==0 )
-    return BUILD_RECO;
-  else if ( strcmp(value,"BUILD_DISPLAY")==0 )
-    return BUILD_DISPLAY;
-  else if ( strcmp(value,"3")==0 )
-    return BUILD_DISPLAY;
-  else if ( strcmp(value,"BUILD_ENVELOPE")==0 )
-    return BUILD_ENVELOPE;
-  else if ( strcmp(value,"4")==0 )
-    return BUILD_ENVELOPE;
-  throw runtime_error(string("Invalid build type value: ")+value);
-}
-
 /// Basic entry point to create a LCDD instance
 /**
  *  Factory: LCDD_constructor
@@ -160,7 +136,7 @@ static long load_compact(LCDD& lcdd, int argc, char** argv) {
     LCDDBuildType type = BUILD_DEFAULT;
     string input = argv[0];
     if ( argc > 1 )  {
-      type = build_type(argv[1]);
+      type = buildType(argv[1]);
       printout(INFO,"CompactLoader","+++ Processing compact file: %s with flag %s",
                input.c_str(), argv[1]);
       lcdd.fromCompact(input,type);
@@ -194,7 +170,7 @@ static long load_xml(LCDD& lcdd, int argc, char** argv) {
     LCDDBuildType type = BUILD_DEFAULT;
     string input = argv[0];
     if ( argc > 1 )  {
-      type = build_type(argv[1]);
+      type = buildType(argv[1]);
       printout(INFO,"XMLLoader","+++ Processing XML file: %s with flag %s",
                input.c_str(), argv[1]);
       lcdd.fromXML(input,type);
@@ -232,7 +208,7 @@ static long process_xml_doc(LCDD& lcdd, int argc, char** argv) {
       XML::Handle_t input(h);
       if ( input.ptr() )   {
         if ( argc > 1 )  {
-          type = build_type(argv[1]);
+          type = buildType(argv[1]);
           printout(INFO,"XMLLoader","+++ Processing XML element: %s with flag %s",
                    input.tag().c_str(), argv[1]);
         }
-- 
GitLab