CMS 3D CMS Logo

ExtensionCord.h
Go to the documentation of this file.
1 #ifndef Utilities_ExtensionCord_h
2 #define Utilities_ExtensionCord_h
3 // -*- C++ -*-
4 //
5 // Package: Utilities
6 // Class : ExtensionCord
7 //
16 //
17 // Original Author: Chris Jones
18 // Created: Fri Sep 22 12:38:58 EDT 2006
19 //
20 
21 // system include files
22 #include <memory>
23 
24 // user include files
27 
28 // forward declarations
29 
30 namespace edm {
31  template <class T>
32  class OutletBase;
33 
34  template <class T>
35  class ExtensionCord {
36  //only something that inherits from OutletBase<T> will
37  // be allowed to call 'setGetter'
38  friend class OutletBase<T>;
39 
40  public:
41  struct Holder {
43  };
44 
46  //virtual ~ExtensionCord();
47 
48  // ---------- const member functions ---------------------
49  const T* operator->() const { return this->get(); }
50 
51  const T* get() const {
52  if (!this->connected()) {
53  throw cms::Exception("InvalidExtensionCord") << "an edm::ExtensionCord for type " << typeid(T).name()
54  << " was not connected to an outlet. This is a programming error.";
55  }
56  return holder_->getter_->get();
57  }
58 
59  const T& operator*() const { return *(this->get()); }
60 
62  bool connected() const { return 0 != holder_->getter_; }
63  // ---------- static member functions --------------------
64 
65  // ---------- member functions ---------------------------
66 
67  private:
68  //ExtensionCord(const ExtensionCord&); // allow default
69 
70  //const ExtensionCord& operator=(const ExtensionCord&); // allow default
71 
72  void setGetter(extensioncord::ECGetterBase<T>* iGetter) { holder_->getter_ = iGetter; }
73  // ---------- member data --------------------------------
74  std::shared_ptr<Holder> holder_;
75  };
76 } // namespace edm
77 
78 #endif
const T * operator->() const
Definition: ExtensionCord.h:49
std::shared_ptr< Holder > holder_
Definition: ExtensionCord.h:74
void setGetter(extensioncord::ECGetterBase< T > *iGetter)
Definition: ExtensionCord.h:72
const T & operator*() const
Definition: ExtensionCord.h:59
HLT enums.
bool connected() const
Returns true if the ExtensionCord is connected to an outlet and can therefore deliver data...
Definition: ExtensionCord.h:62
extensioncord::ECGetterBase< T > * getter_
Definition: ExtensionCord.h:42
long double T