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-10485: Protected methods should not use private method naming convention #16

Merged
merged 3 commits into from
May 19, 2017
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
11 changes: 9 additions & 2 deletions include/astshim/Channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,20 +156,27 @@ class Channel : public Object {
int write(Object const &object);

protected:
virtual std::shared_ptr<Object> _copyPolymorphic() const override { return std::shared_ptr<Object>(); }
virtual std::shared_ptr<Object> copyPolymorphic() const override { return std::shared_ptr<Object>(); }

/**
Construct a channel from an AST channel pointer and a @ref Stream

This is the constructor most subclasses use for their high-level constructor.

@param[in] chan AstChannel object
@param[in,out] stream Stream to associate with the channel
@param[in] isFits If true then read or write the stream as a FITS header
*/
explicit Channel(AstChannel *chan, Stream &stream);
explicit Channel(AstChannel *chan, Stream &stream, bool isFits=false);

/**
Construct a channel from an AST channel pointer that has its own stream

@param[in] chan AstChannel object
*/
explicit Channel(AstChannel *chan);

private:
Stream _stream; ///< stream read and/or written read by the channel
};

Expand Down
6 changes: 3 additions & 3 deletions include/astshim/ChebyMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ class ChebyMap : public Mapping {
ChebyMap &operator=(ChebyMap &&) = default;

/// Return a deep copy of this object.
std::shared_ptr<ChebyMap> copy() const { return std::static_pointer_cast<ChebyMap>(_copyPolymorphic()); }
std::shared_ptr<ChebyMap> copy() const { return std::static_pointer_cast<ChebyMap>(copyPolymorphic()); }

/**
Return the bounding box of the domain of a ChebyMap.
Expand Down Expand Up @@ -307,8 +307,8 @@ class ChebyMap : public Mapping {
ChebyMap polyTran(bool forward, double acc, double maxacc, int maxorder) const;

protected:
virtual std::shared_ptr<Object> _copyPolymorphic() const override {
return _copyImpl<ChebyMap, AstChebyMap>();
virtual std::shared_ptr<Object> copyPolymorphic() const override {
return copyImpl<ChebyMap, AstChebyMap>();
}

/// Construct a ChebyMap from an raw AST pointer
Expand Down
8 changes: 4 additions & 4 deletions include/astshim/CmpFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,19 +84,19 @@ class CmpFrame : public Frame {
CmpFrame &operator=(CmpFrame &&) = default;

/// Return a deep copy of this object.
std::shared_ptr<CmpFrame> copy() const { return std::static_pointer_cast<CmpFrame>(_copyPolymorphic()); }
std::shared_ptr<CmpFrame> copy() const { return std::static_pointer_cast<CmpFrame>(copyPolymorphic()); }

/**
Return a shallow copy of one of the two component frames.

@param[in] i Index: 0 for the first frame, 1 for the second.
@throws std::invalid_argument if `i` is not 0 or 1.
*/
std::shared_ptr<Frame> operator[](int i) const { return _decompose<Frame>(i, false); }
std::shared_ptr<Frame> operator[](int i) const { return decompose<Frame>(i, false); }

protected:
virtual std::shared_ptr<Object> _copyPolymorphic() const override {
return _copyImpl<CmpFrame, AstCmpFrame>();
virtual std::shared_ptr<Object> copyPolymorphic() const override {
return copyImpl<CmpFrame, AstCmpFrame>();
}

/// Construct a CmpFrame from a raw AST pointer
Expand Down
4 changes: 2 additions & 2 deletions include/astshim/CmpMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,15 @@ class CmpMap : public Mapping {
CmpMap &operator=(CmpMap &&) = default;

/// Return a deep copy of this object.
std::shared_ptr<CmpMap> copy() const { return std::static_pointer_cast<CmpMap>(_copyPolymorphic()); }
std::shared_ptr<CmpMap> copy() const { return std::static_pointer_cast<CmpMap>(copyPolymorphic()); }

/**
Return a shallow copy of one of the two component mappings.

@param[in] i Index: 0 for the first mapping, 1 for the second.
@throws std::invalid_argument if `i` is not 0 or 1.
*/
std::shared_ptr<Mapping> operator[](int i) const { return _decompose<Mapping>(i, false); };
std::shared_ptr<Mapping> operator[](int i) const { return decompose<Mapping>(i, false); };

/// Return True if the map is in series
bool getSeries() { return detail::isSeries(reinterpret_cast<AstCmpMap *>(getRawPtr())); }
Expand Down
4 changes: 2 additions & 2 deletions include/astshim/Frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ class Frame : public Mapping {
Frame &operator=(Frame &&) = default;

/// Return a deep copy of this object.
std::shared_ptr<Frame> copy() const { return std::static_pointer_cast<Frame>(_copyPolymorphic()); }
std::shared_ptr<Frame> copy() const { return std::static_pointer_cast<Frame>(copyPolymorphic()); }

/**
Find the angle at point B between the line joining points A and B, and the line joining points C and B.
Expand Down Expand Up @@ -1513,7 +1513,7 @@ class Frame : public Mapping {
}
}

virtual std::shared_ptr<Object> _copyPolymorphic() const override { return _copyImpl<Frame, AstFrame>(); }
virtual std::shared_ptr<Object> copyPolymorphic() const override { return copyImpl<Frame, AstFrame>(); }

private:
/**
Expand Down
6 changes: 3 additions & 3 deletions include/astshim/FrameSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class FrameSet : public Frame {
FrameSet &operator=(FrameSet &&) = default;

/// Return a deep copy of this object.
std::shared_ptr<FrameSet> copy() const { return std::static_pointer_cast<FrameSet>(_copyPolymorphic()); }
std::shared_ptr<FrameSet> copy() const { return std::static_pointer_cast<FrameSet>(copyPolymorphic()); }

/**
Append the axes from a specified @ref Frame to every existing @ref Frame in this FrameSet.
Expand Down Expand Up @@ -479,8 +479,8 @@ class FrameSet : public Frame {
void setCurrent(int ind) { setI("Current", ind); }

protected:
virtual std::shared_ptr<Object> _copyPolymorphic() const override {
return _copyImpl<FrameSet, AstFrameSet>();
virtual std::shared_ptr<Object> copyPolymorphic() const override {
return copyImpl<FrameSet, AstFrameSet>();
}

/**
Expand Down
6 changes: 3 additions & 3 deletions include/astshim/KeyMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class KeyMap : public Object {

/// Return a deep copy of this object.
std::shared_ptr<KeyMap> copy() const {
return std::static_pointer_cast<KeyMap>(_copyPolymorphic());
return std::static_pointer_cast<KeyMap>(copyPolymorphic());
assertOK();
}

Expand Down Expand Up @@ -577,8 +577,8 @@ class KeyMap : public Object {

protected:
// Protected implementation of deep-copy.
virtual std::shared_ptr<Object> _copyPolymorphic() const override {
return std::static_pointer_cast<KeyMap>(_copyImpl<KeyMap, AstKeyMap>());
virtual std::shared_ptr<Object> copyPolymorphic() const override {
return std::static_pointer_cast<KeyMap>(copyImpl<KeyMap, AstKeyMap>());
}

/**
Expand Down
6 changes: 3 additions & 3 deletions include/astshim/LutMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class LutMap : public Mapping {
LutMap &operator=(LutMap &&) = default;

/// Return a deep copy of this object.
std::shared_ptr<LutMap> copy() const { return std::static_pointer_cast<LutMap>(_copyPolymorphic()); }
std::shared_ptr<LutMap> copy() const { return std::static_pointer_cast<LutMap>(copyPolymorphic()); }

/**
Get attribute @ref LutMap_LutEpsilon "LutEpsilon": the relative error of the values in the table.
Expand All @@ -99,8 +99,8 @@ class LutMap : public Mapping {
int getLutInterp() const { return getI("LutInterp"); }

protected:
virtual std::shared_ptr<Object> _copyPolymorphic() const override {
return _copyImpl<LutMap, AstLutMap>();
virtual std::shared_ptr<Object> copyPolymorphic() const override {
return copyImpl<LutMap, AstLutMap>();
}

/// Construct an LutMap from a raw AST pointer
Expand Down
8 changes: 4 additions & 4 deletions include/astshim/Mapping.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class Mapping : public Object {
Mapping &operator=(Mapping &&) = default;

/// Return a deep copy of this object.
std::shared_ptr<Mapping> copy() const { return std::static_pointer_cast<Mapping>(_copyPolymorphic()); }
std::shared_ptr<Mapping> copy() const { return std::static_pointer_cast<Mapping>(copyPolymorphic()); }

/**
Get @ref Mapping_Nin "Nin": the number of input axes
Expand Down Expand Up @@ -397,8 +397,8 @@ class Mapping : public Object {
}

// Protected implementation of deep-copy.
virtual std::shared_ptr<Object> _copyPolymorphic() const override {
return std::static_pointer_cast<Mapping>(_copyImpl<Mapping, AstMapping>());
virtual std::shared_ptr<Object> copyPolymorphic() const override {
return std::static_pointer_cast<Mapping>(copyImpl<Mapping, AstMapping>());
}

/**
Expand All @@ -415,7 +415,7 @@ class Mapping : public Object {
@throws std::runtime_error if this mapping is not a compound mapping.
*/
template <typename Class>
std::shared_ptr<Class> _decompose(int i, bool copy) const;
std::shared_ptr<Class> decompose(int i, bool copy) const;

private:
/**
Expand Down
6 changes: 3 additions & 3 deletions include/astshim/MathMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ class MathMap : public Mapping {
MathMap &operator=(MathMap &&) = default;

/// Return a deep copy of this object.
std::shared_ptr<MathMap> copy() const { return std::static_pointer_cast<MathMap>(_copyPolymorphic()); }
std::shared_ptr<MathMap> copy() const { return std::static_pointer_cast<MathMap>(copyPolymorphic()); }

/**
Get @ref MathMap_Seed "Seed": random number seed
Expand All @@ -404,8 +404,8 @@ class MathMap : public Mapping {
bool getSimpIF() const { return getB("SimpIF"); }

protected:
virtual std::shared_ptr<Object> _copyPolymorphic() const override {
return _copyImpl<MathMap, AstMathMap>();
virtual std::shared_ptr<Object> copyPolymorphic() const override {
return copyImpl<MathMap, AstMathMap>();
}

/// Construct a MathMap from a raw AST pointer
Expand Down
6 changes: 3 additions & 3 deletions include/astshim/MatrixMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ class MatrixMap : public Mapping {

/// Return a deep copy of this object.
std::shared_ptr<MatrixMap> copy() const {
return std::static_pointer_cast<MatrixMap>(_copyPolymorphic());
return std::static_pointer_cast<MatrixMap>(copyPolymorphic());
}

protected:
virtual std::shared_ptr<Object> _copyPolymorphic() const override {
return _copyImpl<MatrixMap, AstMatrixMap>();
virtual std::shared_ptr<Object> copyPolymorphic() const override {
return copyImpl<MatrixMap, AstMatrixMap>();
}

/// Construct a MatrixMap from a raw AST pointer
Expand Down
6 changes: 3 additions & 3 deletions include/astshim/NormMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ class NormMap : public Mapping {
NormMap &operator=(NormMap &&) = default;

/// Return a deep copy of this object.
std::shared_ptr<NormMap> copy() const { return std::static_pointer_cast<NormMap>(_copyPolymorphic()); }
std::shared_ptr<NormMap> copy() const { return std::static_pointer_cast<NormMap>(copyPolymorphic()); }

protected:
virtual std::shared_ptr<Object> _copyPolymorphic() const override {
return _copyImpl<NormMap, AstNormMap>();
virtual std::shared_ptr<Object> copyPolymorphic() const override {
return copyImpl<NormMap, AstNormMap>();
}

/// Construct a NormMap from a raw AST pointer
Expand Down
32 changes: 16 additions & 16 deletions include/astshim/Object.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class Object {
static std::shared_ptr<Class> fromAstObject(AstObject *rawObj, bool copy);

/// Return a deep copy of this object.
std::shared_ptr<Object> copy() const { return std::static_pointer_cast<Object>(_copyPolymorphic()); }
std::shared_ptr<Object> copy() const { return std::static_pointer_cast<Object>(copyPolymorphic()); }

/**
Clear the values of a specified set of attributes for an Object.
Expand Down Expand Up @@ -274,16 +274,6 @@ class Object {
}
}

/**
Given a bare AST object pointer return a shared pointer to an ast::Object of the correct type

The returned object takes ownership of the pointer. This is almost always what you want,
for instance astDecompose returns shallow copies of the internal pointers.

@param[in] rawObj A bare AST object pointer
*/
static std::shared_ptr<Object> _basicFromAstObject(AstObject *rawObj);

/**
Functor to make an astshim instance from a raw AST pointer of the corresponding type.

Expand All @@ -298,10 +288,10 @@ class Object {
/**
Implementation of deep copy

Should be called to implement _copyPolymorphic by all derived classes.
Should be called to implement copyPolymorphic by all derived classes.
*/
template <typename T, typename AstT>
std::shared_ptr<T> _copyImpl() const {
std::shared_ptr<T> copyImpl() const {
auto *rawptr = reinterpret_cast<AstT *>(astCopy(getRawPtr()));
auto retptr = std::shared_ptr<T>(new T(rawptr));
assertOK();
Expand All @@ -313,14 +303,14 @@ class Object {

Each subclass must override this method. The standard implementation is:
```
return _copyImpl<astshim_class, ast_class>();
return copyImpl<astshim_class, ast_class>();
```
for example @ref Frame implements this as:
```
return _copyImpl<Frame, AstFrame>();
return copyImpl<Frame, AstFrame>();
```
*/
virtual std::shared_ptr<Object> _copyPolymorphic() const = 0;
virtual std::shared_ptr<Object> copyPolymorphic() const = 0;

/**
Get the value of an attribute as a bool
Expand Down Expand Up @@ -496,6 +486,16 @@ class Object {
}

private:
/**
Given a bare AST object pointer return a shared pointer to an ast::Object of the correct type

The returned object takes ownership of the pointer. This is almost always what you want,
for instance astDecompose returns shallow copies of the internal pointers.

@param[in] rawObj A bare AST object pointer
*/
static std::shared_ptr<Object> _basicFromAstObject(AstObject *rawObj);

ObjectPtr _objPtr;
};

Expand Down
6 changes: 3 additions & 3 deletions include/astshim/ParallelMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@ class ParallelMap : public CmpMap {

/// Return a deep copy of this object.
std::shared_ptr<ParallelMap> copy() const {
return std::static_pointer_cast<ParallelMap>(_copyPolymorphic());
return std::static_pointer_cast<ParallelMap>(copyPolymorphic());
}

protected:
virtual std::shared_ptr<Object> _copyPolymorphic() const override {
return _copyImpl<ParallelMap, AstCmpMap>();
virtual std::shared_ptr<Object> copyPolymorphic() const override {
return copyImpl<ParallelMap, AstCmpMap>();
}

/// Construct a ParallelMap from a raw AST pointer
Expand Down
6 changes: 3 additions & 3 deletions include/astshim/PcdMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class PcdMap : public Mapping {
PcdMap &operator=(PcdMap &&) = default;

/// Return a deep copy of this object.
std::shared_ptr<PcdMap> copy() const { return std::static_pointer_cast<PcdMap>(_copyPolymorphic()); }
std::shared_ptr<PcdMap> copy() const { return std::static_pointer_cast<PcdMap>(copyPolymorphic()); }

/// Get @ref PcdMap_Disco "Disco": pincushion/barrel distortion coefficient
double getDisco() const { return getD("Disco"); };
Expand All @@ -113,8 +113,8 @@ class PcdMap : public Mapping {
}

protected:
virtual std::shared_ptr<Object> _copyPolymorphic() const override {
return _copyImpl<PcdMap, AstPcdMap>();
virtual std::shared_ptr<Object> copyPolymorphic() const override {
return copyImpl<PcdMap, AstPcdMap>();
}

/// Construct a PcdMap from a raw AST pointer
Expand Down
6 changes: 3 additions & 3 deletions include/astshim/PermMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ class PermMap : public Mapping {
PermMap &operator=(PermMap &&) = default;

/// Return a deep copy of this object.
std::shared_ptr<PermMap> copy() const { return std::static_pointer_cast<PermMap>(_copyPolymorphic()); }
std::shared_ptr<PermMap> copy() const { return std::static_pointer_cast<PermMap>(copyPolymorphic()); }

protected:
virtual std::shared_ptr<Object> _copyPolymorphic() const override {
return _copyImpl<PermMap, AstPermMap>();
virtual std::shared_ptr<Object> copyPolymorphic() const override {
return copyImpl<PermMap, AstPermMap>();
}

/// Construct a PermMap from a raw AST pointer
Expand Down
6 changes: 3 additions & 3 deletions include/astshim/PolyMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class PolyMap : public Mapping {
PolyMap &operator=(PolyMap &&) = default;

/// Return a deep copy of this object.
std::shared_ptr<PolyMap> copy() const { return std::static_pointer_cast<PolyMap>(_copyPolymorphic()); }
std::shared_ptr<PolyMap> copy() const { return std::static_pointer_cast<PolyMap>(copyPolymorphic()); }

/// Get @ref PolyMap_IterInverse "IterInverse": does this provide an iterative inverse transformation?
bool getIterInverse() const { return getB("IterInverse"); }
Expand Down Expand Up @@ -224,8 +224,8 @@ class PolyMap : public Mapping {
std::vector<double> const &ubnd) const;

protected:
virtual std::shared_ptr<Object> _copyPolymorphic() const override {
return _copyImpl<PolyMap, AstPolyMap>();
virtual std::shared_ptr<Object> copyPolymorphic() const override {
return copyImpl<PolyMap, AstPolyMap>();
}

/// Construct a PolyMap from an raw AST pointer
Expand Down