Skip to content

Commit

Permalink
Add explicit constructors to afw.table.io.
Browse files Browse the repository at this point in the history
  • Loading branch information
kfindeisen committed Jan 31, 2018
1 parent 524e945 commit 83cc12c
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 10 deletions.
7 changes: 6 additions & 1 deletion include/lsst/afw/table/io/FitsReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ class FitsReader {
*/
explicit FitsReader(std::string const& persistedClassName);

FitsReader(FitsReader const &) = default;
FitsReader(FitsReader &&) = default;
FitsReader & operator=(FitsReader const &) = default;
FitsReader & operator=(FitsReader &&) = default;

/**
* Create a new Catalog by reading a FITS binary table.
*
Expand Down Expand Up @@ -132,7 +137,7 @@ class FitsReader {
*/
virtual bool usesArchive(int ioFlags) const { return false; }

virtual ~FitsReader() {}
virtual ~FitsReader() = default;

private:
static FitsReader const* _lookupFitsReader(daf::base::PropertyList const& metadata);
Expand Down
10 changes: 8 additions & 2 deletions include/lsst/afw/table/io/FitsSchemaInputMapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace io {

class FitsColumnReader {
public:
FitsColumnReader() {}
FitsColumnReader() = default;

// Neither copyable nor moveable.
FitsColumnReader(FitsColumnReader const &) = delete;
Expand All @@ -25,7 +25,7 @@ class FitsColumnReader {
virtual void readCell(BaseRecord &record, std::size_t row, fits::Fits &fits,
std::shared_ptr<InputArchive> const &archive) const = 0;

virtual ~FitsColumnReader() {}
virtual ~FitsColumnReader() = default;
};

/**
Expand Down Expand Up @@ -67,6 +67,12 @@ class FitsSchemaInputMapper {
/// Construct a mapper from a PropertyList of FITS header values, stripping recognized keys if desired.
FitsSchemaInputMapper(daf::base::PropertyList &metadata, bool stripMetadata);

FitsSchemaInputMapper(FitsSchemaInputMapper const &);
FitsSchemaInputMapper(FitsSchemaInputMapper &&);
FitsSchemaInputMapper & operator=(FitsSchemaInputMapper const &);
FitsSchemaInputMapper & operator=(FitsSchemaInputMapper &&);
~FitsSchemaInputMapper();

/**
* Set the Archive to an externally-provided one, overriding any that may have been read.
*/
Expand Down
6 changes: 6 additions & 0 deletions include/lsst/afw/table/io/FitsWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ class FitsWriter {
/// Construct from a wrapped cfitsio pointer.
explicit FitsWriter(Fits* fits, int flags) : _fits(fits), _flags(flags) {}

FitsWriter(FitsWriter const &) = default;
FitsWriter(FitsWriter &&) = default;
FitsWriter & operator=(FitsWriter const &) = default;
FitsWriter & operator=(FitsWriter &&) = default;
~FitsWriter() = default;

protected:
/// Write a table and its schema.
virtual void _writeTable(std::shared_ptr<BaseTable const> const& table, std::size_t nRows);
Expand Down
2 changes: 2 additions & 0 deletions include/lsst/afw/table/io/InputArchive.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,11 @@ class InputArchive {

/// Copy-constructor. Does not deep-copy loaded Persistables.
InputArchive(InputArchive const& other);
InputArchive(InputArchive && other);

/// Assignment. Does not deep-copy loaded Persistables.
InputArchive& operator=(InputArchive const& other);
InputArchive& operator=(InputArchive && other);

~InputArchive();

Expand Down
2 changes: 2 additions & 0 deletions include/lsst/afw/table/io/OutputArchive.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,11 @@ class OutputArchive {

/// Copy-construct an OutputArchive. Saved objects are not deep-copied.
OutputArchive(OutputArchive const& other);
OutputArchive(OutputArchive && other);

/// Assign from another OutputArchive. Saved objects are not deep-copied.
OutputArchive& operator=(OutputArchive const& other);
OutputArchive& operator=(OutputArchive && other);

// (trivial) destructor must be defined in the source for pimpl idiom.
~OutputArchive();
Expand Down
12 changes: 7 additions & 5 deletions include/lsst/afw/table/io/Persistable.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class Persistable {
/// Return true if this particular object can be persisted using afw::table::io.
virtual bool isPersistable() const { return false; }

virtual ~Persistable() {}
virtual ~Persistable() = default;

protected:
// convenient for derived classes not in afw::table::io
Expand Down Expand Up @@ -133,11 +133,13 @@ class Persistable {
*/
virtual void write(OutputArchiveHandle& handle) const;

Persistable() {}
Persistable() = default;

Persistable(Persistable const& other) {}
Persistable(Persistable const& other) = default;
Persistable(Persistable && other) = default;

void operator=(Persistable const& other) {}
Persistable & operator=(Persistable const& other) = default;
Persistable & operator=(Persistable && other) = default;

private:
friend class io::OutputArchive;
Expand Down Expand Up @@ -244,7 +246,7 @@ class PersistableFactory {
*/
static PersistableFactory const& lookup(std::string const& name, std::string const& module = "");

virtual ~PersistableFactory() {}
virtual ~PersistableFactory() = default;

// No copying
PersistableFactory(const PersistableFactory&) = delete;
Expand Down
6 changes: 6 additions & 0 deletions src/table/io/FitsSchemaInputMapper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,12 @@ FitsSchemaInputMapper::FitsSchemaInputMapper(daf::base::PropertyList &metadata,
}
}

FitsSchemaInputMapper::FitsSchemaInputMapper(FitsSchemaInputMapper const &) = default;
FitsSchemaInputMapper::FitsSchemaInputMapper(FitsSchemaInputMapper &&) = default;
FitsSchemaInputMapper & FitsSchemaInputMapper::operator=(FitsSchemaInputMapper const &) = default;
FitsSchemaInputMapper & FitsSchemaInputMapper::operator=(FitsSchemaInputMapper &&) = default;
FitsSchemaInputMapper::~FitsSchemaInputMapper() = default;

void FitsSchemaInputMapper::setArchive(std::shared_ptr<InputArchive> archive) { _impl->archive = archive; }

bool FitsSchemaInputMapper::readArchive(afw::fits::Fits &fits) {
Expand Down
6 changes: 5 additions & 1 deletion src/table/io/InputArchive.cc
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,17 @@ InputArchive::InputArchive(BaseCatalog const& index, CatalogVector const& catalo
: _impl(new Impl(index, catalogs)) {}

InputArchive::InputArchive(InputArchive const& other) : _impl(other._impl) {}
// Delegate to copy constructor for backwards compatibility
InputArchive::InputArchive(InputArchive && other) : InputArchive(other) {}

InputArchive& InputArchive::operator=(InputArchive const& other) {
_impl = other._impl;
return *this;
}
// Delegate to copy assignment for backwards compatibility
InputArchive& InputArchive::operator=(InputArchive && other) { return *this = other; }

InputArchive::~InputArchive() {}
InputArchive::~InputArchive() = default;

std::shared_ptr<Persistable> InputArchive::get(int id) const { return _impl->get(id, *this); }

Expand Down
6 changes: 5 additions & 1 deletion src/table/io/OutputArchive.cc
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,17 @@ class OutputArchive::Impl {
OutputArchive::OutputArchive() : _impl(new Impl()) {}

OutputArchive::OutputArchive(OutputArchive const &other) : _impl(other._impl) {}
// Delegate to copy constructor for backward compatibility
OutputArchive::OutputArchive(OutputArchive &&other) : OutputArchive(other) {}

OutputArchive &OutputArchive::operator=(OutputArchive const &other) {
_impl = other._impl;
return *this;
}
// Delegate to copy assignment for backward compatibility
OutputArchive &OutputArchive::operator=(OutputArchive &&other) { return *this = other; }

OutputArchive::~OutputArchive() {}
OutputArchive::~OutputArchive() = default;

int OutputArchive::put(Persistable const *obj, bool permissive) {
if (!_impl.unique()) { // copy on write
Expand Down

0 comments on commit 83cc12c

Please sign in to comment.