diff --git a/include/openPMD/Iteration.hpp b/include/openPMD/Iteration.hpp index 0b5de18b8c..e52c4a1c0b 100644 --- a/include/openPMD/Iteration.hpp +++ b/include/openPMD/Iteration.hpp @@ -112,11 +112,11 @@ namespace internal */ class Iteration : public Attributable { - template< + template < typename T, typename T_key, typename T_container, - typename T_AttributableBase > + typename T_AttributableBase> friend class Container; friend class Series; friend class WriteIterations; diff --git a/include/openPMD/RecordComponent.hpp b/include/openPMD/RecordComponent.hpp index 724e50af72..29baa433c5 100644 --- a/include/openPMD/RecordComponent.hpp +++ b/include/openPMD/RecordComponent.hpp @@ -125,15 +125,15 @@ namespace internal class RecordComponent : public BaseRecordComponent { - template< + template < typename T, typename T_key, typename T_container, - typename T_AttributableBase > + typename T_AttributableBase> friend class Container; friend class Iteration; friend class ParticleSpecies; - template< typename T_elem, typename T_RecordComponent > + template friend class BaseRecord; template friend class BaseRecordInterface; @@ -325,19 +325,19 @@ OPENPMD_protected using DataClass = internal::RecordComponentData; - RecordComponent( std::shared_ptr< DataClass > ); + RecordComponent(std::shared_ptr); - inline DataClass const & get() const + inline DataClass const &get() const { return *m_recordComponentData; } - inline DataClass & get() + inline DataClass &get() { return *m_recordComponentData; } - inline void setData( std::shared_ptr< DataClass > data ) + inline void setData(std::shared_ptr data) { m_recordComponentData = std::move(data); BaseRecordComponent::setData(m_recordComponentData); diff --git a/include/openPMD/auxiliary/TypeTraits.hpp b/include/openPMD/auxiliary/TypeTraits.hpp index 90428fe195..971fe75785 100644 --- a/include/openPMD/auxiliary/TypeTraits.hpp +++ b/include/openPMD/auxiliary/TypeTraits.hpp @@ -57,17 +57,17 @@ namespace detail template inline constexpr bool IsVector_v = detail::IsVector::value; -template< typename T > -inline constexpr bool IsArray_v = detail::IsArray< T >::value; +template +inline constexpr bool IsArray_v = detail::IsArray::value; -template< typename T, typename /* U */ > +template struct OkOr { using type = T; }; -template< typename U > -struct OkOr< void, U > +template +struct OkOr { using type = U; }; diff --git a/include/openPMD/backend/Attributable.hpp b/include/openPMD/backend/Attributable.hpp index 852e757118..b41acb60bd 100644 --- a/include/openPMD/backend/Attributable.hpp +++ b/include/openPMD/backend/Attributable.hpp @@ -107,7 +107,7 @@ namespace internal "' must not be empty!"); } - template< typename, typename > + template class BaseRecordData; } // namespace internal @@ -119,19 +119,19 @@ namespace internal class Attributable { // @todo remove unnecessary friend (wew that sounds bitter) - using A_MAP = std::map< std::string, Attribute >; - friend Writable * getWritable( Attributable * ); - template< typename T_elem, typename T_RecordComponent > + using A_MAP = std::map; + friend Writable *getWritable(Attributable *); + template friend class BaseRecord; - template< typename T_elem > + template friend class BaseRecordInterface; - template< typename, typename > + template friend class internal::BaseRecordData; - template< + template < typename T, typename T_key, typename T_container, - typename T_AttributableBase > + typename T_AttributableBase> friend class Container; template friend struct traits::GenerationPolicy; @@ -143,7 +143,7 @@ class Attributable protected: using DataClass = internal::AttributableData; - std::shared_ptr< DataClass > m_attri{ new DataClass() }; + std::shared_ptr m_attri{new DataClass()}; // Should not be called publicly, only by implementing classes Attributable(std::shared_ptr); diff --git a/include/openPMD/backend/BaseRecord.hpp b/include/openPMD/backend/BaseRecord.hpp index 1fe41ef809..868592fc4c 100644 --- a/include/openPMD/backend/BaseRecord.hpp +++ b/include/openPMD/backend/BaseRecord.hpp @@ -33,26 +33,23 @@ namespace openPMD { namespace detail { - template< typename T, typename T_AttributableBase > - using ContainerWithBase = Container< - T, - std::string, - std::map< std::string, T >, - T_AttributableBase >; + template + using ContainerWithBase = + Container, T_AttributableBase>; - template< typename T, typename T_AttributableBaseData > + template using ContainerDataWithBase = internal::ContainerData< T, std::string, - std::map< std::string, T >, - T_AttributableBaseData >; + std::map, + T_AttributableBaseData>; } // namespace detail namespace internal { - template< typename T_elem, typename T_RecordComponentData > - class BaseRecordData : - public detail::ContainerDataWithBase< T_elem, T_RecordComponentData > + template + class BaseRecordData + : public detail::ContainerDataWithBase { public: /** @@ -83,35 +80,35 @@ namespace internal * We specify the above concept by BaseRecord instead and use the * auxiliary::OkOr class template to treat the void type specially. */ -template< +template < typename T_elem_maybe_void, - typename T_RecordComponent = T_elem_maybe_void > -class BaseRecord : - public detail::ContainerWithBase< - typename auxiliary::OkOr< - T_elem_maybe_void, - BaseRecord< void, T_RecordComponent > >::type, - T_RecordComponent > + typename T_RecordComponent = T_elem_maybe_void> +class BaseRecord + : public detail::ContainerWithBase< + typename auxiliary::OkOr< + T_elem_maybe_void, + BaseRecord >::type, + T_RecordComponent> { using T_elem = typename auxiliary:: - OkOr< T_elem_maybe_void, BaseRecord< void, T_RecordComponent > >::type; - using T_container = detail::ContainerWithBase< T_elem, T_RecordComponent >; + OkOr >::type; + using T_container = detail::ContainerWithBase; friend class Iteration; friend class ParticleSpecies; friend class PatchRecord; friend class Record; friend class Mesh; - using DataClass = internal:: - BaseRecordData< T_elem, typename T_RecordComponent::DataClass >; - std::shared_ptr< DataClass > m_baseRecordData{ new DataClass() }; + using DataClass = + internal::BaseRecordData; + std::shared_ptr m_baseRecordData{new DataClass()}; - inline DataClass & get() + inline DataClass &get() { return *m_baseRecordData; } - inline DataClass const & get() const + inline DataClass const &get() const { return *m_baseRecordData; } @@ -119,12 +116,12 @@ class BaseRecord : BaseRecord(); protected: - BaseRecord( std::shared_ptr< DataClass > ); + BaseRecord(std::shared_ptr); - inline void setData( std::shared_ptr< DataClass > data ) + inline void setData(std::shared_ptr data) { - m_baseRecordData = std::move( data ); - T_container::setData( m_baseRecordData ); + m_baseRecordData = std::move(data); + T_container::setData(m_baseRecordData); } public: @@ -144,7 +141,7 @@ class BaseRecord : // this avoids object slicing operator T_RecordComponent() const { - return { m_baseRecordData }; + return {m_baseRecordData}; } virtual ~BaseRecord() = default; @@ -188,8 +185,8 @@ class BaseRecord : void datasetDefined() override; private: - void flush( std::string const & ) final; - virtual void flush_impl( std::string const & ) = 0; + void flush(std::string const &) final; + virtual void flush_impl(std::string const &) = 0; virtual void read() = 0; /** @@ -207,8 +204,8 @@ class BaseRecord : namespace internal { - template< typename T_elem, typename T_RecordComponentData > - BaseRecordData< T_elem, T_RecordComponentData >::BaseRecordData() + template + BaseRecordData::BaseRecordData() { Attributable impl{{this, [](auto const *) {}}}; impl.setAttribute( @@ -217,22 +214,21 @@ namespace internal } } // namespace internal -template< typename T_elem, typename T_RecordComponent > -BaseRecord< T_elem, T_RecordComponent >::BaseRecord() : T_container{ nullptr } +template +BaseRecord::BaseRecord() : T_container{nullptr} { - T_container::setData( m_baseRecordData ); + T_container::setData(m_baseRecordData); } -template< typename T_elem, typename T_RecordComponent > -BaseRecord< T_elem, T_RecordComponent >::BaseRecord( - std::shared_ptr< DataClass > data ) - : T_container{ data }, m_baseRecordData{ std::move( data ) } -{ -} +template +BaseRecord::BaseRecord( + std::shared_ptr data) + : T_container{data}, m_baseRecordData{std::move(data)} +{} -template< typename T_elem, typename T_RecordComponent > +template inline auto -BaseRecord< T_elem, T_RecordComponent >::operator[]( key_type const & key ) +BaseRecord::operator[](key_type const &key) -> mapped_type & { auto it = this->find(key); @@ -240,25 +236,24 @@ BaseRecord< T_elem, T_RecordComponent >::operator[]( key_type const & key ) return it->second; else { - bool const keyScalar = ( key == RecordComponent::SCALAR ); - if( ( keyScalar && !T_container::empty() && !scalar() ) || - ( scalar() && !keyScalar ) ) + bool const keyScalar = (key == RecordComponent::SCALAR); + if ((keyScalar && !T_container::empty() && !scalar()) || + (scalar() && !keyScalar)) throw std::runtime_error( "A scalar component can not be contained at " "the same time as one or more regular components."); - if( keyScalar ) + if (keyScalar) { datasetDefined(); } - mapped_type & ret = keyScalar ? *this : T_container::operator[]( key ); + mapped_type &ret = keyScalar ? *this : T_container::operator[](key); return ret; } } -template< typename T_elem, typename T_RecordComponent > -inline auto -BaseRecord< T_elem, T_RecordComponent >::operator[]( key_type && key ) +template +inline auto BaseRecord::operator[](key_type &&key) -> mapped_type & { auto it = this->find(key); @@ -266,32 +261,31 @@ BaseRecord< T_elem, T_RecordComponent >::operator[]( key_type && key ) return it->second; else { - bool const keyScalar = ( key == RecordComponent::SCALAR ); - if( ( keyScalar && !T_container::empty() && !scalar() ) || - ( scalar() && !keyScalar ) ) + bool const keyScalar = (key == RecordComponent::SCALAR); + if ((keyScalar && !T_container::empty() && !scalar()) || + (scalar() && !keyScalar)) throw std::runtime_error( "A scalar component can not be contained at " "the same time as one or more regular components."); - if( keyScalar ) + if (keyScalar) { datasetDefined(); } - mapped_type & ret = - keyScalar ? *this : T_container::operator[]( std::move( key ) ); + mapped_type &ret = + keyScalar ? *this : T_container::operator[](std::move(key)); return ret; } } -template< typename T_elem, typename T_RecordComponent > -inline auto -BaseRecord< T_elem, T_RecordComponent >::erase( key_type const & key ) +template +inline auto BaseRecord::erase(key_type const &key) -> size_type { bool const keyScalar = (key == RecordComponent::SCALAR); size_type res; - if( !keyScalar || ( keyScalar && this->at( key ).constant() ) ) - res = T_container::erase( key ); + if (!keyScalar || (keyScalar && this->at(key).constant())) + res = T_container::erase(key); else { mapped_type &rc = this->find(RecordComponent::SCALAR)->second; @@ -302,7 +296,7 @@ BaseRecord< T_elem, T_RecordComponent >::erase( key_type const & key ) this->IOHandler()->enqueue(IOTask(&rc, dDelete)); this->IOHandler()->flush(); } - res = T_container::erase( key ); + res = T_container::erase(key); } if (keyScalar) @@ -314,14 +308,14 @@ BaseRecord< T_elem, T_RecordComponent >::erase( key_type const & key ) return res; } -template< typename T_elem, typename T_RecordComponent > -inline auto BaseRecord< T_elem, T_RecordComponent >::erase( iterator res ) +template +inline auto BaseRecord::erase(iterator res) -> iterator { bool const keyScalar = (res->first == RecordComponent::SCALAR); iterator ret; - if( !keyScalar || ( keyScalar && this->at( res->first ).constant() ) ) - ret = T_container::erase( res ); + if (!keyScalar || (keyScalar && this->at(res->first).constant())) + ret = T_container::erase(res); else { mapped_type &rc = this->find(RecordComponent::SCALAR)->second; @@ -332,7 +326,7 @@ inline auto BaseRecord< T_elem, T_RecordComponent >::erase( iterator res ) this->IOHandler()->enqueue(IOTask(&rc, dDelete)); this->IOHandler()->flush(); } - ret = T_container::erase( res ); + ret = T_container::erase(res); } if (keyScalar) @@ -344,22 +338,22 @@ inline auto BaseRecord< T_elem, T_RecordComponent >::erase( iterator res ) return ret; } -template< typename T_elem, typename T_RecordComponent > -inline std::array< double, 7 > -BaseRecord< T_elem, T_RecordComponent >::unitDimension() const +template +inline std::array +BaseRecord::unitDimension() const { return this->getAttribute("unitDimension") .template get >(); } -template< typename T_elem, typename T_RecordComponent > -inline bool BaseRecord< T_elem, T_RecordComponent >::scalar() const +template +inline bool BaseRecord::scalar() const { return get().m_containsScalar; } -template< typename T_elem, typename T_RecordComponent > -inline void BaseRecord< T_elem, T_RecordComponent >::readBase() +template +inline void BaseRecord::readBase() { using DT = Datatype; Parameter aRead; @@ -403,9 +397,9 @@ inline void BaseRecord< T_elem, T_RecordComponent >::readBase() "Unexpected Attribute datatype for 'timeOffset'"); } -template< typename T_elem, typename T_RecordComponent > +template inline void -BaseRecord< T_elem, T_RecordComponent >::flush( std::string const & name ) +BaseRecord::flush(std::string const &name) { if (!this->written() && this->empty()) throw std::runtime_error( @@ -418,8 +412,8 @@ BaseRecord< T_elem, T_RecordComponent >::flush( std::string const & name ) // method doesn't do it } -template< typename T_elem, typename T_RecordComponent > -inline bool BaseRecord< T_elem, T_RecordComponent >::dirtyRecursive() const +template +inline bool BaseRecord::dirtyRecursive() const { if (this->dirty()) { @@ -435,8 +429,8 @@ inline bool BaseRecord< T_elem, T_RecordComponent >::dirtyRecursive() const return false; } -template< typename T_elem, typename T_RecordComponent > -void BaseRecord< T_elem, T_RecordComponent >::datasetDefined() +template +void BaseRecord::datasetDefined() { // If the RecordComponent API of this object has been used, then the record // is a scalar one @@ -444,7 +438,7 @@ void BaseRecord< T_elem, T_RecordComponent >::datasetDefined() RecordComponent::SCALAR, // need to construct it in this line already, construction inside // emplace is impossible due to private constructors - T_RecordComponent{ m_baseRecordData } ); + T_RecordComponent{m_baseRecordData}); get().m_containsScalar = true; T_RecordComponent::datasetDefined(); } diff --git a/include/openPMD/backend/BaseRecordComponent.hpp b/include/openPMD/backend/BaseRecordComponent.hpp index d2283633db..6f7bfcd5e1 100644 --- a/include/openPMD/backend/BaseRecordComponent.hpp +++ b/include/openPMD/backend/BaseRecordComponent.hpp @@ -61,11 +61,11 @@ namespace internal class BaseRecordComponent : public Attributable { - template< + template < typename T, typename T_key, typename T_container, - typename T_AttributableBase > + typename T_AttributableBase> friend class Container; public: @@ -104,27 +104,26 @@ class BaseRecordComponent : public Attributable ChunkTable availableChunks(); protected: - std::shared_ptr< internal::BaseRecordComponentData > - m_baseRecordComponentData{ new internal::BaseRecordComponentData() }; + std::shared_ptr + m_baseRecordComponentData{new internal::BaseRecordComponentData()}; - inline internal::BaseRecordComponentData const & get() const + inline internal::BaseRecordComponentData const &get() const { return *m_baseRecordComponentData; } - inline internal::BaseRecordComponentData & get() + inline internal::BaseRecordComponentData &get() { return *m_baseRecordComponentData; } - inline void - setData( std::shared_ptr< internal::BaseRecordComponentData > data ) + inline void setData(std::shared_ptr data) { - m_baseRecordComponentData = std::move( data ); - Attributable::setData( m_baseRecordComponentData ); + m_baseRecordComponentData = std::move(data); + Attributable::setData(m_baseRecordComponentData); } - BaseRecordComponent( std::shared_ptr< internal::BaseRecordComponentData > ); + BaseRecordComponent(std::shared_ptr); virtual void datasetDefined(); diff --git a/include/openPMD/backend/Container.hpp b/include/openPMD/backend/Container.hpp index 9020b5c218..35240918e7 100644 --- a/include/openPMD/backend/Container.hpp +++ b/include/openPMD/backend/Container.hpp @@ -64,8 +64,8 @@ namespace internal template < typename T, typename T_key = std::string, - typename T_container = std::map< T_key, T >, - typename T_BaseAttributableData = AttributableData > + typename T_container = std::map, + typename T_BaseAttributableData = AttributableData> class ContainerData : public T_BaseAttributableData { public: @@ -128,8 +128,8 @@ namespace detail template < typename T, typename T_key = std::string, - typename T_container = std::map< T_key, T >, - typename T_AttributableBase = Attributable > + typename T_container = std::map, + typename T_AttributableBase = Attributable> class Container : public T_AttributableBase { static_assert( @@ -149,15 +149,15 @@ class Container : public T_AttributableBase T, T_key, T_container, - typename T_AttributableBase::DataClass >; + typename T_AttributableBase::DataClass>; using InternalContainer = T_container; - std::shared_ptr< DataClass > m_containerData{ new DataClass() }; + std::shared_ptr m_containerData{new DataClass()}; - inline void setData( std::shared_ptr< DataClass > containerData ) + inline void setData(std::shared_ptr containerData) { - m_containerData = std::move( containerData ); - T_AttributableBase::setData( m_containerData ); + m_containerData = std::move(containerData); + T_AttributableBase::setData(m_containerData); } inline InternalContainer const &container() const @@ -228,7 +228,7 @@ class Container : public T_AttributableBase */ void clear() { - if( Access::READ_ONLY == this->IOHandler()->m_frontendAccess ) + if (Access::READ_ONLY == this->IOHandler()->m_frontendAccess) throw std::runtime_error( "Can not clear a container in a read-only Series."); @@ -294,20 +294,19 @@ class Container : public T_AttributableBase return it->second; else { - if( Access::READ_ONLY == this->IOHandler()->m_frontendAccess ) + if (Access::READ_ONLY == this->IOHandler()->m_frontendAccess) { auxiliary::OutOfRangeMsg const out_of_range_msg; throw std::out_of_range(out_of_range_msg(key)); } T t = T(); - t.linkHierarchy( this->writable() ); - auto & ret = - container().insert( { key, std::move( t ) } ).first->second; + t.linkHierarchy(this->writable()); + auto &ret = container().insert({key, std::move(t)}).first->second; ret.writable().ownKeyWithinParent = - detail::keyAsString( key, this->writable().ownKeyWithinParent ); - traits::GenerationPolicy< T > gen; - gen( ret ); + detail::keyAsString(key, this->writable().ownKeyWithinParent); + traits::GenerationPolicy gen; + gen(ret); return ret; } } @@ -328,20 +327,19 @@ class Container : public T_AttributableBase return it->second; else { - if( Access::READ_ONLY == this->IOHandler()->m_frontendAccess ) + if (Access::READ_ONLY == this->IOHandler()->m_frontendAccess) { auxiliary::OutOfRangeMsg out_of_range_msg; throw std::out_of_range(out_of_range_msg(key)); } T t = T(); - t.linkHierarchy( this->writable() ); - auto & ret = - container().insert( { key, std::move( t ) } ).first->second; + t.linkHierarchy(this->writable()); + auto &ret = container().insert({key, std::move(t)}).first->second; ret.writable().ownKeyWithinParent = detail::keyAsString( - std::move( key ), this->writable().ownKeyWithinParent ); - traits::GenerationPolicy< T > gen; - gen( ret ); + std::move(key), this->writable().ownKeyWithinParent); + traits::GenerationPolicy gen; + gen(ret); return ret; } } @@ -386,7 +384,7 @@ class Container : public T_AttributableBase */ virtual size_type erase(key_type const &key) { - if( Access::READ_ONLY == this->IOHandler()->m_frontendAccess ) + if (Access::READ_ONLY == this->IOHandler()->m_frontendAccess) throw std::runtime_error( "Can not erase from a container in a read-only Series."); @@ -395,7 +393,7 @@ class Container : public T_AttributableBase { Parameter pDelete; pDelete.path = "."; - this->IOHandler()->enqueue( IOTask( &res->second, pDelete ) ); + this->IOHandler()->enqueue(IOTask(&res->second, pDelete)); this->IOHandler()->flush(); } return container().erase(key); @@ -404,7 +402,7 @@ class Container : public T_AttributableBase //! @todo why does const_iterator not work compile with pybind11? virtual iterator erase(iterator res) { - if( Access::READ_ONLY == this->IOHandler()->m_frontendAccess ) + if (Access::READ_ONLY == this->IOHandler()->m_frontendAccess) throw std::runtime_error( "Can not erase from a container in a read-only Series."); @@ -412,7 +410,7 @@ class Container : public T_AttributableBase { Parameter pDelete; pDelete.path = "."; - this->IOHandler()->enqueue( IOTask( &res->second, pDelete ) ); + this->IOHandler()->enqueue(IOTask(&res->second, pDelete)); this->IOHandler()->flush(); } return container().erase(res); @@ -431,15 +429,14 @@ class Container : public T_AttributableBase OPENPMD_protected // clang-format on - Container( std::shared_ptr< DataClass > containerData ) - : T_AttributableBase( containerData ) - , m_containerData{ std::move( containerData ) } - { - } + Container(std::shared_ptr containerData) + : T_AttributableBase(containerData) + , m_containerData{std::move(containerData)} + {} void clear_unchecked() { - if( this->written() ) + if (this->written()) throw std::runtime_error( "Clearing a written container not (yet) implemented."); @@ -448,11 +445,11 @@ OPENPMD_protected virtual void flush(std::string const &path) { - if( !this->written() ) + if (!this->written()) { Parameter pCreate; pCreate.path = path; - this->IOHandler()->enqueue( IOTask( this, pCreate ) ); + this->IOHandler()->enqueue(IOTask(this, pCreate)); } this->flushAttributes(); @@ -462,10 +459,10 @@ OPENPMD_protected OPENPMD_private // clang-format on - Container() : T_AttributableBase{ nullptr } + Container() : T_AttributableBase{nullptr} { // @todo write Attributable::setData here and in other places? - T_AttributableBase::setData( m_containerData ); + T_AttributableBase::setData(m_containerData); } }; diff --git a/include/openPMD/backend/MeshRecordComponent.hpp b/include/openPMD/backend/MeshRecordComponent.hpp index c6ba7a41a3..bcb2fb5fa8 100644 --- a/include/openPMD/backend/MeshRecordComponent.hpp +++ b/include/openPMD/backend/MeshRecordComponent.hpp @@ -28,14 +28,14 @@ namespace openPMD { class MeshRecordComponent : public RecordComponent { - template< + template < typename T, typename T_key, typename T_container, - typename T_AttributableBase > + typename T_AttributableBase> friend class Container; friend class Mesh; - template< typename, typename > + template friend class BaseRecord; private: @@ -44,10 +44,9 @@ class MeshRecordComponent : public RecordComponent MeshRecordComponent(); // parent-class constructor - MeshRecordComponent( std::shared_ptr< DataClass > data ) - : RecordComponent{ std::move( data ) } - { - } + MeshRecordComponent(std::shared_ptr data) + : RecordComponent{std::move(data)} + {} void read() override; @@ -82,8 +81,8 @@ class MeshRecordComponent : public RecordComponent * @tparam T type of the stored value * @return A reference to this RecordComponent. */ - template< typename T > - MeshRecordComponent & makeConstant( T ); + template + MeshRecordComponent &makeConstant(T); protected: void datasetDefined() override; diff --git a/include/openPMD/backend/PatchRecordComponent.hpp b/include/openPMD/backend/PatchRecordComponent.hpp index c0b830f2a7..7b323c3387 100644 --- a/include/openPMD/backend/PatchRecordComponent.hpp +++ b/include/openPMD/backend/PatchRecordComponent.hpp @@ -61,13 +61,13 @@ namespace internal */ class PatchRecordComponent : public BaseRecordComponent { - template< + template < typename T, typename T_key, typename T_container, - typename T_AttributableBase > + typename T_AttributableBase> friend class Container; - template< typename, typename > + template friend class BaseRecord; friend class ParticlePatches; friend class PatchRecord; @@ -110,7 +110,7 @@ OPENPMD_private using DataClass = internal::PatchRecordComponentData; - std::shared_ptr< DataClass > m_patchRecordComponentData{ new DataClass() }; + std::shared_ptr m_patchRecordComponentData{new DataClass()}; PatchRecordComponent(); @@ -120,17 +120,17 @@ OPENPMD_protected PatchRecordComponent(std::shared_ptr); - inline DataClass const & get() const + inline DataClass const &get() const { return *m_patchRecordComponentData; } - inline DataClass & get() + inline DataClass &get() { return *m_patchRecordComponentData; } - inline void setData( std::shared_ptr< DataClass > data ) + inline void setData(std::shared_ptr data) { m_patchRecordComponentData = std::move(data); BaseRecordComponent::setData(m_patchRecordComponentData); diff --git a/include/openPMD/backend/Writable.hpp b/include/openPMD/backend/Writable.hpp index 566f893059..dfca7b891f 100644 --- a/include/openPMD/backend/Writable.hpp +++ b/include/openPMD/backend/Writable.hpp @@ -64,15 +64,15 @@ class Writable final { friend class internal::AttributableData; friend class Attributable; - template< typename T_elem, typename T_RecordComponent > + template friend class BaseRecord; template friend class BaseRecordInterface; - template< + template < typename T, typename T_key, typename T_container, - typename T_AttributableBase > + typename T_AttributableBase> friend class Container; friend class Iteration; friend class Mesh; diff --git a/src/Mesh.cpp b/src/Mesh.cpp index 4dbfdd0c78..f52efce42a 100644 --- a/src/Mesh.cpp +++ b/src/Mesh.cpp @@ -226,8 +226,8 @@ void Mesh::flush_impl(std::string const &name) { if (scalar()) { - MeshRecordComponent & mrc = at( RecordComponent::SCALAR ); - mrc.flush( name ); + MeshRecordComponent &mrc = at(RecordComponent::SCALAR); + mrc.flush(name); IOHandler()->flush(); } else @@ -244,7 +244,7 @@ void Mesh::flush_impl(std::string const &name) { for (auto &comp : *this) { - comp.second.flush( name ); + comp.second.flush(name); } } else diff --git a/src/ParticleSpecies.cpp b/src/ParticleSpecies.cpp index 522c1fc2d1..8b00413e80 100644 --- a/src/ParticleSpecies.cpp +++ b/src/ParticleSpecies.cpp @@ -101,8 +101,8 @@ void ParticleSpecies::read() dOpen.name = record_name; IOHandler()->enqueue(IOTask(&r, dOpen)); IOHandler()->flush(); - internal::EraseStaleEntries< Record & > scalarMap( r ); - RecordComponent & rc = scalarMap[ RecordComponent::SCALAR ]; + internal::EraseStaleEntries scalarMap(r); + RecordComponent &rc = scalarMap[RecordComponent::SCALAR]; rc.parent() = r.parent(); IOHandler()->enqueue(IOTask(&rc, dOpen)); IOHandler()->flush(); diff --git a/src/backend/BaseRecordComponent.cpp b/src/backend/BaseRecordComponent.cpp index 8aaa075610..aac761a21b 100644 --- a/src/backend/BaseRecordComponent.cpp +++ b/src/backend/BaseRecordComponent.cpp @@ -25,12 +25,12 @@ namespace openPMD { double BaseRecordComponent::unitSI() const { - return getAttribute( "unitSI" ).get< double >(); + return getAttribute("unitSI").get(); } -BaseRecordComponent & BaseRecordComponent::resetDatatype( Datatype d ) +BaseRecordComponent &BaseRecordComponent::resetDatatype(Datatype d) { - if( written() ) + if (written()) throw std::runtime_error( "A Records Datatype can not (yet) be changed after it has been " "written."); @@ -59,25 +59,23 @@ ChunkTable BaseRecordComponent::availableChunks() return ChunkTable{{std::move(offset), rc.m_dataset.extent}}; } containingIteration().open(); - Parameter< Operation::AVAILABLE_CHUNKS > param; - IOTask task( this, param ); - IOHandler()->enqueue( task ); + Parameter param; + IOTask task(this, param); + IOHandler()->enqueue(task); IOHandler()->flush(); - return std::move( *param.chunks ); + return std::move(*param.chunks); } BaseRecordComponent::BaseRecordComponent( - std::shared_ptr< internal::BaseRecordComponentData > data ) - : Attributable{ data }, m_baseRecordComponentData{ std::move( data ) } -{ -} + std::shared_ptr data) + : Attributable{data}, m_baseRecordComponentData{std::move(data)} +{} -BaseRecordComponent::BaseRecordComponent() : Attributable{ nullptr } +BaseRecordComponent::BaseRecordComponent() : Attributable{nullptr} { Attributable::setData(m_baseRecordComponentData); } void BaseRecordComponent::datasetDefined() -{ -} +{} } // namespace openPMD diff --git a/src/backend/MeshRecordComponent.cpp b/src/backend/MeshRecordComponent.cpp index 9a69eba4c5..aab33456ce 100644 --- a/src/backend/MeshRecordComponent.cpp +++ b/src/backend/MeshRecordComponent.cpp @@ -23,8 +23,7 @@ namespace openPMD { MeshRecordComponent::MeshRecordComponent() : RecordComponent() -{ -} +{} void MeshRecordComponent::read() { @@ -62,7 +61,7 @@ MeshRecordComponent &MeshRecordComponent::setPosition(std::vector pos) void MeshRecordComponent::datasetDefined() { - setPosition( std::vector< double >{ 0 } ); + setPosition(std::vector{0}); RecordComponent::datasetDefined(); } diff --git a/src/backend/PatchRecord.cpp b/src/backend/PatchRecord.cpp index 091ebb912f..7c076cb7d8 100644 --- a/src/backend/PatchRecord.cpp +++ b/src/backend/PatchRecord.cpp @@ -40,11 +40,11 @@ void PatchRecord::flush_impl(std::string const &path) { if (this->find(RecordComponent::SCALAR) == this->end()) { - if( IOHandler()->m_frontendAccess != Access::READ_ONLY ) + if (IOHandler()->m_frontendAccess != Access::READ_ONLY) T_container::flush( - path ); // warning (clang-tidy-10): bugprone-parent-virtual-call - for( auto & comp : *this ) - comp.second.flush( comp.first ); + path); // warning (clang-tidy-10): bugprone-parent-virtual-call + for (auto &comp : *this) + comp.second.flush(comp.first); } else this->operator[](RecordComponent::SCALAR).flush(path);