Skip to content

Commit

Permalink
Cleanup: Explicit Destructors, Override
Browse files Browse the repository at this point in the history
override implies virtual, add more destructors to classes, add
default where appropriate.
  • Loading branch information
ax3l committed Dec 13, 2019
1 parent 7d5b0ce commit 3ffa5a9
Show file tree
Hide file tree
Showing 23 changed files with 26 additions and 43 deletions.
2 changes: 1 addition & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Future consideration: cppcoreguidelines-*,clang-analyzer-*,google-*,hicpp-*,llvm-*,misc-*,modernize-*,readability-*,-clang-diagnostic-unused-command-line-argument,-*-namespace-comment*,-*-braces-around-statements,-google-readability-todo,-readability-inconsistent-declaration-parameter-name,-readability-named-parameter
# FIXME: all performance-* reports
# FIXME: all cert-* reports
Checks: -*,bugprone-*,cppcoreguidelines-slicing,mpi-*,readability-non-const-parameter,modernize-use-override
Checks: -*,bugprone-*,cppcoreguidelines-slicing,mpi-*,readability-non-const-parameter,modernize-use-override,modernize-use-equals-default
HeaderFilterRegex: '((^(?!\/share\/openPMD\/).*)*include\/openPMD\/.+\.hpp|src\/^(?!binding).+\.cpp$)'
7 changes: 5 additions & 2 deletions include/openPMD/IO/ADIOS/ADIOS2IOHandler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class ADIOS2IOHandlerImpl
explicit ADIOS2IOHandlerImpl( AbstractIOHandler * );


~ADIOS2IOHandlerImpl( ) override;
~ADIOS2IOHandlerImpl( ) override = default;

std::future< void > flush( ) override;

Expand Down Expand Up @@ -641,7 +641,10 @@ friend class ADIOS2IOHandlerImpl;
ADIOS2IOHandlerImpl m_impl;

public:
~ADIOS2IOHandler( ) override;
~ADIOS2IOHandler( ) override
{
this->flush( );
}

