Transient.h
Go to the documentation of this file.
1 #ifndef canvas_Persistency_Provenance_Transient_h
2 #define canvas_Persistency_Provenance_Transient_h
3 // vim: set sw=2 expandtab :
4 
5 // ===================================================================
6 // We give all instantiations of this template a 'transient="true"'
7 // attribute for the value_ data member to tell ROOT to never write
8 // it to disk. We also set all instantiations (by hand!) to have a
9 // custom streamer (TransientStreamer) that makes sure if the ROOT
10 // I/O buffer is reused for reading that the data member _value is
11 // reinitialized with a default-constructed T.
12 // ===================================================================
13 
14 namespace art {
15  template <typename T>
16  class Transient {
17  public:
18  typedef T value_type;
20  operator T() const { return value_; }
21  Transient&
23  {
24  value_ = rh;
25  return *this;
26  }
27  T const&
28  get() const noexcept
29  {
30  return value_;
31  }
32  T&
33  get() noexcept
34  {
35  return value_;
36  }
37 
38  private:
40  };
41 }
42 #endif /* canvas_Persistency_Provenance_Transient_h */
43 
44 // Local Variables:
45 // mode: c++
46 // End:
Transient(T value=T())
Definition: Transient.h:19
Transient & operator=(T rh)
Definition: Transient.h:22