DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
Operators.h
Go to the documentation of this file.
1 //==========================================================================
2 // AIDA Detector description implementation
3 //--------------------------------------------------------------------------
4 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
5 // All rights reserved.
6 //
7 // For the licensing terms see $DD4hepINSTALL/LICENSE.
8 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
9 //
10 // Author : M.Frank
11 //
12 //==========================================================================
13 
14 #ifndef DD4HEP_OPERATORS_H
15 #define DD4HEP_OPERATORS_H
16 
17 // C/C++ include files
18 #include <string>
19 
21 namespace dd4hep {
22 
24  template <typename T> class ByName {
25  private:
27  template <typename Q> ByName<T>& operator=(const ByName<Q>& /* copy */) { return *this; }
28  public:
30  const std::string& name;
32  ByName(const std::string& nam) : name(nam) {}
34  ByName(const ByName& copy) : name(copy.name) {}
36  bool operator()(const T& entry) const { return entry.name() == name; }
38  bool operator()(const T* entry) const { return entry->name() == name; }
39  };
40  template <typename T> ByName<T> byName(const std::string& n) { return ByName<T>(n); }
41  template <typename T> ByName<T> byName(const T* o) { return ByName<T>(o->name()); }
42  template <typename T> ByName<T> byName(const T& o) { return ByName<T>(o.name()); }
43 
45  template <typename T> class ByNameAttr {
46  private:
48  template <typename Q> ByNameAttr<T>& operator=(const ByNameAttr<Q>& /* copy */) { return *this; }
49  public:
51  const std::string& name;
53  ByNameAttr(const std::string& nam) : name(nam) {}
57  bool operator()(const T& entry) const { return entry.name == name; }
59  bool operator()(const T* entry) const { return entry->name == name; }
60  };
61 
62  template <typename T> ByNameAttr<T> byNameAttr(const std::string& nam) { return ByNameAttr<T>(nam); }
63  template <typename T> ByNameAttr<T> byNameAttr(const T* o) { return ByNameAttr<T>(o->name); }
64  template <typename T> ByNameAttr<T> byNameAttr(const T& o) { return ByNameAttr<T>(o.name); }
65 
66 } // End namespace dd4hep
67 #endif // DD4HEP_OPERATORS_H
dd4hep::ByNameAttr::ByNameAttr
ByNameAttr(const ByNameAttr &copy)
Copy constructor.
Definition: Operators.h:55
dd4hep::ByNameAttr::operator=
ByNameAttr< T > & operator=(const ByNameAttr< Q > &)
Assignment operator.
Definition: Operators.h:48
dd4hep::ByName::operator=
ByName< T > & operator=(const ByName< Q > &)
Assignment operator.
Definition: Operators.h:27
dd4hep::byName
ByName< T > byName(const std::string &n)
Definition: Operators.h:40
dd4hep::ByNameAttr
Helper functor to select elements by name (using name member variable)
Definition: Operators.h:45
dd4hep::ByNameAttr::operator()
bool operator()(const T &entry) const
Operator to select from object containers.
Definition: Operators.h:57
dd4hep::ByNameAttr::operator()
bool operator()(const T *entry) const
Operator to select from pointer containers.
Definition: Operators.h:59
dd4hep::ByName::operator()
bool operator()(const T &entry) const
Operator to select from object containers.
Definition: Operators.h:36
dd4hep::ByNameAttr::name
const std::string & name
Reference name.
Definition: Operators.h:51
dd4hep::ByName
Helper functor to select elements by name (using name() member method)
Definition: Operators.h:24
dd4hep::ByName::name
const std::string & name
Reference name.
Definition: Operators.h:30
dd4hep::ByNameAttr::ByNameAttr
ByNameAttr(const std::string &nam)
Standard constructor.
Definition: Operators.h:53
dd4hep::ByName::ByName
ByName(const ByName &copy)
Copy constructor.
Definition: Operators.h:34
dd4hep::byNameAttr
ByNameAttr< T > byNameAttr(const std::string &nam)
Definition: Operators.h:62
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28
dd4hep::ByName::operator()
bool operator()(const T *entry) const
Operator to select from pointer containers.
Definition: Operators.h:38
dd4hep::detail::tools::copy
void copy(Alignment from, Alignment to)
Copy alignment object from source object.
Definition: AlignmentTools.cpp:43
dd4hep::ByName::ByName
ByName(const std::string &nam)
Standard constructor.
Definition: Operators.h:32