diff --git a/src/diffpy/srreal/EmptyStructureAdapter.cpp b/src/diffpy/srreal/EmptyStructureAdapter.cpp index fb3e3c8..17cc88a 100644 --- a/src/diffpy/srreal/EmptyStructureAdapter.cpp +++ b/src/diffpy/srreal/EmptyStructureAdapter.cpp @@ -71,7 +71,6 @@ class EmptyStructureAdapter : public StructureAdapter { throw outofrange; } - // reusing StructureAdapter::customPQConfig() // reusing StructureAdapter::diff() private: diff --git a/src/diffpy/srreal/NoMetaStructureAdapter.cpp b/src/diffpy/srreal/NoMetaStructureAdapter.cpp index 1b373d1..e15af3a 100644 --- a/src/diffpy/srreal/NoMetaStructureAdapter.cpp +++ b/src/diffpy/srreal/NoMetaStructureAdapter.cpp @@ -12,13 +12,11 @@ * ****************************************************************************** * - * class NoMetaStructureAdapter -- StructureAdapter proxy class that disables - * customPQConfig of another StructureAdapter instance. This may be used - * for preventing the adapter for diffpy.Structure class from applying - * scale, spdiameter and such metadata to the PDFCalculator. + * class NoMetaStructureAdapter -- deprecated StructureAdapter proxy retained + * for source and serialization compatibility. Structures no longer + * configure calculators through metadata. * - * nometa -- factory function that returns a NoMetaStructureAdapter - * instance wrapped in StructureAdapterPtr + * nometa -- compatibility function returning the source StructureAdapter * *****************************************************************************/ @@ -88,10 +86,6 @@ const R3::Matrix& NoMetaStructureAdapter::siteCartesianUij(int idx) const { return msrcstructure->siteCartesianUij(idx); } -void NoMetaStructureAdapter::customPQConfig(PairQuantity* pq) const { - // disable customPQConfig of the wrapped PairQuantity -} - StructureDifference NoMetaStructureAdapter::diff( StructureAdapterConstPtr other) const { StructureDifference sd = this->StructureAdapter::diff(other); @@ -118,11 +112,7 @@ StructureAdapterConstPtr NoMetaStructureAdapter::getSourceStructure() const { // Routines ------------------------------------------------------------------ StructureAdapterPtr nometa(StructureAdapterPtr stru) { - StructureAdapterPtr rv = - std::dynamic_pointer_cast(stru) - ? stru - : StructureAdapterPtr(new NoMetaStructureAdapter(stru)); - return rv; + return stru ? stru : emptyStructureAdapter(); } } // namespace srreal diff --git a/src/diffpy/srreal/NoMetaStructureAdapter.hpp b/src/diffpy/srreal/NoMetaStructureAdapter.hpp index df2ce5d..58c82ba 100644 --- a/src/diffpy/srreal/NoMetaStructureAdapter.hpp +++ b/src/diffpy/srreal/NoMetaStructureAdapter.hpp @@ -12,13 +12,11 @@ * ****************************************************************************** * - * class NoMetaStructureAdapter -- StructureAdapter proxy class that disables - * customPQConfig of another StructureAdapter instance. This may be used - * for preventing the adapter for diffpy.Structure class from applying - * scale, spdiameter and such metadata to the PDFCalculator. + * class NoMetaStructureAdapter -- deprecated StructureAdapter proxy retained + * for source and serialization compatibility. Structures no longer + * configure calculators through metadata. * - * nometa -- factory function that returns a NoMetaStructureAdapter - * instance wrapped in StructureAdapterPtr + * nometa -- compatibility function returning the source StructureAdapter * *****************************************************************************/ @@ -49,7 +47,6 @@ class DLL_EXPORT NoMetaStructureAdapter : public StructureAdapter { virtual double siteOccupancy(int idx) const; virtual bool siteAnisotropy(int idx) const; virtual const R3::Matrix& siteCartesianUij(int idx) const; - virtual void customPQConfig(PairQuantity* pq) const; virtual StructureDifference diff(StructureAdapterConstPtr) const; // methods - own @@ -71,10 +68,10 @@ class DLL_EXPORT NoMetaStructureAdapter : public StructureAdapter { // Routines ------------------------------------------------------------------ -/// create NoMetaStructureAdapter from an existing StructureAdapter +/// Return the input adapter unchanged, or the empty adapter for a null input. DLL_EXPORT StructureAdapterPtr nometa(StructureAdapterPtr stru); -/// create NoMetaStructureAdapter from an adaptable structure object +/// Convert an adaptable structure without creating a proxy. template StructureAdapterPtr nometa(const T& stru) { StructureAdapterPtr bstru = convertToStructureAdapter(stru); diff --git a/src/diffpy/srreal/NoSymmetryStructureAdapter.cpp b/src/diffpy/srreal/NoSymmetryStructureAdapter.cpp index 9add118..6068ca9 100644 --- a/src/diffpy/srreal/NoSymmetryStructureAdapter.cpp +++ b/src/diffpy/srreal/NoSymmetryStructureAdapter.cpp @@ -86,10 +86,6 @@ const R3::Matrix& NoSymmetryStructureAdapter::siteCartesianUij(int idx) const { return msrcstructure->siteCartesianUij(idx); } -void NoSymmetryStructureAdapter::customPQConfig(PairQuantity* pq) const { - msrcstructure->customPQConfig(pq); -} - StructureDifference NoSymmetryStructureAdapter::diff( StructureAdapterConstPtr other) const { StructureDifference sd = this->StructureAdapter::diff(other); diff --git a/src/diffpy/srreal/NoSymmetryStructureAdapter.hpp b/src/diffpy/srreal/NoSymmetryStructureAdapter.hpp index c4b3431..479583b 100644 --- a/src/diffpy/srreal/NoSymmetryStructureAdapter.hpp +++ b/src/diffpy/srreal/NoSymmetryStructureAdapter.hpp @@ -51,7 +51,6 @@ class DLL_EXPORT NoSymmetryStructureAdapter : public StructureAdapter { virtual double siteOccupancy(int idx) const; virtual bool siteAnisotropy(int idx) const; virtual const R3::Matrix& siteCartesianUij(int idx) const; - virtual void customPQConfig(PairQuantity* pq) const; virtual StructureDifference diff(StructureAdapterConstPtr) const; // methods - own diff --git a/src/diffpy/srreal/PQEvaluator.cpp b/src/diffpy/srreal/PQEvaluator.cpp index ab66bc9..df6e6bf 100644 --- a/src/diffpy/srreal/PQEvaluator.cpp +++ b/src/diffpy/srreal/PQEvaluator.cpp @@ -198,8 +198,8 @@ void PQEvaluatorOptimized::updateValue(PairQuantity& pq, // save current value to override the resetValue call from setStructure assert(sd.stru1); pq.stashPartialValue(); - // setStructure(stru1) calls stru1->customPQConfig(pq), which may totally - // change pq configuration. If so, revert to full calculation. + // Fall back to a full calculation if assigning the new structure + // changes the calculator's configuration ticker. assert(pq.ticker() < mvalue_ticker); pq.setStructure(sd.stru1); if (pq.ticker() >= mvalue_ticker) { diff --git a/src/diffpy/srreal/PairQuantity.cpp b/src/diffpy/srreal/PairQuantity.cpp index aa91aaa..1beebdf 100644 --- a/src/diffpy/srreal/PairQuantity.cpp +++ b/src/diffpy/srreal/PairQuantity.cpp @@ -61,7 +61,6 @@ const QuantityType& PairQuantity::eval(StructureAdapterPtr stru) { void PairQuantity::setStructure(StructureAdapterPtr stru) { mstructure = stru.get() ? stru : emptyStructureAdapter(); - mstructure->customPQConfig(this); this->updateMaskData(); this->resetValue(); } diff --git a/src/diffpy/srreal/StructureAdapter.hpp b/src/diffpy/srreal/StructureAdapter.hpp index a580f6f..3d76706 100644 --- a/src/diffpy/srreal/StructureAdapter.hpp +++ b/src/diffpy/srreal/StructureAdapter.hpp @@ -36,7 +36,6 @@ namespace diffpy { namespace srreal { -class PairQuantity; class StructureDifference; /// @class StructureAdapter @@ -85,10 +84,6 @@ class DLL_EXPORT StructureAdapter /// Cartesian coordinate system at independent site @param idx virtual const R3::Matrix& siteCartesianUij(int idx) const = 0; - /// this method allows custom special configuration for a concrete - /// pair of StructureAdapter and PairQuantity objects. - [[deprecated]] virtual void customPQConfig(PairQuantity* pq) const {} - /// Return difference from the other StructureAdapter virtual StructureDifference diff(StructureAdapterConstPtr) const; diff --git a/src/tests/TestNoMetaStructureAdapter.hpp b/src/tests/TestNoMetaStructureAdapter.hpp index 4622844..68c7191 100644 --- a/src/tests/TestNoMetaStructureAdapter.hpp +++ b/src/tests/TestNoMetaStructureAdapter.hpp @@ -25,7 +25,6 @@ #include #include #include "test_helpers.hpp" -#include "test_custompqconfig.hpp" using namespace std; using namespace diffpy::srreal; @@ -42,21 +41,18 @@ class TestNoMetaStructureAdapter : public CxxTest::TestSuite { void setUp() { CxxTest::setAbortTestOnFail(true); if (!m_pswt) { - StructureAdapterPtr pswt; - pswt = loadTestPeriodicStructure("PbScW25TiO3.stru"); - PeriodicAdapterWithPQConfigPtr pswt_pqcfg; - pswt_pqcfg = addCustomPQConfig(pswt); - pswt_pqcfg->cfg["scale"] = 2.5; - m_pswt = pswt_pqcfg; + m_pswt = loadTestPeriodicStructure("PbScW25TiO3.stru"); } CxxTest::setAbortTestOnFail(false); } - void test_PDFCalcMeta() { + void test_PDFCalcPreservesConfiguration() { PDFCalculator pdfc; pdfc.setRstep(0.1); pdfc.setRmax(5.0); - TS_ASSERT_EQUALS(1.0, pdfc.getDoubleAttr("scale")); + pdfc.setDoubleAttr("scale", 2.5); + pdfc.setStructure(m_pswt); + TS_ASSERT_EQUALS(2.5, pdfc.getDoubleAttr("scale")); pdfc.eval(m_pswt); TS_ASSERT_EQUALS(2.5, pdfc.getDoubleAttr("scale")); } @@ -73,14 +69,18 @@ class TestNoMetaStructureAdapter : public CxxTest::TestSuite { void test_NoMetaTwice() { StructureAdapterPtr adpt0 = nometa(m_pswt); StructureAdapterPtr adpt1 = nometa(adpt0); + TS_ASSERT_EQUALS(m_pswt, adpt0); TS_ASSERT_EQUALS(adpt0, adpt1); + TS_ASSERT_EQUALS(emptyStructureAdapter(), nometa(StructureAdapterPtr())); + StructureAdapterPtr proxy(new NoMetaStructureAdapter(m_pswt)); + TS_ASSERT_EQUALS(proxy, nometa(proxy)); } void test_serialization() { using namespace diffpy::serialization; stringstream storage(ios::in | ios::out | ios::binary); oarchive oa(storage, ios::binary); - StructureAdapterPtr pswtbare0(nometa(m_pswt)); + StructureAdapterPtr pswtbare0(new NoMetaStructureAdapter(m_pswt)); oa << pswtbare0; iarchive ia(storage, ios::binary); StructureAdapterPtr pswtbare1; diff --git a/src/tests/test_custompqconfig.hpp b/src/tests/test_custompqconfig.hpp deleted file mode 100644 index 0405bef..0000000 --- a/src/tests/test_custompqconfig.hpp +++ /dev/null @@ -1,75 +0,0 @@ -/***************************************************************************** - * - * libdiffpy Complex Modeling Initiative - * (c) 2014 Brookhaven Science Associates, - * Brookhaven National Laboratory. - * All rights reserved. - * - * File coded by: Pavol Juhas - * - * See AUTHORS.rst for a list of people who contributed. - * See LICENSE.rst for license information. - * - ****************************************************************************** - * - * Helper class for testing the effect of customPQConfig. - * - *****************************************************************************/ - -#ifndef TEST_CUSTOMPQCONFIG_HPP_INCLUDED -#define TEST_CUSTOMPQCONFIG_HPP_INCLUDED - -#include -#include - -using diffpy::srreal::PeriodicStructureAdapter; -using diffpy::srreal::PeriodicStructureAdapterPtr; -using diffpy::srreal::StructureAdapterPtr; - -// --------------------------------------------------------------------------- - -class PeriodicAdapterWithPQConfig : public PeriodicStructureAdapter { - public: - // constructors - PeriodicAdapterWithPQConfig() {} - PeriodicAdapterWithPQConfig(const PeriodicStructureAdapter& src) - : PeriodicStructureAdapter(src) {} - - // overloads - void customPQConfig(diffpy::srreal::PairQuantity* pq) const { - std::map::const_iterator it; - for (it = cfg.begin(); it != cfg.end(); ++it) { - pq->setDoubleAttr(it->first, it->second); - } - } - - // data - std::map cfg; - - private: - // serialization - friend class boost::serialization::access; - template - void serialize(Archive& ar, const unsigned int version) { - using boost::serialization::base_object; - ar& base_object(*this); - ar & cfg; - } -}; - -BOOST_CLASS_EXPORT(PeriodicAdapterWithPQConfig) - -// Typedefs and Functions ---------------------------------------------------- - -typedef std::shared_ptr - PeriodicAdapterWithPQConfigPtr; - -inline PeriodicAdapterWithPQConfigPtr addCustomPQConfig( - StructureAdapterPtr stru) { - PeriodicStructureAdapterPtr pstru = - std::dynamic_pointer_cast(stru); - return PeriodicAdapterWithPQConfigPtr( - new PeriodicAdapterWithPQConfig(*pstru)); -} - -#endif // TEST_CUSTOMPQCONFIG_HPP_INCLUDED