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;
75 template <typename C1, typename T1, typename F1>
84 RefToBase(std::shared_ptr<reftobase::RefHolderBase>
p);
91 value_type const*
operator->() const;
92 value_type const*
get() const;
108 std::auto_ptr<reftobase::RefHolderBase>
holder() const;
134 RefToBase<T>::RefToBase() :
147 holder_(other.holder_) { other.holder_=
nullptr;}
152 delete holder_; holder_=other.holder_; other.holder_=
nullptr;
return *
this;
157 template <
typename C1,
typename T1,
typename F1>
160 holder_(new reftobase::Holder<
T,
Ref<C1, T1, F1> >(iRef))
164 template <
typename C>
167 holder_(new reftobase::Holder<
T,
RefProd<
C> >(iRef))
171 template <
typename T1>
174 holder_(new reftobase::IndirectHolder<
T> (
175 std::shared_ptr< edm::reftobase::RefHolderBase>(iRef.holder().
release())
195 holder_(new reftobase::IndirectHolder<
T>(p))
220 return *getPtrImpl();
252 if ( holder_ ==
nullptr )
254 "attempting get key from null RefToBase;\n"
255 "You should check for nullity before calling key().");
256 return holder_->key();
262 template<
typename T,
typename U>
266 "RefToBase::castTo error element types are not related by inheritance"); }
268 template<
typename T,
typename U>
271 "RefToBase::castTo error non-class element types are not the same"); }
274 template<
typename T,
typename OUT>
276 convertTo(
T const*
t) {
return dynamic_cast<OUT
const*
>(
t); }
278 template<
typename T,
typename OUT>
280 convertTo(
T const*
t) {
return t;}
290 "attempting to cast a null RefToBase;\n"
291 "You should check for nullity before casting.");
294 checkTypeCompatibility<T, typename REF::value_type>();
302 return REF(
id(),
key(), getter);
306 if(value ==
nullptr) {
311 return REF(
id(), newValue,
key(), isTransient());
315 "RefToBase<T>::castTo Error attempting to cast mismatched types\n"
316 "casting from RefToBase with T: ",
330 return !id().isValid();
357 ? holder_->isEqualTo(*rhs.
holder_)
366 return !(*
this == rhs);
380 return holder_? holder_->productGetter():
nullptr;
388 return holder_ ? holder_->getPtr() :
nullptr;
393 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.
RefToBase & operator=(RefToBase &&other)
value_type const & operator*() const