39 # define __attribute__(x)
45 #include "boost/serialization/shared_ptr.hpp"
46 #include "boost/serialization/binary_object.hpp"
47 #include <boost/archive/binary_oarchive.hpp>
48 #include <boost/archive/binary_iarchive.hpp>
72 namespace formatters {
74 template <
typename imagePixelT>
77 static std::string
name();
81 static std::string
name =
"Mask";
85 template <
typename MaskPixelT>
91 template <
typename MaskPixelT>
94 lsst::daf::persistence::Formatter(typeid(this)) {
97 template <
typename MaskPixelT>
101 template <
typename MaskPixelT>
104 Storage::Ptr storage,
106 LOGL_DEBUG(_log,
"MaskFormatter write start");
110 throw LSST_EXCEPT(lsst::pex::exceptions::RuntimeError,
"Persisting non-Mask");
113 LOGL_DEBUG(_log,
"MaskFormatter write BoostStorage");
119 else if (
typeid(*storage) ==
typeid(
FitsStorage)) {
120 LOGL_DEBUG(_log,
"MaskFormatter write FitsStorage");
128 throw LSST_EXCEPT(lsst::pex::exceptions::RuntimeError,
"Unrecognized Storage for Mask");
131 template <
typename MaskPixelT>
133 Storage::Ptr storage,
137 LOGL_DEBUG(_log,
"MaskFormatter read BoostStorage");
144 else if (
typeid(*storage) ==
typeid(
FitsStorage)) {
145 LOGL_DEBUG(_log,
"MaskFormatter read FitsStorage");
151 throw LSST_EXCEPT(lsst::pex::exceptions::RuntimeError,
"Unrecognized Storage for Mask");
154 template <
typename MaskPixelT>
159 throw LSST_EXCEPT(lsst::pex::exceptions::RuntimeError,
"Unexpected call to update for Mask");
162 template <
typename MaskPixelT>
template <
class Archive>
164 Archive& ar,
int const version,
Persistable* persistable) {
165 LOGL_DEBUG(_log,
"MaskFormatter delegateSerialize start");
168 throw LSST_EXCEPT(lsst::pex::exceptions::RuntimeError,
"Serializing non-Mask");
170 ar & ip->_offsetRows & ip->_offsetCols;
175 if (Archive::is_saving::value) {
176 cols = ip->_vwImagePtr->cols();
177 rows = ip->_vwImagePtr->rows();
178 planes = ip->_vwImagePtr->planes();
180 ar & cols & rows & planes;
181 if (Archive::is_loading::value) {
182 ip->_vwImagePtr->set_size(cols, rows, planes);
184 unsigned int pixels = cols * rows * planes;
185 MaskPixelT* data = ip->_vwImagePtr->data();
186 ar & boost::serialization::make_array(data, pixels);
187 LOGL_DEBUG(_log,
"MaskFormatter delegateSerialize end");
190 template <
typename MaskPixelT>
virtual int getHdu(void)
Return the HDU to read from the FITS file.
std::shared_ptr< Policy > Ptr
table::Key< std::string > name
void writeFits(std::string const &fileName, boost::shared_ptr< lsst::daf::base::PropertySet const > metadata=boost::shared_ptr< lsst::daf::base::PropertySet >(), std::string const &mode="w") const
Write a mask to a regular FITS file.
daf_persistence package header file
Class for FITS file storage.
virtual boost::archive::text_oarchive & getOArchive(void)
Get a boost::serialization archive suitable for output.
#define LOGL_DEBUG(logger, message...)
Log a debug-level message using a varargs/printf style interface.
LSST DM logging module built on log4cxx.
Represent a 2-dimensional array of bitmask pixels.
virtual boost::archive::text_iarchive & getIArchive(void)
Get a boost::serialization archive suitable for input.
#define LSST_EXCEPT(type,...)
Create an exception with a given type and message and optionally other arguments (dependent on the ty...
virtual std::string const & getPath(void)
Return the pathname for the FITS file.
Class for boost::serialization storage.
Base class for all persistable classes.
std::shared_ptr< PropertySet > Ptr
#define LOG_GET(logger)
Returns a Log object associated with logger.
Definition of default types for Masks and Variance Images.
Abstract base class for storage implementations.
static boost::shared_ptr< detail::MaskDict > _maskPlaneDict()