From 04f6fcd34b4744e2303262db3136c3097e0091b6 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 3 Mar 2019 14:30:27 +0000 Subject: More clang tidy fixes --- slicer/slicer/modelParts.h | 53 +++++++++++++++++++++------------------ slicer/slicer/modelPartsTypes.cpp | 2 +- slicer/slicer/modelPartsTypes.h | 2 +- slicer/slicer/serializer.h | 26 ++++++++++++++----- slicer/slicer/slicer.h | 4 +-- 5 files changed, 53 insertions(+), 34 deletions(-) diff --git a/slicer/slicer/modelParts.h b/slicer/slicer/modelParts.h index 9b7d886..9d6384e 100644 --- a/slicer/slicer/modelParts.h +++ b/slicer/slicer/modelParts.h @@ -65,16 +65,14 @@ namespace Slicer { class ModelPartForRootBase; class HookCommon; - typedef std::shared_ptr ModelPartPtr; - typedef std::shared_ptr ModelPartForRootPtr; - typedef std::unique_ptr HookCommonPtr; - typedef Ice::optional TypeId; - - typedef std::function ChildHandler; - - typedef std::function ClassRef; - typedef std::function HookFilter; - typedef std::list Metadata; + using ModelPartPtr = std::shared_ptr; + using ModelPartForRootPtr = std::shared_ptr; + using HookCommonPtr = std::unique_ptr; + using TypeId = Ice::optional; + using ChildHandler = std::function; + using ClassRef = std::function; + using HookFilter = std::function; + using Metadata = std::list; DLL_PUBLIC extern const Metadata emptyMetadata; enum ModelPartType { @@ -93,13 +91,13 @@ namespace Slicer { class DLL_PUBLIC ChildRef { public: - ChildRef(); - ChildRef(ModelPartPtr); - ChildRef(ModelPartPtr, const Metadata &); + explicit ChildRef(); + explicit ChildRef(ModelPartPtr); + explicit ChildRef(ModelPartPtr, const Metadata &); ModelPartPtr Child() const; const Metadata & ChildMetaData() const; - operator bool() const; + explicit operator bool() const; private: ModelPartPtr mpp; @@ -108,7 +106,7 @@ namespace Slicer { class DLL_PUBLIC HookCommon { public: - HookCommon(std::string); + explicit HookCommon(std::string); bool filter(const HookFilter & flt); void apply(const ChildHandler & ch, const ModelPartPtr & modelPart); @@ -124,8 +122,15 @@ namespace Slicer { class DLL_PUBLIC ModelPart : public std::enable_shared_from_this { public: + ModelPart() = default; + ModelPart(const ModelPart &) = delete; + ModelPart(ModelPart &&) = delete; + virtual ~ModelPart() = default; + ModelPart & operator=(const ModelPart &) = delete; + ModelPart & operator=(ModelPart &&) = delete; + template static ModelPartPtr CreateFor(); template @@ -155,24 +160,24 @@ namespace Slicer { template class DLL_PUBLIC ModelPartModel { protected: - ModelPartModel() : Model(nullptr) { } - ModelPartModel(T * m) : Model(m) { } + explicit ModelPartModel() : Model(nullptr) { } + explicit ModelPartModel(T * m) : Model(m) { } T * Model; }; class DLL_PUBLIC ModelPartForRootBase : public ModelPart { public: - ModelPartForRootBase(ModelPartPtr mp); + explicit ModelPartForRootBase(ModelPartPtr mp); virtual const std::string & GetRootName() const = 0; - virtual ChildRef GetAnonChildRef(const HookFilter &) override; - virtual ChildRef GetChildRef(const std::string & name, const HookFilter &, bool matchCase = true) override; - virtual void OnEachChild(const ChildHandler & ch) override; - virtual ModelPartType GetType() const override; - virtual bool IsOptional() const override; + ChildRef GetAnonChildRef(const HookFilter &) override; + ChildRef GetChildRef(const std::string & name, const HookFilter &, bool matchCase = true) override; + void OnEachChild(const ChildHandler & ch) override; + ModelPartType GetType() const override; + bool IsOptional() const override; virtual void Write(::Ice::OutputStream &) const = 0; virtual void Read(::Ice::InputStream &) = 0; - virtual ModelPartPtr GetContainedModelPart() override; + ModelPartPtr GetContainedModelPart() override; ModelPartPtr mp; }; diff --git a/slicer/slicer/modelPartsTypes.cpp b/slicer/slicer/modelPartsTypes.cpp index ac95164..faad404 100644 --- a/slicer/slicer/modelPartsTypes.cpp +++ b/slicer/slicer/modelPartsTypes.cpp @@ -267,7 +267,7 @@ namespace Slicer { ModelPartType ModelPartForStreamBase::GetType() const { return mpt_Sequence; } bool ModelPartForStreamBase::HasValue() const { return true; } // Stream Roots - ModelPartForStreamRootBase::ModelPartForStreamRootBase(ModelPartPtr mp) : ModelPartForRootBase(std::move(mp)) { } + ModelPartForStreamRootBase::ModelPartForStreamRootBase(const ModelPartPtr & mp) : ModelPartForRootBase(mp) { } // NOLINTNEXTLINE(hicpp-no-array-decay) void ModelPartForStreamRootBase::Write(Ice::OutputStream&) const { throw InvalidStreamOperation(__FUNCTION__); } // NOLINTNEXTLINE(hicpp-no-array-decay) diff --git a/slicer/slicer/modelPartsTypes.h b/slicer/slicer/modelPartsTypes.h index 2ce204e..3c69f76 100644 --- a/slicer/slicer/modelPartsTypes.h +++ b/slicer/slicer/modelPartsTypes.h @@ -351,7 +351,7 @@ namespace Slicer { class DLL_PUBLIC ModelPartForStreamRootBase : public ModelPartForRootBase { public: - ModelPartForStreamRootBase(ModelPartPtr mp); + ModelPartForStreamRootBase(const ModelPartPtr & mp); virtual void Write(Ice::OutputStream&) const override; virtual void Read(Ice::InputStream&) override; diff --git a/slicer/slicer/serializer.h b/slicer/slicer/serializer.h index 857fa65..73d4617 100644 --- a/slicer/slicer/serializer.h +++ b/slicer/slicer/serializer.h @@ -9,24 +9,38 @@ namespace Slicer { class DLL_PUBLIC Serializer { public: + Serializer() = default; + Serializer(const Serializer &) = delete; + Serializer(Serializer &&) = delete; + virtual ~Serializer() = default; + Serializer & operator=(const Serializer &) = delete; + Serializer & operator=(Serializer &&) = delete; + virtual void Serialize(ModelPartForRootPtr) = 0; }; - typedef std::shared_ptr SerializerPtr; + using SerializerPtr = std::shared_ptr; class DLL_PUBLIC Deserializer { public: + Deserializer() = default; + Deserializer(const Deserializer &) = delete; + Deserializer(Deserializer &&) = delete; + virtual ~Deserializer() = default; + Deserializer & operator=(const Deserializer &) = delete; + Deserializer & operator=(Deserializer &&) = delete; + virtual void Deserialize(ModelPartForRootPtr) = 0; }; - typedef std::shared_ptr DeserializerPtr; + using DeserializerPtr = std::shared_ptr; - typedef AdHoc::Factory StreamSerializerFactory; - typedef AdHoc::Factory StreamDeserializerFactory; - typedef AdHoc::Factory FileSerializerFactory; - typedef AdHoc::Factory FileDeserializerFactory; + using StreamSerializerFactory = AdHoc::Factory; + using StreamDeserializerFactory = AdHoc::Factory; + using FileSerializerFactory = AdHoc::Factory; + using FileDeserializerFactory = AdHoc::Factory; } #endif diff --git a/slicer/slicer/slicer.h b/slicer/slicer/slicer.h index 7d6f381..16d5a46 100644 --- a/slicer/slicer/slicer.h +++ b/slicer/slicer/slicer.h @@ -7,7 +7,7 @@ namespace Slicer { template Object - DeserializeAnyWith(DeserializerPtr deserializer) + DeserializeAnyWith(const DeserializerPtr & deserializer) { Object object; deserializer->Deserialize(ModelPart::CreateRootFor(object)); @@ -23,7 +23,7 @@ namespace Slicer { template void - SerializeAnyWith(const Object & object, SerializerPtr serializer) + SerializeAnyWith(const Object & object, const SerializerPtr & serializer) { serializer->Serialize(ModelPart::CreateRootFor(object)); } -- cgit v1.2.3