DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
DetectorProcessor.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 #ifndef DD4HEP_DETECTORPROCESSOR_H
14 #define DD4HEP_DETECTORPROCESSOR_H
15 
16 // Framework includes
17 #include <DD4hep/DetElement.h>
18 
19 // C/C++ include files
20 #include <memory>
21 
23 namespace dd4hep {
24 
26 
37  public:
39  DetectorProcessor() = default;
45  virtual ~DetectorProcessor();
49  virtual int operator()(DetElement de, int level) const = 0;
51  virtual int process(DetElement de, int level, bool recursive) const;
52  };
53 
55 
64  template <typename T> class DetElementProcessor : virtual public DetectorProcessor {
65  public:
68  public:
70  DetElementProcessor() = delete;
74  DetElementProcessor(T&& p) = delete;
80  virtual ~DetElementProcessor() = default;
84  virtual int operator()(DetElement de, int level) const final
85  { return (processor)(de, level); }
86  };
87 
89  template <typename T> inline
91  { return DetElementProcessor<typename std::remove_reference<T>::type>(std::forward<T>(proc)); }
92 
94 
100  template <typename T> class DetectorProcessorShared : public DetectorProcessor {
101  public:
103  std::shared_ptr<T> processor;
104  public:
108  DetectorProcessorShared(std::shared_ptr<T>& p) : processor(p) {}
112  virtual ~DetectorProcessorShared() = default;
116  virtual int operator()(DetElement de, int level) const final
117  { return (*processor)(de, level); }
118  };
119 
121 
129  template <typename T> class DetElementsCollector {
130  public:
133  public:
137  DetElementsCollector(T&& p) = delete;
147 
152  virtual int operator()(DetElement de, int level) const final;
153  };
154 
156  template <typename T> inline
159 
161 
174  public:
176  DetectorScanner() = default;
181 
183  template <typename Q>
184  DetectorScanner(Q& proc, DetElement start, int level=0, bool recursive=true)
185  { scan(proc, start, level, recursive); }
186 
188  template <typename Q>
189  DetectorScanner(const Q& proc, DetElement start, int level=0, bool recursive=true)
190  { scan(proc, start, level, recursive); }
191 
193  template <typename Q>
194  int scan(Q& p, DetElement start, int level=0, bool recursive=true) const {
195  auto proc = detectorProcessor(p);
196  return proc.process(start, level, recursive);
197  }
198 
200  template <typename Q>
201  int scan(const Q& p, DetElement start, int level=0, bool recursive=true) const {
202  auto proc = detectorProcessor(p);
203  return proc.process(start, level, recursive);
204  }
205  };
206 } /* End namespace dd4hep */
207 #endif // DD4HEP_DETECTORPROCESSOR_H
dd4hep::DetElementsCollector::DetElementsCollector
DetElementsCollector(T &&p)=delete
Default move constructor is disabled.
dd4hep::DetectorScanner::DetectorScanner
DetectorScanner(Q &proc, DetElement start, int level=0, bool recursive=true)
Constructor performing the scan internally.
Definition: DetectorProcessor.h:184
dd4hep::DetectorProcessor::~DetectorProcessor
virtual ~DetectorProcessor()
Default destructor.
Definition: DetectorProcessor.cpp:22
dd4hep::DetectorProcessorShared::DetectorProcessorShared
DetectorProcessorShared(const DetectorProcessorShared &copy)=default
Default copy constructor.
dd4hep::DetectorScanner
Helper to run DetElement scans.
Definition: DetectorProcessor.h:173
dd4hep::DetectorScanner::scan
int scan(const Q &p, DetElement start, int level=0, bool recursive=true) const
Detector element tree scanner using wrapped DetectorProcessor objects.
Definition: DetectorProcessor.h:201
dd4hep::DetectorScanner::DetectorScanner
DetectorScanner(const Q &proc, DetElement start, int level=0, bool recursive=true)
Constructor performing the scan internally.
Definition: DetectorProcessor.h:189
dd4hep::DetectorProcessor::operator=
DetectorProcessor & operator=(const DetectorProcessor &copy)=default
Default assignment.
dd4hep::DetElementProcessor::DetElementProcessor
DetElementProcessor()=delete
Default constructor.
dd4hep::DetectorScanner::DetectorScanner
DetectorScanner(const DetectorScanner &copy)=default
Copy constructor.
dd4hep::DetElementProcessor
Detector scanner using a Processor object.
Definition: DetectorProcessor.h:64
dd4hep::detElementsCollector
DetElementsCollector< typename std::remove_reference< T >::type > detElementsCollector(T &&container)
Creator utility function for DetElementsCollector objects.
Definition: DetectorProcessor.h:157
dd4hep::DetElementProcessor::operator=
DetElementProcessor & operator=(const DetElementProcessor &copy)=default
Default assignment.
dd4hep::DetElementProcessor::operator()
virtual int operator()(DetElement de, int level) const final
Callback to output detector information of an single DetElement.
Definition: DetectorProcessor.h:84
dd4hep::DetElementProcessor::DetElementProcessor
DetElementProcessor(T &p)
Default constructor.
Definition: DetectorProcessor.h:72
dd4hep::DetElementProcessor::~DetElementProcessor
virtual ~DetElementProcessor()=default
Default destructor.
dd4hep::DetElementsCollector::~DetElementsCollector
~DetElementsCollector()=default
Default destructor.
dd4hep::DetElementsCollector::operator=
DetElementsCollector & operator=(const DetElementsCollector &copy)=default
Assignment operator.
dd4hep::DetectorProcessor::DetectorProcessor
DetectorProcessor()=default
Initializing constructor.
dd4hep::DetElement
Handle class describing a detector element.
Definition: DetElement.h:188
dd4hep::DetectorScanner::DetectorScanner
DetectorScanner()=default
Default constructor.
dd4hep::DetectorProcessor::process
virtual int process(DetElement de, int level, bool recursive) const
Callback to output detector information of an entire DetElement.
Definition: DetectorProcessor.cpp:26
dd4hep::DetectorScanner::scan
int scan(Q &p, DetElement start, int level=0, bool recursive=true) const
Detector element tree scanner using wrapped DetectorProcessor objects.
Definition: DetectorProcessor.h:194
dd4hep::DetElementsCollector::DetElementsCollector
DetElementsCollector(T &d)
Default constructor.
Definition: DetectorProcessor.h:135
dd4hep::DetectorProcessorShared::processor
std::shared_ptr< T > processor
Reference to execution object implementing operator()(DetElement de, int level)
Definition: DetectorProcessor.h:103
dd4hep::DetectorProcessor::DetectorProcessor
DetectorProcessor(DetectorProcessor &&copy)=default
R-value copy from a temporary (Since processor is reference)
dd4hep::DetElementsCollector::DetElementsCollector
DetElementsCollector(const DetElementsCollector &copy)=default
Copy constructor.
dd4hep::DetectorProcessor::DetectorProcessor
DetectorProcessor(const DetectorProcessor &copy)=default
Default copy constructor.
dd4hep::DetectorProcessor
Generic Detector processor.
Definition: DetectorProcessor.h:36
dd4hep::DetectorProcessorShared::operator=
DetectorProcessorShared & operator=(const DetectorProcessorShared &copy)=default
Default assignment.
dd4hep::DetElementProcessor::DetElementProcessor
DetElementProcessor(T &&p)=delete
Default move constructor is disabled.
dd4hep::DetElementsCollector::DetElementsCollector
DetElementsCollector(DetElementsCollector &&copy)=default
R-value copy from a temporary.
dd4hep::DetElementsCollector::elements
T & elements
Collection container.
Definition: DetectorProcessor.h:132
dd4hep::DetElementProcessor::processor
T & processor
Reference to execution object implementing operator()(DetElement de, int level)
Definition: DetectorProcessor.h:67
dd4hep::DetectorProcessorShared::operator()
virtual int operator()(DetElement de, int level) const final
Callback to output detector information of an single DetElement.
Definition: DetectorProcessor.h:116
dd4hep::DetElementProcessor::DetElementProcessor
DetElementProcessor(const DetElementProcessor &copy)=default
Default copy constructor.
DetElement.h
dd4hep::DetElementProcessor::DetElementProcessor
DetElementProcessor(DetElementProcessor &&copy)=default
R-value copy from a temporary (Since processor is reference)
dd4hep::DetectorProcessor::operator()
virtual int operator()(DetElement de, int level) const =0
Callback to output detector information of an single DetElement.
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28
dd4hep::DetElementsCollector
Generic detector element collector of a sub-tree.
Definition: DetectorProcessor.h:129
dd4hep::DetectorScanner::operator=
DetectorScanner & operator=(const DetectorScanner &copy)=default
Assignment operator.
dd4hep::DetectorProcessorShared::DetectorProcessorShared
DetectorProcessorShared()=delete
Default constructor.
dd4hep::DetElementsCollector::operator()
virtual int operator()(DetElement de, int level) const final
Callback to output elements information.
Definition: DetectorProcessor.cpp:41
dd4hep::DetectorProcessorShared
Wrapper to call objects in the form of a detector element processor.
Definition: DetectorProcessor.h:100
dd4hep::detail::tools::copy
void copy(Alignment from, Alignment to)
Copy alignment object from source object.
Definition: AlignmentTools.cpp:43
dd4hep::DetectorProcessorShared::DetectorProcessorShared
DetectorProcessorShared(std::shared_ptr< T > &p)
Default constructor.
Definition: DetectorProcessor.h:108
dd4hep::detectorProcessor
DetElementProcessor< typename std::remove_reference< T >::type > detectorProcessor(T &&proc)
Instantiation helper.
Definition: DetectorProcessor.h:90
dd4hep::DetectorProcessorShared::~DetectorProcessorShared
virtual ~DetectorProcessorShared()=default
Default destructor.