Belle II Software development
SelectSubset.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8#include <framework/datastore/SelectSubset.h>
9
10#include <framework/datastore/RelationArray.h>
11
12using namespace Belle2;
13
15{
17 StoreAccessorBase* subset = getSubSet();
18
19 //replace set with subset
20 DataStore::Instance().replaceData(*subset, *set);
21
22 //swap relations
23 for (const std::string& fromArray : m_inheritFromArrays) {
24 RelationArray setRel(DataStore::relationName(fromArray, set->getName()));
25 RelationArray subsetRel(DataStore::relationName(fromArray, subset->getName()));
26 DataStore::Instance().replaceData(subsetRel, setRel);
27 }
28 for (const std::string& toArray : m_inheritToArrays) {
29 RelationArray setRel(DataStore::relationName(set->getName(), toArray));
30 RelationArray subsetRel(DataStore::relationName(subset->getName(), toArray));
31 DataStore::Instance().replaceData(subsetRel, setRel);
32 }
33}
static DataStore & Instance()
Instance of singleton Store.
Definition: DataStore.cc:54
static std::string relationName(const std::string &fromName, const std::string &toName, std::string const &namedRelation="")
Return storage name for a relation between two arrays of the given names.
Definition: DataStore.h:180
void replaceData(const StoreAccessorBase &from, const StoreAccessorBase &to)
For two StoreAccessors of same type, move all data in 'from' into 'to', discarding previous contents ...
Definition: DataStore.cc:343
Low-level class to create/modify relations between StoreArrays.
Definition: RelationArray.h:62
std::vector< std::string > m_inheritFromArrays
array names we inherit relations from.
Definition: SelectSubset.h:54
virtual StoreAccessorBase * getSubSet()=0
Get accessor for reduced set.
void swapSetsAndDestroyOriginal()
Swap set and subset (+relations), and keep only the reduced set.
Definition: SelectSubset.cc:14
virtual StoreAccessorBase * getSet()=0
Get accessor for original set.
std::vector< std::string > m_inheritToArrays
array names we inherit relations to.
Definition: SelectSubset.h:56
Base class for StoreObjPtr and StoreArray for easier common treatment.
const std::string & getName() const
Return name under which the object is saved in the DataStore.
Abstract base class for different kinds of events.