1 #ifndef DataFormats_Common_RefToBase_h
2 #define DataFormats_Common_RefToBase_h
48 #include <type_traits>
61 template<
typename C,
typename T,
typename F>
class Ref;
62 template<
typename C>
class RefProd;
64 template<
typename T>
class View;
74 template <
typename C1,
typename T1,
typename F1>
81 template <
typename T1>
85 RefToBase(std::shared_ptr<reftobase::RefHolderBase>
p);
98 template <
class REF> REF
castTo()
const;
109 std::auto_ptr<reftobase::RefHolderBase>
holder()
const;
135 RefToBase<T>::RefToBase() :
146 template <
typename C1,
typename T1,
typename F1>
149 holder_(new reftobase::Holder<
T,
Ref<C1, T1, F1> >(iRef))
153 template <
typename C>
156 holder_(new reftobase::Holder<
T,
RefProd<
C> >(iRef))
161 template <
typename T1>
164 holder_(new reftobase::IndirectHolder<
T> (
165 std::shared_ptr< edm::reftobase::RefHolderBase>(iRef.holder().
release())
186 holder_(new reftobase::IndirectHolder<
T>(p))
211 return *getPtrImpl();
245 "attempting get key from null RefToBase;\n"
246 "You should check for nullity before calling key().");
247 return holder_->key();
254 template<
typename T,
typename U>
258 "RefToBase::castTo error element types are not related by inheritance"); }
260 template<
typename T,
typename U>
263 "RefToBase::castTo error non-class element types are not the same"); }
266 template<
typename T,
typename OUT>
268 convertTo(
T const*
t) {
return dynamic_cast<OUT
const*
>(
t); }
270 template<
typename T,
typename OUT>
272 convertTo(
T const*
t) {
return t;}
282 "attempting to cast a null RefToBase;\n"
283 "You should check for nullity before casting.");
286 checkTypeCompatibility<T, typename REF::value_type>();
294 return REF(
id(),
key(), getter);
298 if(value ==
nullptr) {
303 return REF(
id(), newValue,
key(), isTransient());
307 "RefToBase<T>::castTo Error attempting to cast mismatched types\n"
308 "casting from RefToBase with T: ",
323 return !id().isValid();
350 ? holder_->isEqualTo(*rhs.
holder_)
359 return !(*
this == rhs);
373 return holder_? holder_->productGetter():
nullptr;
381 return holder_ ? holder_->getPtr() : 0;
386 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)
reftobase::BaseHolder< value_type > * holder_
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
value_type const * operator->() const
bool operator!=(RefToBase const &rhs) const
Container::value_type value_type
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)