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
ConditionsDependencyCollection.h
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 #ifndef DDCOND_CONDITIONSDEPENDENCYCOLLECTION_H
15 #define DDCOND_CONDITIONSDEPENDENCYCOLLECTION_H
16 
17 // Framework include files
18 #include "DD4hep/Detector.h"
19 #include "DD4hep/Conditions.h"
21 
22 // C++ include files
23 #include <map>
24 #include <set>
25 
27 namespace DD4hep {
28 
30  namespace Conditions {
31 
32  // Forward declarations
33  class UserPool;
34  class ConditionDependency;
35 
37 
43  public:
44 
47  struct Holder {
48  int flag;
50  Holder(Dependency* d) : flag(0), dep(d) {}
51  Holder& operator=(Dependency* d) { dep = d; flag=0; return *this; }
52  operator int() const { return dep ? 1 : 0; }
53  operator Dependency*&() { return dep; }
54  Dependency* operator->() const { return dep; }
55  Dependency* get() const { return dep; }
56  };
57 
59  typedef std::map<unsigned int,Holder> Dependencies;
60  typedef Dependencies::const_iterator const_iterator;
61  typedef Dependencies::iterator iterator;
62  typedef Dependencies::key_type key_type;
63  typedef Dependencies::mapped_type mapped_type;
64 
66 
71  class Functor {
72  public:
77  };
80  public:
88  void clear();
90  bool empty() const { return dependencies.empty(); }
92  size_t size() const { return dependencies.size(); }
94  iterator begin() { return dependencies.begin(); }
96  const_iterator begin() const { return dependencies.begin(); }
98  iterator end() { return dependencies.end(); }
100  const_iterator end() const { return dependencies.end(); }
103  { return dependencies.find(key); }
106  { return dependencies.find(key); }
108  std::pair<iterator,bool> insert(const Dependencies::value_type& entry);
110  std::pair<iterator,bool> insert(Dependency* dep);
112  template <typename T> void for_each(const T& function) const
113  { std::for_each(dependencies.begin(),dependencies.end(),function); }
114  };
115 
117 
122  template <typename Data, typename Oper>
124  public:
126  Data& user_data;
128  const Oper& user_oper;
130  DependencyCollector(Data& d, const Oper& o) : user_data(d), user_oper(o) {}
132  void operator()(const Dependencies::value_type& e) const
133  { user_oper(user_data, e); }
134  };
135  } /* End namespace Conditions */
136 } /* End namespace DD4hep */
137 
138 #endif /* DDCOND_CONDITIONSDEPENDENCYCOLLECTION_H */
void clear()
Clear the dependency container. Destroys the contained stuff.
ConditionDependency Dependency
Forward definition of the dependency type.
std::pair< iterator, bool > insert(const Dependencies::value_type &entry)
Mini-container interface: insert element by key.
const_iterator end() const
Mini-container interface: end of iteration (const)
Collection of DetElements from the conditions dependencies.
std::map< unsigned int, Holder > Dependencies
Forward definition of the dependency container type.
const_iterator find(Condition::key_type key) const
Mini-container interface: find element by key (const)
iterator end()
Mini-container interface: end of iteration.
void copy(Alignment from, Alignment to)
Copy alignment object from source object.
return e
Definition: Volumes.cpp:297
unsigned int key_type
Forward definition of the key type.
Definition: Conditions.h:75
ConditionsDependencyCollection::Dependencies Dependencies
Forward definition of the dependency container type.
iterator begin()
Mini-container interface: begin of iteration.
Data & user_data
Reference to collection result (Object owned by caller)
Condition dependency definition.
const_iterator begin() const
Mini-container interface: begin of iteration (const)
const Oper & user_oper
Reference to the collection operator (Object owned by caller)
size_t size() const
Mini-container interface: number of entries.
void operator()(const Dependencies::value_type &e) const
Default callback to work on dependency items. May be overloaded if necessary.
ConditionsDependencyCollection::Dependency Dependency
Forward definition of the dependency type.
iterator find(Condition::key_type key)
Mini-container interface: find element by key.
void for_each(const T &function) const
Create view by application of functor.
bool empty() const
Mini-container interface: emptyness check.
DependencyCollector(Data &d, const Oper &o)
Initializing constructor.