39 # define __attribute__(x)
43 #include "boost/serialization/shared_ptr.hpp"
44 #include "boost/serialization/binary_object.hpp"
45 #include <boost/archive/binary_oarchive.hpp>
46 #include <boost/archive/binary_iarchive.hpp>
58 static void execTrace(std::string s,
int level =
EXEC_TRACE) {
71 namespace formatters {
73 template <
typename imagePixelT>
76 static std::string
name();
80 static std::string
name =
"Mask";
84 template <
typename MaskPixelT>
90 template <
typename MaskPixelT>
93 lsst::daf::persistence::Formatter(typeid(this)) {
96 template <
typename MaskPixelT>
100 template <
typename MaskPixelT>
103 Storage::Ptr storage,
105 execTrace(
"MaskFormatter write start");
109 throw LSST_EXCEPT(lsst::pex::exceptions::RuntimeError,
"Persisting non-Mask");
112 execTrace(
"MaskFormatter write BoostStorage");
115 execTrace(
"MaskFormatter write end");
118 else if (
typeid(*storage) ==
typeid(
FitsStorage)) {
119 execTrace(
"MaskFormatter write FitsStorage");
124 execTrace(
"MaskFormatter write end");
127 throw LSST_EXCEPT(lsst::pex::exceptions::RuntimeError,
"Unrecognized Storage for Mask");
130 template <
typename MaskPixelT>
132 Storage::Ptr storage,
134 execTrace(
"MaskFormatter read start");
136 execTrace(
"MaskFormatter read BoostStorage");
140 execTrace(
"MaskFormatter read end");
143 else if (
typeid(*storage) ==
typeid(
FitsStorage)) {
144 execTrace(
"MaskFormatter read FitsStorage");
147 execTrace(
"MaskFormatter read end");
150 throw LSST_EXCEPT(lsst::pex::exceptions::RuntimeError,
"Unrecognized Storage for Mask");
153 template <
typename MaskPixelT>
158 throw LSST_EXCEPT(lsst::pex::exceptions::RuntimeError,
"Unexpected call to update for Mask");
161 template <
typename MaskPixelT>
template <
class Archive>
163 Archive& ar,
int const version,
Persistable* persistable) {
164 execTrace(
"MaskFormatter delegateSerialize start");
167 throw LSST_EXCEPT(lsst::pex::exceptions::RuntimeError,
"Serializing non-Mask");
169 ar & ip->_offsetRows & ip->_offsetCols;
174 if (Archive::is_saving::value) {
175 cols = ip->_vwImagePtr->cols();
176 rows = ip->_vwImagePtr->rows();
177 planes = ip->_vwImagePtr->planes();
179 ar & cols & rows & planes;
180 if (Archive::is_loading::value) {
181 ip->_vwImagePtr->set_size(cols, rows, planes);
183 unsigned int pixels = cols * rows * planes;
184 MaskPixelT* data = ip->_vwImagePtr->data();
185 ar & boost::serialization::make_array(data, pixels);
186 execTrace(
"MaskFormatter delegateSerialize end");
189 template <
typename MaskPixelT>
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
boost::uint16_t MaskPixel
virtual boost::archive::text_iarchive & getIArchive(void)
boost::shared_ptr< PropertySet > Ptr
virtual std::string const & getPath(void)
boost::shared_ptr< Policy > Ptr
definition of the Trace messaging facilities
limited backward compatibility to the DC2 run-time trace facilities
Class for FITS file storage.
Represent a 2-dimensional array of bitmask pixels.
#define LSST_EXCEPT(type,...)
virtual boost::archive::text_oarchive & getOArchive(void)
Class for boost::serialization storage.
Base class for all persistable classes.
Definition of default types for Masks and Variance Images.
Abstract base class for storage implementations.
static boost::shared_ptr< detail::MaskDict > _maskPlaneDict()