diff --git a/DataFormats/Common/interface/Ptr.h b/DataFormats/Common/interface/Ptr.h index 613bf0be4d5b4..09b819220b229 100644 --- a/DataFormats/Common/interface/Ptr.h +++ b/DataFormats/Common/interface/Ptr.h @@ -149,6 +149,8 @@ namespace edm { /// Checks if collection is in memory or available /// in the event. No type checking is done. + /// This function is potentially costly as it might cause a disk + /// read (note that it does not cause the data to be cached locally) bool isAvailable() const; /// Checks if this Ptr is transient (i.e. not persistable). diff --git a/DataFormats/Common/interface/Ref.h b/DataFormats/Common/interface/Ref.h index c5fbfcc4a10eb..396fcea17a66b 100644 --- a/DataFormats/Common/interface/Ref.h +++ b/DataFormats/Common/interface/Ref.h @@ -257,6 +257,8 @@ namespace edm { /// Checks if collection is in memory or available /// in the Event. No type checking is done. + /// This function is potentially costly as it might cause a disk + /// read (note that it does not cause the data to be cached locally) bool isAvailable() const; /// Checks if this ref is transient (i.e. not persistable). @@ -404,6 +406,8 @@ namespace edm { /// Checks if collection is in memory or available /// in the Event. No type checking is done. + /// This function is potentially costly as it might cause a disk + /// read (note that it does not cause the data to be cached locally) bool isAvailable() const; /// Checks if this ref is transient (i.e. not persistable). diff --git a/DataFormats/Common/interface/RefCoreWithIndex.h b/DataFormats/Common/interface/RefCoreWithIndex.h index 9098d28db108b..595cfeaba011d 100644 --- a/DataFormats/Common/interface/RefCoreWithIndex.h +++ b/DataFormats/Common/interface/RefCoreWithIndex.h @@ -88,7 +88,8 @@ namespace edm { // Checks if collection is in memory or available // in the Event. No type checking is done. - + // This function is potentially costly as it might cause a disk + // read (note that it does not cause the data to be cached locally) bool isAvailable() const { return toRefCore().isAvailable(); } //Convert to an equivalent RefCore. Needed for Ref specialization. diff --git a/DataFormats/Common/interface/RefProd.h b/DataFormats/Common/interface/RefProd.h index b5f40fd293bcf..c17a5f2d821ee 100644 --- a/DataFormats/Common/interface/RefProd.h +++ b/DataFormats/Common/interface/RefProd.h @@ -134,6 +134,8 @@ namespace edm { /// Checks if collection is in memory or available /// in the Event. No type checking is done. + /// This function is potentially costly as it might cause a disk + /// read (note that it does not cause the data to be cached locally) bool isAvailable() const { return product_.isAvailable(); } /// Checks if this RefProd is transient (i.e. not persistable). diff --git a/DataFormats/Common/interface/RefToBase.h b/DataFormats/Common/interface/RefToBase.h index d46226f0de93c..d12434a65b4a7 100644 --- a/DataFormats/Common/interface/RefToBase.h +++ b/DataFormats/Common/interface/RefToBase.h @@ -116,6 +116,8 @@ namespace edm { /// Checks if collection is in memory or available /// in the Event. No type checking is done. + /// This function is potentially costly as it might cause a disk + /// read (note that it does not cause the data to be cached locally) bool isAvailable() const { return holder_ ? holder_->isAvailable() : false; } bool isTransient() const { return holder_ ? holder_->isTransient() : false; } diff --git a/DataFormats/Common/interface/RefToBaseProd.h b/DataFormats/Common/interface/RefToBaseProd.h index bbac746d107fa..b046ea271419f 100644 --- a/DataFormats/Common/interface/RefToBaseProd.h +++ b/DataFormats/Common/interface/RefToBaseProd.h @@ -66,6 +66,12 @@ namespace edm { /// Checks for non-null bool isNonnull() const { return product_.isNonnull(); } + /// Checks if collection is in memory or available + /// in the Event. No type checking is done. + /// This function is potentially costly as it might cause a disk + /// read (note that it does not cause the data to be cached locally) + bool isAvailable() const { return product_.isAvailable(); } + /// Checks for null bool operator!() const { return isNull(); } diff --git a/DataFormats/Common/test/reftobaseprod_t.cppunit.cc b/DataFormats/Common/test/reftobaseprod_t.cppunit.cc index 02ab42145d08b..45564b64125f5 100644 --- a/DataFormats/Common/test/reftobaseprod_t.cppunit.cc +++ b/DataFormats/Common/test/reftobaseprod_t.cppunit.cc @@ -93,11 +93,13 @@ void testRefToBaseProd::constructTest() { CPPUNIT_ASSERT(!nulled); CPPUNIT_ASSERT(nulled.isNull()); CPPUNIT_ASSERT(!nulled.isNonnull()); + CPPUNIT_ASSERT(!nulled.isAvailable()); RefToBaseProd nulledP; CPPUNIT_ASSERT(!nulledP); CPPUNIT_ASSERT(nulledP.isNull()); CPPUNIT_ASSERT(!nulledP.isNonnull()); + CPPUNIT_ASSERT(!nulledP.isAvailable()); ProductID const pid(1, 1); @@ -110,6 +112,9 @@ void testRefToBaseProd::constructTest() { OrphanHandle handle(&dummyContainer, pid); RefToBaseProd dummyPtr(handle); + CPPUNIT_ASSERT(!dummyPtr.isNull()); + CPPUNIT_ASSERT(dummyPtr.isNonnull()); + CPPUNIT_ASSERT(dummyPtr.isAvailable()); CPPUNIT_ASSERT(dummyPtr.id() == pid); compareTo(dummyPtr, dummyContainer); } @@ -218,9 +223,15 @@ void testRefToBaseProd::getTest() { RefCore core(pid, nullptr, &tester, false); RefToBaseProd& prod = reinterpret_cast&>(core); + CPPUNIT_ASSERT(!prod.isNull()); + CPPUNIT_ASSERT(prod.isNonnull()); + CPPUNIT_ASSERT(prod.isAvailable()); //previously making a copy before reading back would cause seg fault RefToBaseProd prodCopy(prod); + CPPUNIT_ASSERT(!prodCopy.isNull()); + CPPUNIT_ASSERT(prodCopy.isNonnull()); + CPPUNIT_ASSERT(prodCopy.isAvailable()); CPPUNIT_ASSERT(!prod.hasCache());