diff --git a/src/diffpy/srreal/EmptyStructureAdapter.cpp b/src/diffpy/srreal/EmptyStructureAdapter.cpp index a5606ac..f6ff3c8 100644 --- a/src/diffpy/srreal/EmptyStructureAdapter.cpp +++ b/src/diffpy/srreal/EmptyStructureAdapter.cpp @@ -99,7 +99,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 f5d7366..27ddb90 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 * *****************************************************************************/ @@ -111,12 +109,6 @@ const R3::Matrix& NoMetaStructureAdapter::siteCartesianUij(int idx) const } -void NoMetaStructureAdapter::customPQConfig(PairQuantity* pq) const -{ - // disable customPQConfig of the wrapped PairQuantity -} - - StructureDifference NoMetaStructureAdapter::diff(StructureAdapterConstPtr other) const { @@ -151,10 +143,7 @@ NoMetaStructureAdapter::getSourceStructure() const 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 da454fc..288d923 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 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 @@ -74,11 +71,11 @@ class NoMetaStructureAdapter : public StructureAdapter // Routines ------------------------------------------------------------------ -/// create NoMetaStructureAdapter from an existing StructureAdapter +/// Return the input adapter unchanged, or the empty adapter for a null input. 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) { diff --git a/src/diffpy/srreal/NoSymmetryStructureAdapter.cpp b/src/diffpy/srreal/NoSymmetryStructureAdapter.cpp index 1502f63..837fee7 100644 --- a/src/diffpy/srreal/NoSymmetryStructureAdapter.cpp +++ b/src/diffpy/srreal/NoSymmetryStructureAdapter.cpp @@ -108,12 +108,6 @@ const R3::Matrix& NoSymmetryStructureAdapter::siteCartesianUij(int idx) const } -void NoSymmetryStructureAdapter::customPQConfig(PairQuantity* pq) const -{ - msrcstructure->customPQConfig(pq); -} - - StructureDifference NoSymmetryStructureAdapter::diff(StructureAdapterConstPtr other) const { diff --git a/src/diffpy/srreal/NoSymmetryStructureAdapter.hpp b/src/diffpy/srreal/NoSymmetryStructureAdapter.hpp index 5d8d87c..21b7dc3 100644 --- a/src/diffpy/srreal/NoSymmetryStructureAdapter.hpp +++ b/src/diffpy/srreal/NoSymmetryStructureAdapter.hpp @@ -51,7 +51,6 @@ class 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 7187405..29ffe35 100644 --- a/src/diffpy/srreal/PQEvaluator.cpp +++ b/src/diffpy/srreal/PQEvaluator.cpp @@ -247,8 +247,8 @@ void PQEvaluatorOptimized::updateValue( // 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 f420df5..039e2a3 100644 --- a/src/diffpy/srreal/PairQuantity.cpp +++ b/src/diffpy/srreal/PairQuantity.cpp @@ -69,7 +69,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 3d047b1..31d8864 100644 --- a/src/diffpy/srreal/StructureAdapter.hpp +++ b/src/diffpy/srreal/StructureAdapter.hpp @@ -34,7 +34,6 @@ namespace diffpy { namespace srreal { -class PairQuantity; class StructureDifference; @@ -86,11 +85,6 @@ class 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 aabf5dd..1c4bf2b 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; @@ -47,23 +46,20 @@ class TestNoMetaStructureAdapter : public CxxTest::TestSuite 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")); } @@ -84,7 +80,11 @@ class TestNoMetaStructureAdapter : public CxxTest::TestSuite { 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)); } @@ -93,7 +93,7 @@ class TestNoMetaStructureAdapter : public CxxTest::TestSuite 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 a71ec10..0000000 --- a/src/tests/test_custompqconfig.hpp +++ /dev/null @@ -1,86 +0,0 @@ -/***************************************************************************** -* -* libdiffpy Complex Modeling Initiative -* (c) 2014 Brookhaven Science Associates, -* Brookhaven National Laboratory. -* All rights reserved. -* -* File coded by: Pavol Juhas -* -* See AUTHORS.txt for a list of people who contributed. -* See LICENSE.txt 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::StructureAdapterPtr; -using diffpy::srreal::PeriodicStructureAdapter; -using diffpy::srreal::PeriodicStructureAdapterPtr; - -// --------------------------------------------------------------------------- - -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