1 #ifndef DataFormats_Common_RefToBase_h
2 #define DataFormats_Common_RefToBase_h
47 #include <type_traits>
59 template<
typename C,
typename T,
typename F>
class Ref;
60 template<
typename C>
class RefProd;
62 template<
typename T>
class View;
72 template <
typename C1,
typename T1,
typename F1>
78 template <
typename T1>
81 RefToBase(std::shared_ptr<reftobase::RefHolderBase>
p);
94 template <
class REF> REF
castTo()
const;
105 std::auto_ptr<reftobase::RefHolderBase>
holder()
const;
131 RefToBase<T>::RefToBase() :
142 template <
typename C1,
typename T1,
typename F1>
145 holder_(new reftobase::Holder<
T,
Ref<C1, T1, F1> >(iRef))
149 template <
typename C>
152 holder_(new reftobase::Holder<
T,
RefProd<
C> >(iRef))
156 template <
typename T1>
159 holder_(new reftobase::IndirectHolder<
T> (
160 std::shared_ptr< edm::reftobase::RefHolderBase>(iRef.holder().
release())
180 holder_(new reftobase::IndirectHolder<
T>(p))
205 return *getPtrImpl();
237 if ( holder_ ==
nullptr )
239 "attempting get key from null RefToBase;\n"
240 "You should check for nullity before calling key().");
241 return holder_->key();
247 template<
typename T,
typename U>
251 "RefToBase::castTo error element types are not related by inheritance"); }
253 template<
typename T,
typename U>
256 "RefToBase::castTo error non-class element types are not the same"); }
259 template<
typename T,
typename OUT>
261 convertTo(
T const*
t) {
return dynamic_cast<OUT
const*
>(
t); }
263 template<
typename T,
typename OUT>
265 convertTo(
T const*
t) {
return t;}
275 "attempting to cast a null RefToBase;\n"
276 "You should check for nullity before casting.");
279 checkTypeCompatibility<T, typename REF::value_type>();
287 return REF(
id(),
key(), getter);
291 if(value ==
nullptr) {
296 return REF(
id(), newValue,
key(), isTransient());
300 "RefToBase<T>::castTo Error attempting to cast mismatched types\n"
301 "casting from RefToBase with T: ",
315 return !id().isValid();
342 ? holder_->isEqualTo(*rhs.
holder_)
351 return !(*
this == rhs);
365 return holder_? holder_->productGetter():
nullptr;
373 return holder_ ? holder_->getPtr() :
nullptr;
378 return holder_? holder_->holder() : std::auto_ptr<reftobase::RefHolderBase>();
value_type const * get() const
edm::Ref< Container > Ref
virtual bool isTransient() const =0
bool isNonnull() const
Checks for non-null.
virtual bool isAvailable() const =0
std::auto_ptr< reftobase::RefHolderBase > holder() const
#define CMS_CLASS_VERSION(_version_)
EDProductGetter const * productGetter(std::atomic< void const * > const &iCache)
void swap(Association< C > &lhs, Association< C > &rhs)
bool operator==(RefToBase const &rhs) const
static void throwThis(Code category, char const *message0="", char const *message1="", char const *message2="", char const *message3="", char const *message4="")
void swap(RefToBase &other)
Container::value_type value_type
reftobase::BaseHolder< value_type > * holder_
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
value_type const * operator->() const
bool operator!=(RefToBase const &rhs) const
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
edm::RefProd< Container > RefProd
bool isNull() const
Checks for null.
value_type const * getPtrImpl() const
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
EDProductGetter const * productGetter() const
bool operator!() const
Checks for null.
value_type const & operator*() const
RefToBase & operator=(RefToBase const &rhs)