DD4hep - The AIDA detector description toolkit for high energy physics experiments
DD4hep  Rev:Unversioneddirectory
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ConditionsDependencyHandler.cpp
Go to the documentation of this file.
1 // $Id$
2 //==========================================================================
3 // AIDA Detector description implementation for LCD
4 //--------------------------------------------------------------------------
5 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
6 // All rights reserved.
7 //
8 // For the licensing terms see $DD4hepINSTALL/LICENSE.
9 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
10 //
11 // Author : M.Frank
12 //
13 //==========================================================================
14 
15 // Framework include files
16 #include "DD4hep/Printout.h"
18 
19 using namespace DD4hep;
20 using namespace DD4hep::Conditions;
21 
24  UserPool& pool,
25  const Dependencies& dependencies,
26  void* user_param)
27  : m_manager(mgr), m_pool(pool), m_dependencies(dependencies), m_userParam(user_param)
28 {
29 }
30 
33 }
34 
37  Condition c = m_pool.get(key);
38  if ( c.isValid() ) {
39  Condition::Object* obj = c.ptr();
40  const IOV& required = m_pool.validity();
41  if ( obj->iov && IOV::key_is_contained(required.keyData,obj->iov->keyData) )
42  return c;
44  if ( i != m_dependencies.end() ) {
46  const ConditionDependency* dep = (*i).second.get();
47  m_pool.remove(key);
48  return do_callback(*dep);
49  }
50  }
52  if ( i != m_dependencies.end() ) {
53  const ConditionDependency* dep = (*i).second.get();
54  return do_callback(*dep);
55  }
56  return Condition();
57 }
58 
59 
63  try {
65  ConditionUpdateCall::Context ctxt(*this, dep, m_userParam, iov.reset().invert());
66  Condition cond = (*dep.callback)(dep.target, ctxt);
67  Condition::Object* obj = cond.ptr();
68  if ( obj ) {
69  if ( !obj->hash ) obj->hash = ConditionKey::hashCode(obj->name);
70  cond->setFlag(Condition::DERIVED);
71  cond->iov = m_pool.validityPtr();
72  // Must IMMEDIATELY insert to handle inter-dependencies.
73  m_pool.insert(cond);
74  }
75  return obj;
76  }
77  catch(const std::exception& e) {
78  printout(ERROR,"ConditionDependency",
79  "+++ Exception while creating dependent Condition %s:",
80  dep.target.name.c_str());
81  printout(ERROR,"ConditionDependency","\t\t%s", e.what());
82  }
83  catch(...) {
84  printout(ERROR,"ConditionDependency",
85  "+++ UNKNOWN exception while creating dependent Condition %s.",
86  dep.target.name.c_str());
87  }
88  m_pool.print("*");
89  except("ConditionDependency",
90  "++ Exception while creating dependent Condition %s.",
91  dep.target.name.c_str());
92  return 0;
93 }
94 
97  return do_callback(*dep);
98 }
virtual bool remove(key_type hash_key)=0
Remove condition by key from pool.
virtual bool insert(Condition cond)=0
Register a new condition to this pool.
Interface for conditions pool optimized to host conditions updates.
bool isValid() const
Check the validity of the object held by the handle.
Definition: Handle.h:124
const IOV & validity() const
Access the interval of validity for this user pool.
The data class behind a conditions handle.
iterator end()
Mini-container interface: end of iteration.
virtual void print(const std::string &opt) const =0
Print pool content.
Main condition object handle.
Definition: Conditions.h:70
virtual Condition get(key_type key) const =0
Check if a condition exists in the pool and return it to the caller.
return e
Definition: Volumes.cpp:297
int except(const std::string &src, const std::string &fmt,...)
Calls the display action with ERROR and throws an std::runtime_error exception.
Definition: Printout.cpp:217
const IOVType * iovType
Definition: IOV.h:69
T * ptr() const
Access to the held object.
Definition: Handle.h:149
Condition dependency definition.
Condition::Object * do_callback(const ConditionDependency &dep) const
Internal call to trigger update callback.
UserPool & m_pool
Reference to the user pool object.
Class describing the interval of validty.
Definition: IOV.h:59
Key keyData
Definition: IOV.h:70
ConditionUpdateCall * callback
Reference to the update callback. No auto pointer. callback may be shared.
void * m_userParam
User defined optional processing parameter.
const Dependencies & m_dependencies
Dependency container to be resolved.
std::string name
The object name.
Definition: NamedObject.h:34
const IOV * validityPtr() const
Access the interval of validity for this user pool.
ConditionUpdateContext class used by the derived conditions calculation mechanism.
Conditions internal namespace declaration.
static bool key_is_contained(const Key &key, const Key &test)
Check if IOV 'test' is fully contained in IOV 'key'.
Definition: IOV.h:127
virtual Condition get(const ConditionKey &key) const
ConditionResolver implementation: Interface to access conditions.
std::string name
String representation of the key object.
Definition: Conditions.h:279
static key_type hashCode(const char *value)
Hash code generation from input string.
Definition: Conditions.h:323
const iov_type * iov
Interval of validity.
ConditionsDependencyHandler(ConditionsManager::Object *mgr, UserPool &pool, const Dependencies &dependencies, void *user_param)
Initializing constructor.
ConditionKey target
Key to the condition to be updated.
int printout(PrintLevel severity, const char *src, const char *fmt,...)
Calls the display action with a given severity level.
Definition: Printout.cpp:111
iterator find(Condition::key_type key)
Mini-container interface: find element by key.
Condition::Object * operator()(const ConditionDependency *dep) const
Handler callback to process multiple derived conditions.
key_type hash
Hash value of the name.