CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FWGenericHandle.h
Go to the documentation of this file.
1 #ifndef Fireworks_FWGenericHandle_h
2 #define Fireworks_FWGenericHandle_h
3 // -*- C++ -*-
4 //
5 // Package: Framework
6 // Class : FWGenericHandle
7 //
28 //
29 // Original Author: Chris Jones
30 // Created: Sat Jan 7 15:40:43 EST 2006
31 // $Id: FWGenericHandle.h,v 1.17 2009/11/04 15:27:19 wmtan Exp $
32 //
33 
34 // system include files
35 #include <string>
36 
37 // user include files
38 #include "Reflex/Object.h"
43 
44 // forward declarations
45 namespace edm {
48 {
49 };
50 
51 template<>
53 public:
55  Handle(std::string const& iName) :
56  type_(Reflex::Type::ByName(iName)), prod_(), prov_(0) {
57  if(type_ == Reflex::Type()) {
59  "Handle<FWGenericObject> told to use uknown type '",
60  iName.c_str(),
61  "'.\n Please check spelling or that a module uses this type in the job.");
62  }
63  if(type_.IsTypedef()){
64  //For a 'Reflex::Typedef' the 'toType' method returns the actual type
65  // this is needed since you are now allowed to 'invoke' methods of a 'Typedef'
66  // only for a 'real' class
67  type_ = type_.ToType();
68  }
69  }
70 
72  Handle(Reflex::Type const& iType):
73  type_(iType), prod_(), prov_(0) {
74  if(iType == Reflex::Type()) {
75  Exception::throwThis(errors::NotFound, "Handle<FWGenericObject> given an invalid Reflex::Type");
76  }
77  if(type_.IsTypedef()){
78  //For a 'Reflex::Typedef' the 'toType' method returns the actual type
79  // this is needed since you are now allowed to 'invoke' methods of a 'Typedef'
80  // only for a 'real' class
81  type_ = type_.ToType();
82  }
83  }
84 
86  type_(h.type_),
87  prod_(h.prod_),
88  prov_(h.prov_),
90  { }
91 
92  Handle(Reflex::Object const& prod, Provenance const* prov, ProductID const& pid):
93  type_(prod.TypeOf()),
94  prod_(prod),
95  prov_(prov) {
96  assert(prod_);
97  assert(prov_);
98  // assert(prov_->productID() != ProductID());
99  }
100 
101  //~Handle();
102 
104  {
105  // use unqualified swap for user defined classes
106  using std::swap;
107  swap(type_, other.type_);
108  std::swap(prod_, other.prod_);
109  swap(prov_, other.prov_);
110  swap(whyFailed_, other.whyFailed_);
111  }
112 
113 
115  {
117  this->swap(temp);
118  return *this;
119  }
120 
121  bool isValid() const {
122  return prod_ && 0!= prov_;
123  }
124 
125  bool failedToGet() const {
126  return 0 != whyFailed_.get();
127  }
128  Reflex::Object const* product() const {
129  if(this->failedToGet()) {
130  whyFailed_->raise();
131  }
132  return &prod_;
133  }
134  Reflex::Object const* operator->() const {return this->product();}
135  Reflex::Object const& operator*() const {return *(this->product());}
136 
137  Reflex::Type const& type() const {return type_;}
138  Provenance const* provenance() const {return prov_;}
139 
140  ProductID id() const {return prov_->productID();}
141 
142  void clear() { prov_ = 0; whyFailed_.reset();}
143 
144  void setWhyFailed(boost::shared_ptr<cms::Exception> const& iWhyFailed) {
145  whyFailed_=iWhyFailed;
146  }
147 private:
149  Reflex::Object prod_;
150  Provenance const* prov_;
151  boost::shared_ptr<cms::Exception> whyFailed_;
152 };
153 
155 
157 void convert_handle(BasicHandle const& orig,
159 
160 
162 template <>
163 bool
165 
166 }
167 #endif
void swap(Handle< FWGenericObject > &other)
static void throwThis(Code category, char const *message0="", char const *message1="", char const *message2="", char const *message3="", char const *message4="")
Definition: EDMException.cc:81
bool getByLabel(const InputTag &, Handle< T > &) const
Definition: EventBase.h:86
boost::shared_ptr< cms::Exception > whyFailed_
Definition: HandleBase.h:101
void convert_handle(BasicHandle const &orig, Handle< T > &result)
Definition: ConvertHandle.h:17
Reflex::Type const & type() const
Handle< FWGenericObject > & operator=(Handle< FWGenericObject > const &rhs)
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
Provenance const * provenance() const
tuple result
Definition: query.py:137
Reflex::Object const * operator->() const
This class is just a &#39;tag&#39; used to allow a specialization of edm::Handle.
Handle(std::string const &iName)
Throws exception if iName is not a known C++ class type.
void swap(HandleBase &other)
Definition: HandleBase.h:63
bool failedToGet() const
Definition: HandleBase.h:80
Reflex::Object const & operator*() const
void setWhyFailed(boost::shared_ptr< cms::Exception > const &iWhyFailed)
Handle(Reflex::Type const &iType)
Throws exception if iType is invalid.
T const * product() const
Definition: Handle.h:74
boost::shared_ptr< cms::Exception > whyFailed_
Handle(Handle< FWGenericObject > const &h)
Provenance const * prov_
Definition: HandleBase.h:100
Handle(Reflex::Object const &prod, Provenance const *prov, ProductID const &pid)
Handle< FWGenericObject > FWGenericHandle
ProductID const & productID() const
Definition: Provenance.h:88
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
Reflex::Object const * product() const