8 #include <framework/datastore/SelectSubset.h>
9 #include <framework/datastore/StoreArray.h>
10 #include <framework/datastore/RelationsObject.h>
11 #include <framework/datastore/RelationArray.h>
14 #include <gtest/gtest.h>
21 #include <unordered_map>
30 class SelectSubsetTest :
public ::testing::Test {
34 using KeyElementType = UInt_t;
38 static bool SelectionCriterium(
const KeyElementType a)
42 return (a % 2) != 0 && (a % 3) != 0 && (a % 5) != 0 && (a % 7) != 0 &&
43 (a % 11) != 0 && (a % 13) != 0 && (a % 17) != 0 && (a % 19) != 0 && (a % 23) != 0 &&
44 (a % 29) != 0 && (a % 31) != 0 ;
47 static bool SelectionCriteriumOnElement(
const StoredElement* a)
49 return SelectionCriterium(a->GetUniqueID());
55 using FromTargetElementsToWeight = map< KeyElementType , double >;
68 using FromStringToArrows = unordered_map< string, FromTargetElementsToWeight >;
71 KeyElementType m_fromElement;
72 FromStringToArrows m_allRelations;
77 explicit Relations(
const KeyElementType& from):
82 const FromStringToArrows&
83 getConstSetOfAllRelations()
const
85 return m_allRelations;
88 FromStringToArrows::const_iterator
89 getConstSetOfToRelations(
const string& toSetName)
const
91 return m_allRelations.find(toSetName) ;
95 FromStringToArrows::iterator
96 getSetOfToRelations(
const string& toSetName)
98 return m_allRelations.find(toSetName) ;
101 FromStringToArrows::const_iterator
102 getSetOfToRelations(
const string& toSetName)
const
104 return m_allRelations.find(toSetName) ;
111 cout <<
"From KeyElement " << m_fromElement <<
"to:" << endl;
112 for (
const auto& toSet : m_allRelations) {
113 for (
auto pair : toSet.second)
115 << toSet.first <<
" "
117 <<
" ( " << pair.second <<
" ) " << endl;
119 cout <<
"-----------------------------------------------------------------" << endl;
124 isPresentRelationTo(
const string& toSetName, KeyElementType to)
const
126 auto toRelations = getConstSetOfToRelations(toSetName);
127 if (toRelations == m_allRelations.end())
129 return toRelations->second.find(to) != toRelations->second.end();
133 appendNewRelationTo(
const string& toName, KeyElementType to,
136 auto toRelations = getSetOfToRelations(toName);
137 if (toRelations == m_allRelations.end()) {
139 m_allRelations.insert(pair <string, FromTargetElementsToWeight>
141 FromTargetElementsToWeight({ {to, weight} })));
144 pair< KeyElementType, double > relation(to, weight);
145 toRelations->second.insert(relation);
149 const FromTargetElementsToWeight&
150 getAllRelations(
const string& toOtherSetName)
const
152 static FromTargetElementsToWeight nothing;
153 auto toRelations = getSetOfToRelations(toOtherSetName);
154 if (toRelations == m_allRelations.end()) {
157 return toRelations->second;
163 #if defined(__INTEL_COMPILER)
164 #pragma warning disable 177
177 map< KeyElementType, Relations > m_set;
188 cout <<
"The NamedSet: " << m_name <<
" contains:" << endl ;
189 for (
auto set : m_set) {
190 cout << set.first << endl;
193 cout <<
"~~~~~~~~~~~~~~~~~~~~~~~" << endl;
197 explicit NamedSet(
const string& name =
"") :
198 m_name(name), m_storeArray(name) {}
201 bool operator()(
const NamedSet& a,
const NamedSet& b)
const
203 return a.getName() < b.getName();
207 [[nodiscard]]
const string getName()
const
218 void initializeDatastore()
222 DataStore::Instance().setInitializeActive(
true);
225 array.registerInDataStore();
226 array.registerRelationTo(array);
228 DataStore::Instance().setInitializeActive(
false);
231 void initializeDatastore(
const string& SetName)
237 DataStore::Instance().setInitializeActive(
true);
241 array.registerInDataStore();
242 array.registerRelationTo(otherSet);
243 otherSet.registerRelationTo(array);
246 DataStore::Instance().setInitializeActive(
false);
262 void appendNewElement(KeyElementType element)
264 m_set.insert(pair< KeyElementType, Relations > (element, Relations(element)));
267 void appendNewRelationTo(KeyElementType fromKey,
const string& toName, KeyElementType toKey,
270 auto fromElement = m_set.find(fromKey);
271 if (fromElement == m_set.end()) {
272 cout <<
"??" << endl;
275 fromElement->second.appendNewRelationTo(toName, toKey, weight);
278 [[nodiscard]]
bool isPresentRelationFromTo(
const KeyElementType& fromKey,
const string& otherSetName ,
279 const KeyElementType& toKey)
const
281 auto fromElement = m_set.find(fromKey);
282 if (fromElement != m_set.end()) {
283 return fromElement->second.isPresentRelationTo(otherSetName, toKey);
286 if (i ++ < 999 || (i % 100) == 0) {
287 cout <<
"Error: from: " <<
getName() <<
" id " << fromKey <<
288 " -> " << otherSetName <<
" id " << toKey << endl;
289 for (
const auto& element : m_set)
290 cout << element.first <<
"\t";
292 for (
const auto& element : m_storeArray)
293 cout << element.GetUniqueID() <<
"\t";
295 }
else if (i == 1000) {
296 cout <<
"Skipping 99% of the following errors" << endl;
302 [[nodiscard]]
const FromTargetElementsToWeight& getAllRelations(
const KeyElementType& fromKey,
const string& toOtherSetName)
const
304 auto fromElement = m_set.find(fromKey);
305 return fromElement->second.getAllRelations(toOtherSetName);
308 using StlRelationArray = map< KeyElementType , FromTargetElementsToWeight >;
310 [[nodiscard]] StlRelationArray getRestrictedDomainRelationTo(
const string& toOtherSetName)
const
312 StlRelationArray theInducedRelation;
313 for (
const auto& element : m_set) {
314 if (SelectionCriterium(element.first) &&
315 element.second.getAllRelations(toOtherSetName).size() != 0)
316 theInducedRelation.insert(pair< KeyElementType, FromTargetElementsToWeight>
317 (element.first, element.second.getAllRelations(toOtherSetName)));
319 return theInducedRelation;
322 [[nodiscard]] StlRelationArray getRestrictedCodomainRelationTo(
const string& setName)
const
324 StlRelationArray theInducedRelation;
325 for (
const auto& element : m_set) {
326 if (element.second.getConstSetOfToRelations(setName) ==
327 element.second.getConstSetOfAllRelations().end())
329 for (
auto image : element.second.getConstSetOfToRelations(setName)->second) {
330 if (SelectionCriterium(image.first)) {
331 if (theInducedRelation.find(element.first) == theInducedRelation.end())
332 theInducedRelation.insert(pair< KeyElementType, FromTargetElementsToWeight>
333 (element.first, FromTargetElementsToWeight()));
334 theInducedRelation.find(element.first)->second.
335 insert(FromTargetElementsToWeight::value_type
336 (image.first, image.second));
340 return theInducedRelation;
343 [[nodiscard]] StlRelationArray getRestrictedSelfRelation()
const
345 StlRelationArray theInducedRelation;
346 for (
const auto& element : m_set) {
347 if (! SelectionCriterium(element.first) ||
348 element.second.getAllRelations(m_name).size() == 0)
350 for (
auto image : element.second.getConstSetOfToRelations(m_name)->second) {
351 if (SelectionCriterium(image.first)) {
352 if (theInducedRelation.find(element.first) == theInducedRelation.end())
353 theInducedRelation.insert(pair< KeyElementType, FromTargetElementsToWeight>
354 (element.first, FromTargetElementsToWeight()));
355 theInducedRelation.find(element.first)->second.
356 insert(FromTargetElementsToWeight::value_type
357 (image.first, image.second));
361 return theInducedRelation;
366 class CollectionOfSets {
376 vector< string > m_otherSetsNames;
377 unordered_map< string, NamedSet > m_otherSets;
381 CollectionOfSets(): m_set(
"theSet"),
382 m_subset(
"theSubset"),
383 m_otherSetsNames {string(
"G"), string(
"F"), string(
"E"),
384 string(
"D"), string(
"C"), string(
"B"), string(
"A")
387 m_setName = m_set.getName();
388 m_subsetName = m_subset.getName();
389 for (
const auto& aSetName : m_otherSetsNames)
390 m_otherSets.insert(pair<string, NamedSet> (aSetName, NamedSet(aSetName)));
403 return m_set.storedArray();
414 getSubsetName()
const
416 return m_subsetName ;
422 return m_subset.storedArray();
428 return m_otherSets.size() ;
431 const vector< string >&
432 getOtherSetsNames()
const
434 return m_otherSetsNames ;
438 getOtherSetsNames(
int i)
const
440 return m_otherSetsNames[i] ;
446 auto otherSet = m_otherSets.find(m_otherSetsNames[ i ]);
447 if (otherSet != m_otherSets.end())
448 return otherSet->second.storedArray();
450 cout <<
" ???????????? " << i << endl;
451 throw std::runtime_error(
"invalid set access");
454 pair< const string, NamedSet>&
455 getOtherNamedSet(
int i)
457 return * m_otherSets.find(m_otherSetsNames[ i ]);
460 unordered_map< string, NamedSet >&
467 initializeDatastore()
471 m_set.initializeDatastore();
473 for (
auto namedSet : m_otherSets)
474 namedSet.second.initializeDatastore(getSetName());
481 unsigned int nElements = 1368;
482 for (
unsigned int i = 0; i < nElements ; i++)
483 appendNewElement(m_set);
487 for (
auto& set : m_otherSets) {
488 unsigned int nOtherElements = nElements - n * 100;
490 for (
unsigned int i = 0; i < nOtherElements ; i++)
491 appendNewElement(set.second);
496 for (
auto& set : m_otherSets) {
499 unsigned int nArrows = nElements * j;
502 for (
unsigned int arrow = 0; arrow < nArrows ; arrow ++) {
503 appendNewRelationToOther(set);
504 appendNewRelationFromOther(set);
510 for (
unsigned int arrow = 0; arrow < 5 * nElements; arrow ++)
511 appendNewSelfRelation();
523 static double counter(0.0);
524 return counter += 1.;
528 flat_random(
unsigned int max)
534 static unsigned int next = 11036;
539 result = (
unsigned int)(next / 65536) % 2048;
544 result ^= (
unsigned int)(next / 65536) % 1024;
549 result ^= (
unsigned int)(next / 65536) % 1024;
556 appendNewElement(NamedSet& namedSet)
560 static int uniqueId(0);
562 namedSet.appendNewElement(uniqueId);
564 set[ i ]->SetUniqueID(uniqueId);
570 appendNewRelationToOther(pair< const string, NamedSet>& set)
573 int from_index = flat_random(getSet().getEntries());
574 KeyElementType from_key = getSet()[from_index]->GetUniqueID();
575 int to_index = flat_random(set.second.storedArray().getEntries());
576 KeyElementType to_key = set.second.storedArray()[to_index]->GetUniqueID();
579 if (getNamedSet().isPresentRelationFromTo(from_key, set.first , to_key))
583 double weight = getWeight();
585 getNamedSet().appendNewRelationTo(from_key, set.first, to_key , weight);
587 RelationArray setToOtherSet(getSet(), set.second.storedArray());
588 setToOtherSet.add(from_index, to_index, weight);
594 appendNewRelationFromOther(pair< const string, NamedSet>& otherSet)
598 unsigned int from_index = flat_random(otherSet.second.storedArray().getEntries());
600 KeyElementType from_key = otherSet.second.storedArray()[from_index]->GetUniqueID();
602 unsigned int to_index = flat_random(getSet().getEntries());
603 KeyElementType to_key = getSet()[to_index]->GetUniqueID();
605 if (otherSet.second.isPresentRelationFromTo(from_key, getSetName(), to_key))
609 double weight = getWeight();
611 otherSet.second.appendNewRelationTo(from_key, getSetName(), to_key , weight);
615 RelationArray otherSetToSet(otherSet.second.storedArray(), getSet());
616 otherSetToSet.add(from_index, to_index, weight);
621 appendNewSelfRelation()
623 unsigned int from_index = flat_random(getSet().getEntries());
624 KeyElementType from_key = getSet()[from_index]->GetUniqueID();
625 unsigned int to_index = flat_random(getSet().getEntries());
626 KeyElementType to_key = getSet()[to_index]->GetUniqueID();
629 if (getNamedSet().isPresentRelationFromTo(from_key, getSetName() , to_key))
632 double weight = getWeight();
634 getNamedSet().appendNewRelationTo(from_key, getSetName(), to_key , weight);
638 setToSet.add(from_index, to_index, weight);
649 CollectionOfSets m_TestBench;
651 void SetUp()
override
656 void TearDown()
override
658 DataStore::Instance().reset();
663 testRelationToOther(pair< const string, NamedSet>& otherSet)
669 otherSet.second.storedArray());
672 NamedSet::StlRelationArray theInducedRelation;
674 for (
int relation = 0 ; relation < subsetToOtherSet.getEntries() ; relation++) {
675 size_t relationSize = subsetToOtherSet[ relation ].getSize();
678 KeyElementType fromElementKey =
subset[from]->GetUniqueID();
679 if (theInducedRelation.find(fromElementKey) == theInducedRelation.end())
680 theInducedRelation.insert(pair< KeyElementType, FromTargetElementsToWeight>
681 (fromElementKey, FromTargetElementsToWeight()));
683 for (
unsigned int to_index = 0 ; to_index < relationSize ; to_index++) {
685 double weight = subsetToOtherSet[ relation ].getWeight(to_index);
686 KeyElementType toElementKey = otherSet.second.storedArray()[to]->GetUniqueID();
688 theInducedRelation.find(fromElementKey)->second.insert(pair< KeyElementType, double> (toElementKey , weight));
694 NamedSet::StlRelationArray theExpectedRelation = m_TestBench.getNamedSet().
695 getRestrictedDomainRelationTo(otherSet.first) ;
697 bool OKorKO =
equal(theExpectedRelation.begin(), theExpectedRelation.end(), theInducedRelation.begin(),
698 [](
const NamedSet::StlRelationArray::value_type & a,
699 const NamedSet::StlRelationArray::value_type & b) {
701 cout << a.first <<
" vs " << b.first << endl;
703 return a.first == b.first &&
704 equal(a.second.begin(), a.second.end(), b.second.begin(),
705 [](const FromTargetElementsToWeight::value_type & x,
706 const FromTargetElementsToWeight::value_type & y) {
709 << x.first <<
"," << x.second
711 << y.first <<
"," << y.second <<
"\t";
712 cout << (x.first == y.first) <<
" , " << (x.second == y.second) << endl;
714 return x.first == y.first && x.second == y.second;
720 for (
auto relation : theExpectedRelation)
721 for (
auto to : relation.second)
722 cout << relation.first <<
" -> " << to.first <<
" ( " << to.second <<
" )" << endl;
724 for (
auto relation : theInducedRelation)
725 for (
auto to : relation.second)
726 cout << relation.first <<
" --> " << to.first <<
" ( " << to.second <<
" )" << endl;
734 testRelationFromOther(pair< const string, NamedSet>& otherNamedSet)
741 RelationArray subsetFromOtherSet(otherNamedSet.second.storedArray(), subset);
744 NamedSet::StlRelationArray theInducedRelation;
746 for (
int relation = 0 ; relation < subsetFromOtherSet.getEntries() ; relation++) {
747 size_t relationSize = subsetFromOtherSet[ relation ].getSize();
749 KeyElementType fromElementKey = other[from]->GetUniqueID();
750 if (theInducedRelation.find(fromElementKey) == theInducedRelation.end()) {
751 theInducedRelation.insert(pair< KeyElementType, FromTargetElementsToWeight>
752 (fromElementKey, FromTargetElementsToWeight()));
755 for (
unsigned int to_index = 0 ; to_index < relationSize ; to_index++) {
757 subsetFromOtherSet[ relation ].getToIndex(to_index);
758 double weight = subsetFromOtherSet[ relation ].getWeight(to_index);
759 KeyElementType toElementKey =
subset[to]->GetUniqueID();
761 theInducedRelation.find(fromElementKey)->second.insert(pair< KeyElementType, double> (toElementKey , weight));
767 NamedSet::StlRelationArray theExpectedRelation
768 = otherNamedSet.second.getRestrictedCodomainRelationTo(m_TestBench.getSetName());
769 bool OKorKO =
equal(theExpectedRelation.begin(), theExpectedRelation.end(), theInducedRelation.begin(),
770 [](
const NamedSet::StlRelationArray::value_type & a,
771 const NamedSet::StlRelationArray::value_type & b) {
773 cout << a.first <<
" vs " << b.first << endl;
775 return a.first == b.first &&
776 equal(a.second.begin(), a.second.end(), b.second.begin(),
777 [](const FromTargetElementsToWeight::value_type & x,
778 const FromTargetElementsToWeight::value_type & y) {
781 << x.first <<
"," << x.second
783 << y.first <<
"," << y.second <<
"\t";
784 cout << (x.first == y.first) <<
" , " << (x.second == y.second) << endl;
786 return x.first == y.first && x.second == y.second;
792 for (
auto relation : theExpectedRelation)
793 for (
auto to : relation.second)
794 cout << relation.first <<
" -> " << to.first <<
" ( " << to.second <<
" )" << endl;
796 for (
auto relation : theInducedRelation)
797 for (
auto to : relation.second)
798 cout << relation.first <<
" --> " << to.first <<
" ( " << to.second <<
" )" << endl;
814 NamedSet::StlRelationArray theInducedRelation;
816 for (
int relation = 0 ; relation < selfRelation.getEntries() ; relation++) {
817 size_t relationSize = selfRelation[ relation ].getSize();
819 KeyElementType fromElementKey =
subset[from]->GetUniqueID();
820 if (theInducedRelation.find(fromElementKey) == theInducedRelation.end()) {
821 theInducedRelation.insert(pair< KeyElementType, FromTargetElementsToWeight>
822 (fromElementKey, FromTargetElementsToWeight()));
825 for (
unsigned int to_index = 0 ; to_index < relationSize ; to_index++) {
827 selfRelation[ relation ].getToIndex(to_index);
828 double weight = selfRelation[ relation ].getWeight(to_index);
829 KeyElementType toElementKey =
subset[to]->GetUniqueID();
831 theInducedRelation.find(fromElementKey)->second.insert(pair< KeyElementType, double> (toElementKey , weight));
837 NamedSet::StlRelationArray theExpectedRelation = m_TestBench.getNamedSet().
838 getRestrictedSelfRelation();
840 bool OKorKO =
equal(theExpectedRelation.begin(), theExpectedRelation.end(), theInducedRelation.begin(),
841 [](
const NamedSet::StlRelationArray::value_type & a,
842 const NamedSet::StlRelationArray::value_type & b) {
845 cout << a.first <<
" vs " << b.first << endl;
847 return (true || a.first == b.first) &&
848 equal(a.second.begin(), a.second.end(), b.second.begin(),
849 [](const FromTargetElementsToWeight::value_type & x,
850 const FromTargetElementsToWeight::value_type & y) {
853 << x.first <<
"," << x.second
855 << y.first <<
"," << y.second <<
"\t";
856 cout << (x.first == y.first) <<
" , " << (x.second == y.second) << endl;
858 return x.first == y.first && x.second == y.second;
865 cout <<
"We do expect the following set of relations" << endl;
866 for (
auto relation : theExpectedRelation)
867 for (
auto to : relation.second)
868 cout << relation.first <<
" -> " << to.first <<
" ( " << to.second <<
" )" << endl;
870 cout <<
"We found the following ones" << endl;
871 for (
auto relation : theInducedRelation)
872 for (
auto to : relation.second)
873 cout << relation.first <<
" --> " << to.first <<
" ( " << to.second <<
" )" << endl;
886 TEST_F(SelectSubsetTest, ExtensiveTest)
888 m_TestBench.initializeDatastore();
889 m_TestBench.populateDatastore();
894 DataStore::Instance().setInitializeActive(
true);
896 selector.registerSubset(set, m_TestBench.getSubsetName());
898 for (
auto other : m_TestBench.getOtherSets()) {
899 selector.inheritRelationsTo(other.second.storedArray());
900 selector.inheritRelationsFrom(other.second.storedArray());
904 selector.inheritRelationsFrom(set);
906 DataStore::Instance().setInitializeActive(
false);
908 selector.select(SelectionCriteriumOnElement);
912 bool allSubsetElementsAreGood(
true);
917 for (
const auto& element : subset) {
918 if (! SelectionCriteriumOnElement(& element))
919 allSubsetElementsAreGood =
false;
924 EXPECT_TRUE(allSubsetElementsAreGood);
930 for (
const auto& element : set)
931 NSelected += SelectionCriteriumOnElement(&element) ? 1 : 0;
933 EXPECT_TRUE(NSelected ==
subset.getEntries());
937 EXPECT_TRUE(testSelfRelation());
939 for (
int i = 0 ; i < m_TestBench.getNSets(); i++) {
941 auto otherSet = m_TestBench.getOtherNamedSet(i);
942 EXPECT_TRUE(testRelationToOther(otherSet));
943 EXPECT_TRUE(testRelationFromOther(otherSet));
950 return (a->getArrayIndex() % 2) == 1;
953 TEST_F(SelectSubsetTest, TestWithManyRelations)
958 DataStore::Instance().setInitializeActive(
true);
962 arrayMain.registerInDataStore();
963 arrayA.registerInDataStore();
964 arrayB.registerInDataStore();
965 arrayA.registerRelationTo(arrayMain);
966 arrayMain.registerRelationTo(arrayB);
975 DataStore::Instance().setInitializeActive(
false);
978 for (
int i = 0; i < 10; i++) {
979 auto* mainObj = arrayMain.appendNew();
980 for (
int j = 0; j < 2; j++) {
981 auto* aObj = arrayA.appendNew();
982 aObj->addRelationTo(mainObj);
984 for (
int j = 0; j < 10; j++) {
985 auto* bObj = arrayB.appendNew();
986 mainObj->addRelationTo(bObj);
991 selectorMain.
select(hasOddIndex);
995 EXPECT_EQ(10, arrayMain.getEntries());
996 EXPECT_EQ(20, arrayA.getEntries());
997 EXPECT_EQ(100, arrayB.getEntries());
1003 EXPECT_EQ(5, arraySubset.getEntries());
1014 EXPECT_TRUE(hasOddIndex(originalObject));
1018 TEST_F(SelectSubsetTest, InheritAll)
1023 DataStore::Instance().setInitializeActive(
true);
1027 arrayMain.registerInDataStore();
1028 arrayA.registerInDataStore();
1029 arrayB.registerInDataStore();
1030 arrayA.registerRelationTo(arrayMain);
1031 arrayMain.registerRelationTo(arrayB);
1039 DataStore::Instance().setInitializeActive(
false);
1047 TEST_F(SelectSubsetTest, TestExistingSetWithManyRelations)
1052 DataStore::Instance().setInitializeActive(
true);
1056 arrayMain.registerInDataStore();
1057 arrayA.registerInDataStore();
1058 arrayB.registerInDataStore();
1059 arrayA.registerRelationTo(arrayMain);
1060 arrayMain.registerRelationTo(arrayB);
1066 DataStore::Instance().setInitializeActive(
false);
1069 for (
int i = 0; i < 10; i++) {
1070 auto* mainObj = arrayMain.appendNew();
1071 for (
int j = 0; j < 2; j++) {
1072 auto* aObj = arrayA.appendNew();
1073 aObj->addRelationTo(mainObj);
1075 for (
int j = 0; j < 10; j++) {
1076 auto* bObj = arrayB.appendNew();
1077 mainObj->addRelationTo(bObj);
1082 EXPECT_EQ(10, arrayMain.getEntries());
1083 EXPECT_EQ(20, arrayA.getEntries());
1084 EXPECT_EQ(100, arrayB.getEntries());
1087 selectorMain.
select(hasOddIndex);
1091 EXPECT_EQ(5, arrayMain.getEntries());
1101 EXPECT_EQ((i / 2 % 2 == 1) ? 1u : 0u, r.getRelationsTo<
RelationsObject>(
"main").size());
1106 TEST_F(SelectSubsetTest, TestEmptyArray)
1111 DataStore::Instance().setInitializeActive(
true);
1115 arrayMain.registerInDataStore();
1116 arrayA.registerInDataStore();
1117 arrayB.registerInDataStore();
1118 arrayA.registerRelationTo(arrayMain);
1119 arrayMain.registerRelationTo(arrayB);
1125 DataStore::Instance().setInitializeActive(
false);
1128 EXPECT_EQ(0, arrayMain.getEntries());
1129 selectorMain.
select(hasOddIndex);
1130 EXPECT_EQ(0, arrayMain.getEntries());
1133 for (
int i = 0; i < 10; i++) {
1134 auto* mainObj = arrayMain.appendNew();
1135 for (
int j = 0; j < 2; j++) {
1136 auto* aObj = arrayA.appendNew();
1137 aObj->addRelationTo(mainObj);
1139 for (
int j = 0; j < 10; j++) {
1140 auto* bObj = arrayB.appendNew();
1141 mainObj->addRelationTo(bObj);
1146 EXPECT_EQ(10, arrayMain.getEntries());
1147 EXPECT_EQ(20, arrayA.getEntries());
1148 EXPECT_EQ(100, arrayB.getEntries());
1152 selectorMain.
select(never);
1156 EXPECT_EQ(0, arrayMain.getEntries());
Low-level class to create/modify relations between StoreArrays.
unsigned int index_type
type used for indices.
Defines interface for accessing relations of objects in StoreArray.
std::vector< std::string > getInheritToArrays() const
Get list of arrays we inherit relations to.
std::vector< std::string > getInheritFromArrays() const
Get list of arrays we inherit relations from.
bool getInheritToSelf() const
Do we inherit relations from original set to itself?
Class to create a subset of a given StoreArray together with the relations with other StoreArrays.
void inheritRelationsTo(const StoreArray< T > &array, MoreArguments... moreArgs)
Inherit relations pointing from objects selected into this subset to Other.
void inheritRelationsFrom(const StoreArray< T > &array, MoreArguments... moreArgs)
Inherit relations pointing from Other to objects selected into this subset.
void inheritAllRelations()
Automatically inherit all relations to or from the original set (if registered when calling this func...
void registerSubset(const StoreArray< StoredClass > &set, DataStore::EStoreFlags storeFlags=DataStore::c_ErrorIfAlreadyRegistered)
Remove all non-selected objects from set.
Accessor to arrays stored in the data store.
T * appendNew()
Construct a new T object at the end of the array.
int getEntries() const
Get the number of objects in the array.
TEST_F(GlobalLabelTest, LargeNumberOfTimeDependentParameters)
Test large number of time-dep params for registration and retrieval.
void select(const std::function< bool(const StoredClass *)> &f)
This method is the actual worker.
RelationsInterface< TObject > RelationsObject
Provides interface for getting/adding relations to objects in StoreArrays.
TString getName(const TObject *obj)
human-readable name (e.g.
Abstract base class for different kinds of events.
std::bitset< max - min+1 > subset(std::bitset< nbits > set)
extract a subset of bitstring, like substring.