Commit 9465072d authored by Simon Spannagel's avatar Simon Spannagel
Browse files

Move reset of kMustCleanup from destructor to the clear() function of the Clipoard

This allows to sue the objects differently outside the framework without affecting
their cleanup procedure.
parent dd5bbbf0
Pipeline #1080926 passed with stages
in 16 minutes and 19 seconds
......@@ -50,6 +50,11 @@ void Clipboard::clear() {
std::shared_ptr<ObjectVector> collection = std::static_pointer_cast<ObjectVector>(set->second);
// Loop over all objects and delete them
for(ObjectVector::iterator it = collection->begin(); it != collection->end(); ++it) {
// All objects are destroyed together in this clear function at the end of the event. To avoid costly
// reverse-iterations through the TRef dependency hash lists, we just tell ROOT not to care about possible
// TRef-dependants and to just destroy the object directly by resetting the `kMustCleanup` bit.
(*it)->ResetBit(kMustCleanup);
// Delete the object itself:
delete(*it);
}
set = collections.erase(set);
......
......@@ -7,12 +7,7 @@ Object::Object(std::string detectorID) : m_detectorID(std::move(detectorID)) {}
Object::Object(double timestamp) : m_timestamp(timestamp) {}
Object::Object(std::string detectorID, double timestamp) : m_detectorID(std::move(detectorID)), m_timestamp(timestamp) {}
Object::Object(const Object&) = default;
Object::~Object() {
// In Corryvreckan, all objects are destroyed together, i.e. at the end of the event. To avoid costly reverse-iterations
// through the TRef dependency hash lists, we just tell ROOT not to care about possible TRef-dependants and to just
// destroy the object directly by resetting the `kMustCleanup` bit.
this->ResetBit(kMustCleanup);
}
Object::~Object() = default;
std::ostream& corryvreckan::operator<<(std::ostream& out, const Object& obj) {
obj.print(out);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment