Skip to content

Commit 76219ae

Browse files
committed
Add BVParametersTable method getAllCustom.
Return a set of all BVParam values that were customized.
1 parent 8830822 commit 76219ae

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

src/diffpy/srreal/BVParametersTable.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,13 @@ void BVParametersTable::resetAll()
118118
}
119119

120120

121+
const BVParametersTable::SetOfBVParam&
122+
BVParametersTable::getAllCustom() const
123+
{
124+
return mcustomtable;
125+
}
126+
127+
121128
BVParametersTable::SetOfBVParam
122129
BVParametersTable::getAll() const
123130
{

src/diffpy/srreal/BVParametersTable.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ class BVParametersTable
5757
void resetCustom(const std::string& atom0, int valence0,
5858
const std::string& atom1, int valence1);
5959
void resetAll();
60+
const SetOfBVParam& getAllCustom() const;
6061
SetOfBVParam getAll() const;
6162

6263
private:

src/tests/TestBVParametersTable.hpp

+19
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,25 @@ class TestBVParametersTable : public CxxTest::TestSuite
135135
}
136136

137137

138+
void test_getAllCustom()
139+
{
140+
TS_ASSERT(mbvtb->getAllCustom().empty());
141+
BVParam mymgo("Mg", 2, "O", -2);
142+
mbvtb->setCustom(mymgo);
143+
TS_ASSERT_EQUALS(1u, mbvtb->getAllCustom().size());
144+
const BVParam& bp = mbvtb->lookup("O2-", "Mg2+");
145+
BVParametersTable::SetOfBVParam::const_iterator ii;
146+
ii = mbvtb->getAllCustom().find(mymgo);
147+
TS_ASSERT_DIFFERS(ii, mbvtb->getAllCustom().end());
148+
TS_ASSERT_DIFFERS(&mymgo, &(*ii));
149+
TS_ASSERT_EQUALS(&bp, &(*ii));
150+
TS_ASSERT_EQUALS(mymgo, *ii);
151+
// erase the only custom parameter
152+
mbvtb->resetCustom(*ii);
153+
TS_ASSERT(mbvtb->getAllCustom().empty());
154+
}
155+
156+
138157
void test_getAll()
139158
{
140159
BVParametersTable::SetOfBVParam allpars0, allpars1;

0 commit comments

Comments
 (0)