From 9533a86648c3fb3646c2619e27c5d9ae84878628 Mon Sep 17 00:00:00 2001 From: azn Date: Wed, 17 Dec 2014 11:17:28 +0300 Subject: [PATCH] 0025617: Avoid classes with a copy constructor and the default destructor or assignment operator Removed useless user-defined copy constructors and assignment operators in BOPCol_NCVector, NCollection_Mat4, NCollection_Vec* User-defined assignment operator matching copy constructor added in NCollection_StdAllocator. Class VrmlData_DataMapOfShapeAppearance redefined as simple typedef to NCollection_DataMap<>. --- src/BOPCol/BOPCol_NCVector.hxx | 4 -- src/NCollection/NCollection_Mat4.hxx | 15 ------- src/NCollection/NCollection_StdAllocator.hxx | 21 +++++----- src/NCollection/NCollection_Vec2.hxx | 15 ------- src/NCollection/NCollection_Vec3.hxx | 13 ------ src/NCollection/NCollection_Vec4.hxx | 13 ------ .../VrmlData_DataMapOfShapeAppearance.hxx | 40 +------------------ src/VrmlData/VrmlData_Group.hxx | 2 +- src/VrmlData/VrmlData_Scene.hxx | 2 +- 9 files changed, 15 insertions(+), 110 deletions(-) diff --git a/src/BOPCol/BOPCol_NCVector.hxx b/src/BOPCol/BOPCol_NCVector.hxx index 73ad5e4a37..f3db4b5902 100755 --- a/src/BOPCol/BOPCol_NCVector.hxx +++ b/src/BOPCol/BOPCol_NCVector.hxx @@ -33,10 +33,6 @@ template class BOPCol_NCVector : NCollection_Vector(theIncrement, theAlloc) {} // - BOPCol_NCVector(const BOPCol_NCVector& theOther) - : NCollection_Vector(theOther) - {} - // Type& Append1 () { Type& anAppended = *(Type*)this->expandV (this->myLength); diff --git a/src/NCollection/NCollection_Mat4.hxx b/src/NCollection/NCollection_Mat4.hxx index c2d52cd905..9481fcf72c 100755 --- a/src/NCollection/NCollection_Mat4.hxx +++ b/src/NCollection/NCollection_Mat4.hxx @@ -49,21 +49,6 @@ public: InitIdentity(); } - //! Copy constructor. - //! @param theOther [in] the matrix to copy values from. - NCollection_Mat4 (const NCollection_Mat4& theOther) - { - std::memcpy (this, &theOther, sizeof (NCollection_Mat4)); - } - - //! Assignment operator. - //! @param theOther [in] the matrix to copy values from. - const NCollection_Mat4& operator= (const NCollection_Mat4& theOther) - { - std::memcpy (this, &theOther, sizeof (NCollection_Mat4)); - return *this; - } - //! Get element at the specified row and column. //! @param theRow [in] the row.to address. //! @param theCol [in] the column to address. diff --git a/src/NCollection/NCollection_StdAllocator.hxx b/src/NCollection/NCollection_StdAllocator.hxx index 8bf3610504..6b8c9c198e 100755 --- a/src/NCollection/NCollection_StdAllocator.hxx +++ b/src/NCollection/NCollection_StdAllocator.hxx @@ -58,19 +58,15 @@ public: NCollection_StdAllocator( const Handle(NCollection_BaseAllocator)& theAlloc) throw() { myAlloc = theAlloc; } - //! Constructor. - /*! Copies Allocator() from \a X.*/ - NCollection_StdAllocator( const NCollection_StdAllocator& X) throw() { myAlloc = X.myAlloc; } - - //! Destructor. - /*! Empty implementation.*/ - ~NCollection_StdAllocator() throw() {} - - //! Constructor. + //! Copy constructor. /*! Copies Allocator() from \a Y.*/ template NCollection_StdAllocator( const NCollection_StdAllocator& Y) throw() { myAlloc = Y.Allocator(); } + //! Assignment operator + template NCollection_StdAllocator& operator= (const NCollection_StdAllocator& Y) throw() + { myAlloc = Y.Allocator(); return *this; } + //! Returns an object address. /*! Returns &x.*/ pointer address( reference x ) const { return &x; } @@ -158,6 +154,13 @@ public: /*! Returns an object specified in the constructor.*/ const Handle(NCollection_BaseAllocator)& Allocator() const { return myAlloc; } + //! Assignment operator + NCollection_StdAllocator& operator=(const NCollection_StdAllocator& X) throw() + { + myAlloc = X.myAlloc; + return *this; + } + protected: Handle(NCollection_BaseAllocator) myAlloc; }; diff --git a/src/NCollection/NCollection_Vec2.hxx b/src/NCollection/NCollection_Vec2.hxx index 5515a637a1..79b95123bc 100644 --- a/src/NCollection/NCollection_Vec2.hxx +++ b/src/NCollection/NCollection_Vec2.hxx @@ -57,21 +57,6 @@ public: v[1] = theY; } - //! Copy constructor. - NCollection_Vec2 (const NCollection_Vec2& theVec2) - { - v[0] = theVec2[0]; - v[1] = theVec2[1]; - } - - //! Assignment operator. - const NCollection_Vec2& operator= (const NCollection_Vec2& theVec2) - { - v[0] = theVec2[0]; - v[1] = theVec2[1]; - return *this; - } - //! Alias to 1st component as X coordinate in XY. Element_t x() const { return v[0]; } diff --git a/src/NCollection/NCollection_Vec3.hxx b/src/NCollection/NCollection_Vec3.hxx index a666aa243b..73b9743368 100644 --- a/src/NCollection/NCollection_Vec3.hxx +++ b/src/NCollection/NCollection_Vec3.hxx @@ -73,19 +73,6 @@ public: v[2] = Element_t(0); } - //! Copy constructor. - NCollection_Vec3 (const NCollection_Vec3& theVec3) - { - std::memcpy (this, &theVec3, sizeof(NCollection_Vec3)); - } - - //! Assignment operator. - const NCollection_Vec3& operator= (const NCollection_Vec3& theVec3) - { - std::memcpy (this, &theVec3, sizeof(NCollection_Vec3)); - return *this; - } - //! Alias to 1st component as X coordinate in XYZ. Element_t x() const { return v[0]; } diff --git a/src/NCollection/NCollection_Vec4.hxx b/src/NCollection/NCollection_Vec4.hxx index 65b38ebf15..e3016813e6 100644 --- a/src/NCollection/NCollection_Vec4.hxx +++ b/src/NCollection/NCollection_Vec4.hxx @@ -80,19 +80,6 @@ public: v[3] = theAlpha; } - //! Copy constructor. - NCollection_Vec4 (const NCollection_Vec4& theVec4) - { - std::memcpy (this, &theVec4, sizeof(NCollection_Vec4)); - } - - //! Assignment operator. - const NCollection_Vec4& operator= (const NCollection_Vec4& theVec4) - { - std::memcpy (this, &theVec4, sizeof(NCollection_Vec4)); - return *this; - } - //! Alias to 1st component as X coordinate in XYZW. Element_t x() const { return v[0]; } diff --git a/src/VrmlData/VrmlData_DataMapOfShapeAppearance.hxx b/src/VrmlData/VrmlData_DataMapOfShapeAppearance.hxx index c0613fdae8..b3b5ba3486 100644 --- a/src/VrmlData/VrmlData_DataMapOfShapeAppearance.hxx +++ b/src/VrmlData/VrmlData_DataMapOfShapeAppearance.hxx @@ -20,44 +20,6 @@ #include #include -/** - * Data Map that provides the link between each Shape obtained in VRML import - * and the corresponding Appearance. - */ -class VrmlData_DataMapOfShapeAppearance - : public NCollection_DataMap -{ -public: - //! Constructor - inline VrmlData_DataMapOfShapeAppearance - (const Standard_Integer NbBuckets=1, - const Handle(NCollection_BaseAllocator)& theAllocator = 0L) - : NCollection_DataMap (NbBuckets, theAllocator) - {} - - //! Copy constructor - inline VrmlData_DataMapOfShapeAppearance - (const VrmlData_DataMapOfShapeAppearance& theOther) - : NCollection_DataMap (theOther) - {} - - - friend Standard_Boolean IsEqual (const Handle(TopoDS_TShape)& one, - const Handle(TopoDS_TShape)& two); - -}; - -//======================================================================= -//function : IsEqual -//purpose : for NCollection_DataMap interface -//======================================================================= -inline Standard_Boolean IsEqual (const Handle(TopoDS_TShape)& one, - const Handle(TopoDS_TShape)& two) -{ - return one == two; -} - +typedef NCollection_DataMap VrmlData_DataMapOfShapeAppearance; #endif diff --git a/src/VrmlData/VrmlData_Group.hxx b/src/VrmlData/VrmlData_Group.hxx index 2f13bd194f..4de9d470af 100644 --- a/src/VrmlData/VrmlData_Group.hxx +++ b/src/VrmlData/VrmlData_Group.hxx @@ -17,11 +17,11 @@ #define VrmlData_Group_HeaderFile #include +#include #include #include class TopoDS_Shape; -class VrmlData_DataMapOfShapeAppearance; /** * Implementation of node "Group" diff --git a/src/VrmlData/VrmlData_Scene.hxx b/src/VrmlData/VrmlData_Scene.hxx index 6dbde261cb..052be359de 100644 --- a/src/VrmlData/VrmlData_Scene.hxx +++ b/src/VrmlData/VrmlData_Scene.hxx @@ -27,9 +27,9 @@ #include #include #include +#include struct VrmlData_InBuffer; -class VrmlData_DataMapOfShapeAppearance; /** * Block of comments describing class VrmlData_Scene -- 2.39.5