Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-6056: replace CONST_PTR and PTR macros by std::shared #35

Merged
merged 1 commit into from
Aug 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions include/lsst/shapelet/FunctorKeys.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ class MultiShapeletFunctionKey : public afw::table::FunctorKey< MultiShapeletFun
MultiShapeletFunctionKey() {}

/// Construct from individual Keys/FunctorKeys
explicit MultiShapeletFunctionKey(std::vector<PTR(ShapeletFunctionKey)> const & components) :
explicit MultiShapeletFunctionKey(std::vector<std::shared_ptr<ShapeletFunctionKey>> const & components) :
_components(components)
{}

Expand Down Expand Up @@ -221,13 +221,13 @@ class MultiShapeletFunctionKey : public afw::table::FunctorKey< MultiShapeletFun
bool isValid() const;

/// Return a FunctorKey to the nth component.
PTR(ShapeletFunctionKey) operator[](int n) { return _components[n]; }
std::shared_ptr<ShapeletFunctionKey> operator[](int n) { return _components[n]; }

/// Return a FunctorKey to the nth component.
PTR(ShapeletFunctionKey const) operator[](int n) const { return _components[n]; }
std::shared_ptr<ShapeletFunctionKey const> operator[](int n) const { return _components[n]; }

private:
std::vector<PTR(ShapeletFunctionKey)> _components;
std::vector<std::shared_ptr<ShapeletFunctionKey>> _components;
};

}} // namespace lsst::shapelet
Expand Down
6 changes: 3 additions & 3 deletions include/lsst/shapelet/MatrixBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ class MatrixBuilder {

template <typename U> friend class MatrixBuilderFactory;

explicit MatrixBuilder(PTR(Impl) impl);
explicit MatrixBuilder(std::shared_ptr<Impl> impl);

PTR(Impl) _impl;
std::shared_ptr<Impl> _impl;
};

/**
Expand Down Expand Up @@ -344,7 +344,7 @@ class MatrixBuilderFactory {
MatrixBuilder<T> operator()(Workspace & workspace) const;

private:
PTR(Impl) _impl;
std::shared_ptr<Impl> _impl;
};

}} // namespace lsst::shapelet
Expand Down
6 changes: 3 additions & 3 deletions include/lsst/shapelet/RadialProfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,12 @@ class RadialProfile {
* Throws NotFoundError if the a basis with the given combination of nComponents and
* maxRadius has not been added to the RadialProfile.
*/
PTR(MultiShapeletBasis) getBasis(int nComponents, int maxRadius=0) const;
std::shared_ptr<MultiShapeletBasis> getBasis(int nComponents, int maxRadius=0) const;

/**
* @brief Register a basis with the profile, making it available to callers of getBasis().
*/
void registerBasis(PTR(MultiShapeletBasis) basis, int nComponents, int maxRadius);
void registerBasis(std::shared_ptr<MultiShapeletBasis> basis, int nComponents, int maxRadius);

protected:

