Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[13_1_X] Add isAvailable() function to RefToBaseProd #41931

Merged
merged 2 commits into from
Jun 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions DataFormats/Common/interface/Ptr.h
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
4 changes: 4 additions & 0 deletions DataFormats/Common/interface/Ref.h
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down Expand Up @@ -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).
Expand Down
3 changes: 2 additions & 1 deletion DataFormats/Common/interface/RefCoreWithIndex.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions DataFormats/Common/interface/RefProd.h
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
2 changes: 2 additions & 0 deletions DataFormats/Common/interface/RefToBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
6 changes: 6 additions & 0 deletions DataFormats/Common/interface/RefToBaseProd.h
Original file line number Diff line number Diff line change
Expand Up @@ -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(); }

Expand Down
11 changes: 11 additions & 0 deletions DataFormats/Common/test/reftobaseprod_t.cppunit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,13 @@ void testRefToBaseProd::constructTest() {
CPPUNIT_ASSERT(!nulled);
CPPUNIT_ASSERT(nulled.isNull());
CPPUNIT_ASSERT(!nulled.isNonnull());
CPPUNIT_ASSERT(!nulled.isAvailable());

RefToBaseProd<Dummy> nulledP;
CPPUNIT_ASSERT(!nulledP);
CPPUNIT_ASSERT(nulledP.isNull());
CPPUNIT_ASSERT(!nulledP.isNonnull());
CPPUNIT_ASSERT(!nulledP.isAvailable());

ProductID const pid(1, 1);

Expand All @@ -110,6 +112,9 @@ void testRefToBaseProd::constructTest() {
OrphanHandle<DummyCollection> handle(&dummyContainer, pid);
RefToBaseProd<Dummy> dummyPtr(handle);

CPPUNIT_ASSERT(!dummyPtr.isNull());
CPPUNIT_ASSERT(dummyPtr.isNonnull());
CPPUNIT_ASSERT(dummyPtr.isAvailable());
CPPUNIT_ASSERT(dummyPtr.id() == pid);
compareTo(dummyPtr, dummyContainer);
}
Expand Down Expand Up @@ -218,9 +223,15 @@ void testRefToBaseProd::getTest() {

RefCore core(pid, nullptr, &tester, false);
RefToBaseProd<IntValue>& prod = reinterpret_cast<RefToBaseProd<IntValue>&>(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<IntValue> prodCopy(prod);
CPPUNIT_ASSERT(!prodCopy.isNull());
CPPUNIT_ASSERT(prodCopy.isNonnull());
CPPUNIT_ASSERT(prodCopy.isAvailable());

CPPUNIT_ASSERT(!prod.hasCache());

Expand Down