#else
public:
Expand Down
2 changes: 1 addition & 1 deletion include/openPMD/IO/AbstractFilePosition.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ namespace openPMD
class AbstractFilePosition
{
public:
virtual ~AbstractFilePosition() { }
virtual ~AbstractFilePosition() = default;
}; // AbstractFilePosition
} // openPMD
2 changes: 1 addition & 1 deletion include/openPMD/IO/DummyIOHandler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace openPMD
{
public:
DummyIOHandler(std::string, AccessType);
~DummyIOHandler();
~DummyIOHandler() override = default;

/** No-op consistent with the IOHandler interface to enable library use without IO.
*/
Expand Down
2 changes: 1 addition & 1 deletion include/openPMD/IO/HDF5/HDF5IOHandlerImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace openPMD
{
public:
HDF5IOHandlerImpl(AbstractIOHandler*);
virtual ~HDF5IOHandlerImpl();
~HDF5IOHandlerImpl() override;

void createFile(Writable*, Parameter< Operation::CREATE_FILE > const&) override;
void createPath(Writable*, Parameter< Operation::CREATE_PATH > const&) override;
Expand Down
2 changes: 1 addition & 1 deletion include/openPMD/IO/HDF5/ParallelHDF5IOHandlerImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace openPMD
{
public:
ParallelHDF5IOHandlerImpl(AbstractIOHandler*, MPI_Comm);
virtual ~ParallelHDF5IOHandlerImpl();
~ParallelHDF5IOHandlerImpl() override;

MPI_Comm m_mpiComm;
MPI_Info m_mpiInfo;
Expand Down
1 change: 1 addition & 0 deletions include/openPMD/Mesh.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class Mesh : public BaseRecord< MeshRecordComponent >
public:
Mesh(Mesh const&) = default;
Mesh& operator=(Mesh const&) = default;
~Mesh() override = default;

/** @brief Enumerated datatype for the geometry of the mesh.
*
Expand Down
3 changes: 2 additions & 1 deletion include/openPMD/ParticlePatches.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ namespace openPMD

public:
size_t numPatches() const;
~ParticlePatches() override = default;

private:
ParticlePatches();
ParticlePatches() = default;
void read();
}; // ParticlePatches

Expand Down
2 changes: 1 addition & 1 deletion include/openPMD/ParticleSpecies.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class ParticleSpecies : public Container< Record >
ParticlePatches particlePatches;

private:
ParticleSpecies();
ParticleSpecies() = default;

void read();
void flush(std::string const &) override;
Expand Down
6 changes: 3 additions & 3 deletions include/openPMD/Record.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ class Record : public BaseRecord< RecordComponent >
friend class ParticleSpecies;

public:
Record(Record const&);
Record& operator=(Record const&);
~Record() override;
Record(Record const&) = default;
Record& operator=(Record const&) = default;
~Record() override = default;

Record& setUnitDimension(std::map< UnitDimension, double > const&);

Expand Down
3 changes: 1 addition & 2 deletions include/openPMD/backend/BaseRecord.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,12 @@ class BaseRecord : public Container< T_elem >

protected:
BaseRecord();

void readBase();

std::shared_ptr< bool > m_containsScalar;

private:
virtual void flush(std::string const&) final;
void flush(std::string const&) final;
virtual void flush_impl(std::string const&) = 0;
virtual void read() = 0;
}; //BaseRecord
Expand Down
3 changes: 1 addition & 2 deletions include/openPMD/backend/BaseRecordComponent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ class BaseRecordComponent : public Attributable
class Container;

public:
virtual ~BaseRecordComponent()
{ }
~BaseRecordComponent() override = default;

double unitSI() const;

Expand Down
2 changes: 1 addition & 1 deletion include/openPMD/backend/Container.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class Container : public Attributable
using const_iterator = typename InternalContainer::const_iterator;

Container(Container const&) = default;
virtual ~Container() { }
virtual ~Container() = default;

iterator begin() noexcept { return m_container->begin(); }
const_iterator begin() const noexcept { return m_container->begin(); }
Expand Down
2 changes: 2 additions & 0 deletions include/openPMD/backend/MeshRecordComponent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ class MeshRecordComponent : public RecordComponent
void read() override;

public:
~MeshRecordComponent() override = default;

template< typename T >
std::vector< T > position() const;
template< typename T >
Expand Down
3 changes: 2 additions & 1 deletion include/openPMD/backend/PatchRecord.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ class PatchRecord : public BaseRecord< PatchRecordComponent >

public:
PatchRecord& setUnitDimension(std::map< UnitDimension, double > const&);
~PatchRecord() override = default;

private:
PatchRecord();
PatchRecord() = default;

void flush_impl(std::string const&) override;
void read() override;
Expand Down
4 changes: 2 additions & 2 deletions include/openPMD/backend/Writable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class AbstractIOHandlerImplCommon;
* - whether the logical object has been modified compared
* to last persistent state
*/
class Writable
class Writable final
{
friend class Attributable;
template< typename T_elem >
Expand Down Expand Up @@ -81,7 +81,7 @@ class Writable

public:
Writable(Attributable* = nullptr);
virtual ~Writable();
~Writable() = default;

OPENPMD_private:
std::shared_ptr< AbstractFilePosition > abstractFilePosition;
Expand Down
11 changes: 0 additions & 11 deletions src/IO/ADIOS/ADIOS2IOHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,6 @@ ADIOS2IOHandlerImpl::ADIOS2IOHandlerImpl( AbstractIOHandler * handler )
{
}

ADIOS2IOHandlerImpl::~ADIOS2IOHandlerImpl( )
{
this->flush( );
}

std::future< void > ADIOS2IOHandlerImpl::flush( )
{
auto res = AbstractIOHandlerImpl::flush( );
Expand Down Expand Up @@ -1333,12 +1328,6 @@ ADIOS2IOHandler::ADIOS2IOHandler( std::string path, AccessType at )
{
}


ADIOS2IOHandler::~ADIOS2IOHandler( )
{
this->flush( );
}

std::future< void > ADIOS2IOHandler::flush( )
{
return m_impl.flush( );
Expand Down
2 changes: 0 additions & 2 deletions src/IO/DummyIOHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ namespace openPMD
: AbstractIOHandler(std::move(path), at)
{ }

DummyIOHandler::~DummyIOHandler() = default;

void DummyIOHandler::enqueue(IOTask const&)
{ }

Expand Down
1 change: 0 additions & 1 deletion src/ParticlePatches.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

namespace openPMD
{
ParticlePatches::ParticlePatches() = default;

size_t
ParticlePatches::numPatches() const
Expand Down
1 change: 0 additions & 1 deletion src/ParticleSpecies.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

namespace openPMD
{
ParticleSpecies::ParticleSpecies() = default;

void
ParticleSpecies::read()
Expand Down
4 changes: 0 additions & 4 deletions src/Record.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ Record::Record()
setTimeOffset(0.f);
}

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

Record&
Record::setUnitDimension(std::map< UnitDimension, double > const& udim)
{
Expand Down
2 changes: 0 additions & 2 deletions src/backend/PatchRecord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ PatchRecord::setUnitDimension(std::map< UnitDimension, double > const& udim)
return *this;
}

PatchRecord::PatchRecord() = default;

void
PatchRecord::flush_impl(std::string const& path)
{
Expand Down
2 changes: 0 additions & 2 deletions src/backend/Writable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,4 @@ Writable::Writable(Attributable* a)
written{false}
{ }

Writable::~Writable() = default;

} // openPMD

0 comments on commit 3ffa5a9

Please sign in to comment.