9 #include "boost/serialization/nvp.hpp" 13 #include "lsst/daf/persistence/FormatterImpl.h" 14 #include "lsst/daf/persistence/LogicalLocation.h" 15 #include "lsst/daf/persistence/BoostStorage.h" 16 #include "lsst/daf/persistence/XmlStorage.h" 17 #include "lsst/pex/exceptions.h" 18 #include "lsst/log/Log.h" 19 #include "lsst/pex/policy/Policy.h" 24 LOG_LOGGER _log = LOG_GET(
"afw.detection.PsfFormatter");
35 using boost::serialization::make_nvp;
37 dafPersist::FormatterRegistration PsfFormatter::registration(
"Psf",
typeid(Psf), createInstance);
39 PsfFormatter::PsfFormatter(std::shared_ptr<pexPolicy::Policy> policy)
40 :
dafPersist::Formatter(typeid(this)), _policy(policy) {}
45 std::shared_ptr<dafPersist::FormatterStorage> storage,
46 std::shared_ptr<dafBase::PropertySet>) {
47 LOGL_DEBUG(_log,
"PsfFormatter write start");
48 Psf const* ps =
dynamic_cast<Psf const*
>(persistable);
50 throw LSST_EXCEPT(lsst::pex::exceptions::RuntimeError,
"Persisting non-Psf");
53 auto boost = std::dynamic_pointer_cast<dafPersist::BoostStorage>(storage);
55 LOGL_DEBUG(_log,
"PsfFormatter write BoostStorage");
56 boost->getOArchive() & ps;
57 LOGL_DEBUG(_log,
"PsfFormatter write end");
60 auto xml = std::dynamic_pointer_cast<dafPersist::XmlStorage>(storage);
62 LOGL_DEBUG(_log,
"PsfFormatter write XmlStorage");
63 xml->getOArchive() & make_nvp(
"psf", ps);
64 LOGL_DEBUG(_log,
"PsfFormatter write end");
67 throw LSST_EXCEPT(lsst::pex::exceptions::RuntimeError,
"Unrecognized FormatterStorage for Psf");
71 std::shared_ptr<dafBase::PropertySet>) {
72 LOGL_DEBUG(_log,
"PsfFormatter read start");
76 auto boost = std::dynamic_pointer_cast<dafPersist::BoostStorage>(storage);
78 LOGL_DEBUG(_log,
"PsfFormatter read BoostStorage");
79 boost->getIArchive() & ps;
80 LOGL_DEBUG(_log,
"PsfFormatter read end");
83 auto xml = std::dynamic_pointer_cast<dafPersist::XmlStorage>(storage);
85 LOGL_DEBUG(_log,
"PsfFormatter read XmlStorage");
86 xml->getIArchive() & make_nvp(
"psf", ps);
87 LOGL_DEBUG(_log,
"PsfFormatter read end");
90 throw LSST_EXCEPT(lsst::pex::exceptions::RuntimeError,
"Unrecognized FormatterStorage for Psf");
94 std::shared_ptr<dafBase::PropertySet>) {
95 throw LSST_EXCEPT(lsst::pex::exceptions::RuntimeError,
"Unexpected call to update for Psf");
98 template <
class Archive>
100 LOGL_DEBUG(_log,
"PsfFormatter delegateSerialize start");
101 Psf* ps =
dynamic_cast<Psf*
>(persistable);
103 throw LSST_EXCEPT(lsst::pex::exceptions::RuntimeError,
"Serializing non-Psf");
105 #if 0 // not present in baseclass 106 ar & make_nvp(
"width", ps->_width) & make_nvp(
"height", ps->_height);
107 ar & make_nvp(
"k", ps->_kernel);
110 LOGL_DEBUG(_log,
"PsfFormatter delegateSerialize end");
113 std::shared_ptr<dafPersist::Formatter> PsfFormatter::createInstance(
114 std::shared_ptr<pexPolicy::Policy> policy) {
115 return std::shared_ptr<dafPersist::Formatter>(
new PsfFormatter(policy));
A base class for image defects.
A polymorphic base class for representing an image's Point Spread Function.