Expand All @@ -119,7 +119,7 @@ class RadialProfile {

private:

typedef std::map<std::pair<int,int>,PTR(MultiShapeletBasis)> BasisRegistry;
typedef std::map<std::pair<int,int>, std::shared_ptr<MultiShapeletBasis>> BasisRegistry;

std::string const _name;
int _defaultMaxRadius;
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/shapelet/functorKeys.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ PYBIND11_MODULE(functorKeys, mod) {
clsMultiShapeletFunctionKey.def(py::init<>());
clsMultiShapeletFunctionKey.def(py::init<afw::table::SubSchema const &, BasisTypeEnum>(), "s"_a,
"basisType"_a = HERMITE);
clsMultiShapeletFunctionKey.def(py::init<std::vector<PTR(ShapeletFunctionKey)> const &>(),
clsMultiShapeletFunctionKey.def(py::init<std::vector<std::shared_ptr<ShapeletFunctionKey>> const &>(),
"components"_a);

clsMultiShapeletFunctionKey.def_static("addFields", MultiShapeletFunctionKey::addFields, "schema"_a,
Expand Down
2 changes: 1 addition & 1 deletion src/FunctorKeys.cc
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ MultiShapeletFunctionKey::MultiShapeletFunctionKey(
std::size_t i = 0;
while (true) {
try {
PTR(ShapeletFunctionKey) component = std::make_shared<ShapeletFunctionKey>(
std::shared_ptr<ShapeletFunctionKey> component = std::make_shared<ShapeletFunctionKey>(
s[std::to_string(i)],
basisType
);
Expand Down
20 changes: 10 additions & 10 deletions src/MatrixBuilder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,12 @@ class MatrixBuilderFactory<T>::Impl {

virtual int computeWorkspace() const = 0;

PTR(BuilderImpl) makeBuilderImpl() const {
std::shared_ptr<BuilderImpl> makeBuilderImpl() const {
Workspace workspace(computeWorkspace());
return makeBuilderImpl(workspace);
}

virtual PTR(BuilderImpl) makeBuilderImpl(Workspace & workspace) const = 0;
virtual std::shared_ptr<BuilderImpl> makeBuilderImpl(Workspace & workspace) const = 0;

virtual ~Impl() {}

Expand Down Expand Up @@ -217,7 +217,7 @@ class ShapeletImpl : public SimpleImpl<T> {

int getLhsOrder() const { return _lhsOrder; }

virtual PTR(typename MatrixBuilder<T>::Impl) makeBuilderImpl(Workspace & workspace) const {
virtual std::shared_ptr<typename MatrixBuilder<T>::Impl> makeBuilderImpl(Workspace & workspace) const {
return std::make_shared<ShapeletImpl>(*this, &workspace);
}

Expand Down Expand Up @@ -353,7 +353,7 @@ class ConvolvedShapeletImpl : public ShapeletImpl<T> {

ShapeletFunction const & getPsf() const { return _psf; }

virtual PTR(typename MatrixBuilder<T>::Impl) makeBuilderImpl(Workspace & workspace) const {
virtual std::shared_ptr<typename MatrixBuilder<T>::Impl> makeBuilderImpl(Workspace & workspace) const {
return std::make_shared<ConvolvedShapeletImpl>(*this, &workspace);
}

Expand Down Expand Up @@ -449,7 +449,7 @@ class RemappedShapeletImpl : public ShapeletImpl<T> {

ndarray::Array<double const,2,2> getRemapMatrix() const { return _remapMatrix; }

virtual PTR(typename MatrixBuilder<T>::Impl) makeBuilderImpl(Workspace & workspace) const {
virtual std::shared_ptr<typename MatrixBuilder<T>::Impl> makeBuilderImpl(Workspace & workspace) const {
return std::make_shared<RemappedShapeletImpl>(*this, &workspace);
}

Expand Down Expand Up @@ -548,7 +548,7 @@ class RemappedConvolvedShapeletImpl : public ConvolvedShapeletImpl<T> {

ndarray::Array<double const,2,2> getRemapMatrix() const { return _remapMatrix; }

virtual PTR(typename MatrixBuilder<T>::Impl) makeBuilderImpl(Workspace & workspace) const {
virtual std::shared_ptr<typename MatrixBuilder<T>::Impl> makeBuilderImpl(Workspace & workspace) const {
return std::make_shared<RemappedConvolvedShapeletImpl>(*this, &workspace);
}

Expand Down Expand Up @@ -616,11 +616,11 @@ class CompoundImpl : public MatrixBuilder<T>::Impl {
typedef MatrixBuilderWorkspace<T> Workspace;

typedef typename MatrixBuilder<T>::Impl Component;
typedef std::vector<PTR(Component)> Vector;
typedef std::vector<std::shared_ptr<Component>> Vector;
typedef typename Vector::const_iterator Iterator;

typedef typename MatrixBuilderFactory<T>::Impl FactoryComponent;
typedef std::vector<PTR(FactoryComponent)> FactoryVector;
typedef std::vector<std::shared_ptr<FactoryComponent>> FactoryVector;
typedef typename FactoryVector::const_iterator FactoryIterator;

class Factory : public MatrixBuilderFactory<T>::Impl {
Expand Down Expand Up @@ -675,7 +675,7 @@ class CompoundImpl : public MatrixBuilder<T>::Impl {
return ws;
}

virtual PTR(typename MatrixBuilder<T>::Impl) makeBuilderImpl(Workspace & workspace) const {
virtual std::shared_ptr<typename MatrixBuilder<T>::Impl> makeBuilderImpl(Workspace & workspace) const {
Vector builders;
builders.reserve(_components.size());
for (FactoryIterator i = _components.begin(); i != _components.end(); ++i) {
Expand Down Expand Up @@ -785,7 +785,7 @@ void MatrixBuilder<T>::operator()(
}

template <typename T>
MatrixBuilder<T>::MatrixBuilder(PTR(Impl) impl) :
MatrixBuilder<T>::MatrixBuilder(std::shared_ptr<Impl> impl) :
_impl(impl)
{}

Expand Down
6 changes: 3 additions & 3 deletions src/RadialProfile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class GaussianRadialProfile : public SersicRadialProfile {
explicit GaussianRadialProfile() :
SersicRadialProfile("gaussian", 0.5, 0)
{
PTR(MultiShapeletBasis) basis = std::make_shared<MultiShapeletBasis>(1);
std::shared_ptr<MultiShapeletBasis> basis = std::make_shared<MultiShapeletBasis>(1);
ndarray::Array<double,2,2> matrix = ndarray::allocate(1,1);
matrix.deep() = 0.5 / std::sqrt(geom::PI);
basis->addComponent(_momentsRadiusFactor, 0, matrix);
Expand Down Expand Up @@ -160,7 +160,7 @@ ndarray::Array<double,1,1> RadialProfile::evaluate(ndarray::Array<double const,1
return p;
}

PTR(MultiShapeletBasis) RadialProfile::getBasis(int nComponents, int maxRadius) const {
std::shared_ptr<MultiShapeletBasis> RadialProfile::getBasis(int nComponents, int maxRadius) const {
if (maxRadius == 0) maxRadius = _defaultMaxRadius;
BasisRegistry::const_iterator i = _basisRegistry.find(std::make_pair(nComponents, maxRadius));
if (i == _basisRegistry.end()) {
Expand All @@ -175,7 +175,7 @@ PTR(MultiShapeletBasis) RadialProfile::getBasis(int nComponents, int maxRadius)
return std::make_shared<MultiShapeletBasis>(*i->second);
}

void RadialProfile::registerBasis(PTR(MultiShapeletBasis) basis, int nComponents, int maxRadius) {
void RadialProfile::registerBasis(std::shared_ptr<MultiShapeletBasis> basis, int nComponents, int maxRadius) {
_basisRegistry[std::make_pair(nComponents, maxRadius)] = basis;
}

Expand Down