LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
CPCSentry.h
Go to the documentation of this file.
1 #ifndef art_Framework_Core_CPCSentry_h
2 #define art_Framework_Core_CPCSentry_h
3 
4 #include "cetlib/exempt_ptr.h"
5 
6 // ======================================================================
7 //
8 // class CPCSentry uses RAII to make sure that the
9 // CurrentProcessingContext pointer it is guarding is set to the right
10 // value, and cleared at the right time.
11 //
12 // ======================================================================
13 
14 namespace art {
15 
16  class CurrentProcessingContext;
17 
18  namespace detail {
19 
20  class CPCSentry {
21  public:
22  CPCSentry(cet::exempt_ptr<CurrentProcessingContext const>& c,
23  cet::exempt_ptr<CurrentProcessingContext const> value)
24  : referenced_{&c}
25  {
26  c = value;
27  }
28 
29  ~CPCSentry() noexcept { *referenced_ = nullptr; }
30 
31  private:
32  cet::exempt_ptr<CurrentProcessingContext const>* referenced_;
33  }; // CPCSentry
34 
35  } // detail
36 } // art
37 
38  // ======================================================================
39 
40 #endif /* art_Framework_Core_CPCSentry_h */
41 
42 // Local Variables:
43 // mode: c++
44 // End:
CPCSentry(cet::exempt_ptr< CurrentProcessingContext const > &c, cet::exempt_ptr< CurrentProcessingContext const > value)
Definition: CPCSentry.h:22
std::string value(boost::any const &)
cet::exempt_ptr< CurrentProcessingContext const > * referenced_
Definition: CPCSentry.h:32
~CPCSentry() noexcept
Definition: CPCSentry.h:29
HLT enums.