Skip to content

Commit

Permalink
Merge pull request #58 from lsst/tickets/DM-6056
Browse files Browse the repository at this point in the history
DM-6056: replace CONST_PTR and PTR macros by std::shared
  • Loading branch information
mwittgen committed Aug 30, 2021
2 parents c1211bb + cf51463 commit 9177489
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
14 changes: 7 additions & 7 deletions include/lsst/meas/extensions/psfex/PsfexPsf.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,17 @@ class PsfexPsf : public lsst::afw::table::io::PersistableFacade<PsfexPsf>,
virtual ~PsfexPsf();

/// Polymorphic deep copy; should usually be unnecessary as Psfs are immutable.x
virtual PTR(lsst::afw::detection::Psf) clone() const;
virtual std::shared_ptr<lsst::afw::detection::Psf> clone() const;

/// Return a clone with specified kernel dimensions
virtual PTR(afw::detection::Psf) resized(int width, int height) const;
virtual std::shared_ptr<afw::detection::Psf> resized(int width, int height) const;

/// Return average position of stars; used as default position.
virtual lsst::geom::Point2D getAveragePosition() const { return _averagePosition; }

/// Return the PSF's basis functions as a spatially-invariant LinearCombinationKernel
/// with unit weights
PTR(lsst::afw::math::LinearCombinationKernel const)
std::shared_ptr<lsst::afw::math::LinearCombinationKernel const>
getKernel(lsst::geom::Point2D =
lsst::geom::Point2D(std::numeric_limits<double>::quiet_NaN())) const;

Expand All @@ -77,26 +77,26 @@ class PsfexPsf : public lsst::afw::table::io::PersistableFacade<PsfexPsf>,
std::vector<int> _size; // PSF dimensions
std::vector<float> _comp; // Complete pix. data (PSF components)
std::vector<std::pair<double, double> > _context; // Offset/scale to apply to context data
mutable PTR(lsst::afw::math::LinearCombinationKernel) _kernel; // keep a reference to getKernel()'s kernel
mutable std::shared_ptr<lsst::afw::math::LinearCombinationKernel> _kernel; // keep a reference to getKernel()'s kernel

/// default ctor; needed for persistence
explicit PsfexPsf();

/// Compute an image of the Psf at the specified position/colour, at pixel position in the output image
virtual PTR(lsst::afw::detection::Psf::Image) _doComputeImage(
virtual std::shared_ptr<lsst::afw::detection::Psf::Image> _doComputeImage(
lsst::geom::Point2D const & position, ///< position within the chip
lsst::afw::image::Color const& color, ///< colour of object
lsst::geom::Point2D const& center ///< position of center of image in the output image
) const;

/// Compute an image of the Psf at the specified position/colour, at pixel (0.0, 0.0) in the output image
virtual PTR(lsst::afw::detection::Psf::Image) doComputeKernelImage(
virtual std::shared_ptr<lsst::afw::detection::Psf::Image> doComputeKernelImage(
lsst::geom::Point2D const & position, ///< position within the chip
lsst::afw::image::Color const& color ///< colour of object
) const;

/// Compute an image of the Psf at the specified position/colour, at pixel position in the output image
virtual PTR(lsst::afw::detection::Psf::Image) doComputeImage(
virtual std::shared_ptr<lsst::afw::detection::Psf::Image> doComputeImage(
lsst::geom::Point2D const & position, ///< position within the chip
lsst::afw::image::Color const& color ///< colour of object
) const;
Expand Down
22 changes: 11 additions & 11 deletions src/PsfexPsf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,17 @@ PsfexPsf::~PsfexPsf()
poly_end(_poly);
}

PTR(afw::detection::Psf)
std::shared_ptr<afw::detection::Psf>
PsfexPsf::clone() const {
return std::make_shared<PsfexPsf>(*this);
}

PTR(afw::detection::Psf)
std::shared_ptr<afw::detection::Psf>
PsfexPsf::resized(int width, int height) const {
throw LSST_EXCEPT(pex::exceptions::LogicError, "Not Implemented");
}

PTR(afw::math::LinearCombinationKernel const)
std::shared_ptr<afw::math::LinearCombinationKernel const>
PsfexPsf::getKernel(geom::Point2D position) const
{
double pos[MAXCONTEXT];
Expand Down Expand Up @@ -180,13 +180,13 @@ PsfexPsf::getKernel(geom::Point2D position) const
return _kernel;
}

PTR(afw::detection::Psf::Image)
std::shared_ptr<afw::detection::Psf::Image>
PsfexPsf::doComputeImage(geom::Point2D const & position,
afw::image::Color const & color) const {
return _doComputeImage(position, color, position);
}

PTR(afw::detection::Psf::Image)
std::shared_ptr<afw::detection::Psf::Image>
PsfexPsf::doComputeKernelImage(geom::Point2D const& position,
afw::image::Color const& color) const
{
Expand Down Expand Up @@ -221,7 +221,7 @@ geom::Box2I PsfexPsf::_doComputeBBox(geom::Point2D const & position,
return bbox;
}

PTR(afw::detection::Psf::Image)
std::shared_ptr<afw::detection::Psf::Image>
PsfexPsf::_doComputeImage(geom::Point2D const& position,
afw::image::Color const& color,
geom::Point2D const& center
Expand Down Expand Up @@ -270,7 +270,7 @@ PsfexPsf::_doComputeImage(geom::Point2D const& position,
// And copy it into place
//
geom::Box2I bbox = _doComputeBBox(position, center);
PTR(afw::detection::Psf::Image) im = std::make_shared<afw::detection::Psf::Image>(bbox);
std::shared_ptr<afw::detection::Psf::Image> im = std::make_shared<afw::detection::Psf::Image>(bbox);

int sampleW = bbox.getWidth();
int sampleH = bbox.getHeight();
Expand Down Expand Up @@ -377,11 +377,11 @@ namespace detail { // PsfexPsfFactory needs to be a friend
class PsfexPsfFactory : public table::io::PersistableFactory {
public:

virtual PTR(table::io::Persistable)
virtual std::shared_ptr<table::io::Persistable>
read(InputArchive const & archive, CatalogVector const & catalogs) const {
LSST_ARCHIVE_ASSERT(catalogs.size() == 2u);

PTR(PsfexPsf) result(new PsfexPsf());
std::shared_ptr<PsfexPsf> result(new PsfexPsf());

int ndim, ngroup, ncoeff;
int size_size, comp_size, context_size;
Expand Down Expand Up @@ -482,7 +482,7 @@ void PsfexPsf::write(afw::table::io::OutputArchiveHandle & handle) const {
{
PsfexPsfSchema1 const keys;
afw::table::BaseCatalog cat = handle.makeCatalog(keys.schema);
PTR(afw::table::BaseRecord) record = cat.addNew();
std::shared_ptr<afw::table::BaseRecord> record = cat.addNew();

// Sizes in _poly
record->set(keys.ndim, _poly->ndim);
Expand All @@ -503,7 +503,7 @@ void PsfexPsf::write(afw::table::io::OutputArchiveHandle & handle) const {
_size.size(), _comp.size(), _context.size());
afw::table::BaseCatalog cat = handle.makeCatalog(keys.schema);
// _poly
PTR(afw::table::BaseRecord) record = cat.addNew();
std::shared_ptr<afw::table::BaseRecord> record = cat.addNew();
{
int *begin = record->getElement(keys.group);
std::copy(_poly->group, _poly->group + _poly->ndim, begin);
Expand Down

0 comments on commit 9177489

Please sign in to comment.