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.2 2012/07/06 22:48:52 wmtan Exp $
32 //
33 
34 // system include files
35 #include <string>
36 
37 // user include files
38 #include "Reflex/Object.h"
42 
43 // forward declarations
44 namespace edm {
47 {
48 };
49 
50 template<>
52 public:
54  Handle(std::string const& iName) :
55  type_(Reflex::Type::ByName(iName)), prod_(), prov_(0) {
56  if(type_ == Reflex::Type()) {
58  "Handle<FWGenericObject> told to use uknown type '",
59  iName.c_str(),
60  "'.\n Please check spelling or that a module uses this type in the job.");
61  }
62  if(type_.IsTypedef()){
63  //For a 'Reflex::Typedef' the 'toType' method returns the actual type
64  // this is needed since you are now allowed to 'invoke' methods of a 'Typedef'
65  // only for a 'real' class
66  type_ = type_.ToType();
67  }
68  }
69 
71  Handle(Reflex::Type const& iType):
72  type_(iType), prod_(), prov_(0) {
73  if(iType == Reflex::Type()) {
74  Exception::throwThis(errors::NotFound, "Handle<FWGenericObject> given an invalid Reflex::Type");
75  }
76  if(type_.IsTypedef()){
77  //For a 'Reflex::Typedef' the 'toType' method returns the actual type
78  // this is needed since you are now allowed to 'invoke' methods of a 'Typedef'
79  // only for a 'real' class
80  type_ = type_.ToType();
81  }
82  }
83 
85  type_(h.type_),
86  prod_(h.prod_),
87  prov_(h.prov_),
89  { }
90 
91  Handle(Reflex::Object const& prod, Provenance const* prov, ProductID const& pid):
92  type_(prod.TypeOf()),
93  prod_(prod),
94  prov_(prov) {
95  assert(prod_);
96  assert(prov_);
97  // assert(prov_->productID() != ProductID());
98  }
99 
100  //~Handle();
101 
103  {
104  // use unqualified swap for user defined classes
105  using std::swap;
106  swap(type_, other.type_);
107  std::swap(prod_, other.prod_);
108  swap(prov_, other.prov_);
109  swap(whyFailed_, other.whyFailed_);
110  }
111 
112 
114  {
116  this->swap(temp);
117  return *this;
118  }
119 
120  bool isValid() const {
121  return prod_ && 0!= prov_;
122  }
123 
124  bool failedToGet() const {
125  return 0 != whyFailed_.get();
126  }
127  Reflex::Object const* product() const {
128  if(this->failedToGet()) {
129  whyFailed_->raise();
130  }
131  return &prod_;
132  }
133  Reflex::Object const* operator->() const {return this->product();}
134  Reflex::Object const& operator*() const {return *(this->product());}
135 
136  Reflex::Type const& type() const {return type_;}
137  Provenance const* provenance() const {return prov_;}
138 
139  ProductID id() const {return prov_->productID();}
140 
141  void clear() { prov_ = 0; whyFailed_.reset();}
142 
143  void setWhyFailed(boost::shared_ptr<cms::Exception> const& iWhyFailed) {
144  whyFailed_=iWhyFailed;
145  }
146 private:
148  Reflex::Object prod_;
149  Provenance const* prov_;
150  boost::shared_ptr<cms::Exception> whyFailed_;
151 };
152 
154 
156 void convert_handle(BasicHandle const& orig,
158 
159 
161 template <>
162 bool
164 
165 }
166 #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="")
boost::shared_ptr< cms::Exception > whyFailed_
Definition: HandleBase.h:101
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)
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
Handle(Reflex::Type const &iType)
Throws exception if iType is invalid.
void convert_handle(BasicHandle const &bh, Handle< T > &result)
Definition: ConvertHandle.h:19
T const * product() const
Definition: Handle.h:74
boost::shared_ptr< cms::Exception > whyFailed_
Handle(Handle< FWGenericObject > const &h)
bool getByLabel(InputTag const &, Handle< T > &) const
Definition: EventBase.h:86
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
Reflex::Object const * product() const