diff --git a/cxx4/ncAtt.cpp b/cxx4/ncAtt.cpp index c373e73..9ea77ac 100644 --- a/cxx4/ncAtt.cpp +++ b/cxx4/ncAtt.cpp @@ -6,39 +6,6 @@ using namespace std; using namespace netCDF; - -// destructor (defined even though it is virtual) -NcAtt::~NcAtt() {} - -// assignment operator -NcAtt& NcAtt::operator=(const NcAtt& rhs) -{ - nullObject = rhs.nullObject; - myName = rhs.myName; - groupId = rhs.groupId; - varId =rhs.varId; - return *this; -} - -// Constructor generates a null object. -NcAtt::NcAtt() : - nullObject(true) -{} - -// Constructor for non-null instances. -NcAtt::NcAtt(bool nullObject): - nullObject(nullObject) -{} - -// The copy constructor. -NcAtt::NcAtt(const NcAtt& rhs) : - nullObject(rhs.nullObject), - myName(rhs.myName), - groupId(rhs.groupId), - varId(rhs.varId) -{} - - // equivalence operator bool NcAtt::operator==(const NcAtt & rhs) const { diff --git a/cxx4/ncAtt.h b/cxx4/ncAtt.h index 588ec1f..3afd659 100644 --- a/cxx4/ncAtt.h +++ b/cxx4/ncAtt.h @@ -14,17 +14,15 @@ namespace netCDF { public: - /*! destructor */ - virtual ~NcAtt()=0; - /*! Constructor generates a \ref isNull "null object". */ - NcAtt (); + NcAtt () = default; + virtual ~NcAtt() = default; + NcAtt(const NcAtt& rhs) = default; + NcAtt(NcAtt&&) = default; /*! Constructor for non-null instances. */ - NcAtt(bool nullObject); + NcAtt(bool nullObject_) : nullObject(nullObject_) {} - /*! The copy constructor. */ - NcAtt(const NcAtt& rhs); /*! Get the attribute name. */ std::string getName() const {return myName;} @@ -103,17 +101,13 @@ namespace netCDF bool isNull() const {return nullObject;} protected: - /*! assignment operator */ - NcAtt& operator= (const NcAtt& rhs); + NcAtt& operator= (const NcAtt& rhs) = default; + NcAtt& operator= (NcAtt&&) = default; - bool nullObject; - + bool nullObject{true}; std::string myName; - - int groupId; - - int varId; - + int groupId{-1}; + int varId{-1}; }; } diff --git a/cxx4/ncByte.cpp b/cxx4/ncByte.cpp index 86b2ff4..c14dd1c 100644 --- a/cxx4/ncByte.cpp +++ b/cxx4/ncByte.cpp @@ -11,12 +11,8 @@ namespace netCDF { NcByte::NcByte() : NcType(NC_BYTE){ } -NcByte::~NcByte() { -} - int NcByte::sizeoff(){char a;return sizeof(a);}; - // equivalence operator bool NcByte::operator==(const NcByte & rhs) { // simply check the netCDF id. diff --git a/cxx4/ncByte.h b/cxx4/ncByte.h index 6535594..cb48979 100644 --- a/cxx4/ncByte.h +++ b/cxx4/ncByte.h @@ -17,8 +17,6 @@ namespace netCDF /*! storage size */ int sizeoff(); - ~NcByte(); - /*! Constructor */ NcByte(); }; diff --git a/cxx4/ncChar.cpp b/cxx4/ncChar.cpp index c5483b6..fdd30a2 100644 --- a/cxx4/ncChar.cpp +++ b/cxx4/ncChar.cpp @@ -11,10 +11,6 @@ namespace netCDF { NcChar::NcChar() : NcType(NC_CHAR){ } -NcChar::~NcChar() { -} - - // equivalence operator bool NcChar::operator==(const NcChar & rhs) { // simply check the netCDF id. diff --git a/cxx4/ncChar.h b/cxx4/ncChar.h index bd689ce..e6d3f33 100644 --- a/cxx4/ncChar.h +++ b/cxx4/ncChar.h @@ -13,10 +13,7 @@ namespace netCDF /*! equivalence operator */ bool operator==(const NcChar & rhs); - - ~NcChar(); - - /*! Constructor */ + NcChar(); }; diff --git a/cxx4/ncCompoundType.cpp b/cxx4/ncCompoundType.cpp index 7698946..f230950 100644 --- a/cxx4/ncCompoundType.cpp +++ b/cxx4/ncCompoundType.cpp @@ -21,13 +21,6 @@ using namespace netCDF::exceptions; // Class represents a netCDF variable. -// assignment operator -NcCompoundType& NcCompoundType::operator=(const NcCompoundType& rhs) -{ - NcType::operator=(rhs); // assign base class parts - return *this; -} - // assignment operator NcCompoundType& NcCompoundType::operator=(const NcType& rhs) { @@ -40,13 +33,6 @@ NcCompoundType& NcCompoundType::operator=(const NcType& rhs) return *this; } -// The copy constructor. -NcCompoundType::NcCompoundType(const NcCompoundType& rhs): - NcType(rhs) -{ -} - - // equivalence operator bool NcCompoundType::operator==(const NcCompoundType& rhs) { @@ -56,17 +42,6 @@ bool NcCompoundType::operator==(const NcCompoundType& rhs) return myId ==rhs.myId && groupId == rhs.groupId; } -// Constructor generates a null object. -NcCompoundType::NcCompoundType() : - NcType() // invoke base class constructor -{} - -// constructor -NcCompoundType::NcCompoundType(const NcGroup& grp, const string& name): - NcType(grp,name) -{ -} - // constructor // The copy constructor. NcCompoundType::NcCompoundType(const NcType& rhs): diff --git a/cxx4/ncCompoundType.h b/cxx4/ncCompoundType.h index f018778..f92305e 100644 --- a/cxx4/ncCompoundType.h +++ b/cxx4/ncCompoundType.h @@ -17,18 +17,7 @@ namespace netCDF class NcCompoundType : public NcType { public: - - /*! Constructor generates a \ref isNull "null object". */ - NcCompoundType(); - - /*! - Constructor. - The compound Type must already exist in the netCDF file. New netCDF compound types can be - added using NcGroup::addNcCompoundType(); - \param grp The parent group where this type is defined. - \param name Name of new type. - */ - NcCompoundType(const NcGroup& grp, const std::string& name); + using NcType::NcType; /*! Constructor. @@ -37,25 +26,15 @@ namespace netCDF */ NcCompoundType(const NcType& ncType); - /*! assignment operator */ - NcCompoundType& operator=(const NcCompoundType& rhs); - /*! Assignment operator. This assigns from the base type NcType object. Will throw an exception if the NcType is not the base of a Compound type. */ NcCompoundType& operator=(const NcType& rhs); - /*! The copy constructor. */ - NcCompoundType(const NcCompoundType& rhs); - /*! equivalence operator */ bool operator==(const NcCompoundType & rhs); - /*! destructor */ - ~NcCompoundType(){;} - - /*! Adds a named field. \param memName Name of new field. @@ -105,12 +84,6 @@ the offset of a member "mem4" in structure struct1 is: offsetof(struct1,mem4). \return The size of the dimensions of the field. Non-array fields have 0 dimensions. */ std::vector getMemberShape(int memberIndex) const; - - - private: - - int myOffset; - }; } diff --git a/cxx4/ncDim.cpp b/cxx4/ncDim.cpp index c207b37..bc7bf4a 100644 --- a/cxx4/ncDim.cpp +++ b/cxx4/ncDim.cpp @@ -22,23 +22,6 @@ namespace netCDF { using namespace netCDF; -// assignment operator -NcDim& NcDim::operator=(const NcDim & rhs) -{ - nullObject = rhs.nullObject; - myId = rhs.myId; - groupId = rhs.groupId; - return *this; -} - -// The copy constructor. -NcDim::NcDim(const NcDim& rhs): - nullObject(rhs.nullObject), - myId(rhs.myId), - groupId(rhs.groupId) -{} - - // equivalence operator bool NcDim::operator==(const NcDim& rhs) const { @@ -60,11 +43,6 @@ NcGroup NcDim::getParentGroup() const { return NcGroup(groupId); } -// Constructor generates a null object. -NcDim::NcDim() : - nullObject(true) -{} - // Constructor for a dimension (must already exist in the netCDF file.) NcDim::NcDim(const NcGroup& grp, int dimId) : nullObject(false) diff --git a/cxx4/ncDim.h b/cxx4/ncDim.h index 0d65d81..aa85117 100644 --- a/cxx4/ncDim.h +++ b/cxx4/ncDim.h @@ -13,12 +13,7 @@ namespace netCDF class NcDim { public: - - /*! destructor*/ - ~NcDim(){}; - - /*! Constructor generates a \ref isNull "null object". */ - NcDim (); + NcDim () = default; /*! Constructor for a dimension . @@ -28,18 +23,12 @@ namespace netCDF */ NcDim(const NcGroup& grp, int dimId); - /*! assignment operator */ - NcDim& operator =(const NcDim &); - /*! equivalence operator */ bool operator==(const NcDim& rhs) const; /*! != operator */ bool operator!=(const NcDim& rhs) const; - /*! The copy constructor. */ - NcDim(const NcDim& ncDim); - /*! The name of this dimension.*/ std::string getName() const; @@ -68,15 +57,10 @@ namespace netCDF friend bool operator>(const NcDim& lhs,const NcDim& rhs); private: - - bool nullObject; - - int myId; - - int groupId; - + bool nullObject{true}; + int myId{-1}; + int groupId{-1}; }; - } diff --git a/cxx4/ncDouble.cpp b/cxx4/ncDouble.cpp index 6043024..de2ee8e 100644 --- a/cxx4/ncDouble.cpp +++ b/cxx4/ncDouble.cpp @@ -11,10 +11,6 @@ namespace netCDF { NcDouble::NcDouble() : NcType(NC_DOUBLE){ } -NcDouble::~NcDouble() { -} - - // equivalence operator bool NcDouble::operator==(const NcDouble & rhs) { // simply check the netCDF id. diff --git a/cxx4/ncDouble.h b/cxx4/ncDouble.h index db9b00e..d618f59 100644 --- a/cxx4/ncDouble.h +++ b/cxx4/ncDouble.h @@ -14,9 +14,6 @@ namespace netCDF /*! equivalence operator */ bool operator==(const NcDouble & rhs); - /*! destructor */ - ~NcDouble(); - /*! Constructor */ NcDouble(); }; diff --git a/cxx4/ncEnumType.cpp b/cxx4/ncEnumType.cpp index f3a3ad4..3670aca 100644 --- a/cxx4/ncEnumType.cpp +++ b/cxx4/ncEnumType.cpp @@ -20,13 +20,6 @@ using namespace netCDF::exceptions; // Class represents a netCDF variable. -// assignment operator -NcEnumType& NcEnumType::operator=(const NcEnumType& rhs) -{ - NcType::operator=(rhs); // assign base class parts - return *this; -} - // assignment operator NcEnumType& NcEnumType::operator=(const NcType& rhs) { @@ -39,24 +32,6 @@ NcEnumType& NcEnumType::operator=(const NcType& rhs) return *this; } -// The copy constructor. -NcEnumType::NcEnumType(const NcEnumType& rhs): - NcType(rhs) -{ -} - - -// Constructor generates a null object. -NcEnumType::NcEnumType() : - NcType() // invoke base class constructor -{} - -// constructor -NcEnumType::NcEnumType(const NcGroup& grp, const string& name): - NcType(grp,name) -{} - - // constructor NcEnumType::NcEnumType(const NcType& ncType): NcType(ncType) diff --git a/cxx4/ncEnumType.h b/cxx4/ncEnumType.h index c3e9fe1..ba1e620 100644 --- a/cxx4/ncEnumType.h +++ b/cxx4/ncEnumType.h @@ -28,17 +28,7 @@ namespace netCDF nc_UINT64 = NC_UINT64 //!< unsigned 8-byte int }; - /*! Constructor generates a \ref isNull "null object". */ - NcEnumType(); - - /*! - Constructor. - The enum Type must already exist in the netCDF file. New netCDF enum types can - be added using NcGroup::addNcEnumType(); - \param grp The parent group where this type is defined. - \param name Name of new type. - */ - NcEnumType(const NcGroup& grp, const std::string& name); + using NcType::NcType; /*! Constructor. @@ -47,22 +37,15 @@ namespace netCDF */ NcEnumType(const NcType& ncType); - /*! assignment operator */ - NcEnumType& operator=(const NcEnumType& rhs); + NcEnumType(const NcEnumType& rhs) = default; + NcEnumType& operator=(const NcEnumType& rhs) = default; /*! Assignment operator. This assigns from the base type NcType object. Will throw an exception if the NcType is not the base of an Enum type. */ NcEnumType& operator=(const NcType& rhs); - - /*! The copy constructor. */ - NcEnumType(const NcEnumType& rhs); - - /*! Destructor */ - ~NcEnumType(){} - - + /*! Adds a new member to this NcEnumType type. \param name Name for this new Enum memebr. diff --git a/cxx4/ncFile.cpp b/cxx4/ncFile.cpp index 3526cd1..34367bf 100644 --- a/cxx4/ncFile.cpp +++ b/cxx4/ncFile.cpp @@ -37,11 +37,6 @@ void NcFile::close() nullObject = true; } -// Constructor generates a null object. -NcFile::NcFile() : - NcGroup() // invoke base class constructor -{} - // constructor NcFile::NcFile(const string& filePath, const FileMode fMode) { diff --git a/cxx4/ncFile.h b/cxx4/ncFile.h index 291c79d..c738a05 100644 --- a/cxx4/ncFile.h +++ b/cxx4/ncFile.h @@ -37,9 +37,22 @@ namespace netCDF /*! Constructor generates a \ref isNull "null object". */ - NcFile(); - - /*! + NcFile() = default; + /*! Closes file and releases all resources */ + ~NcFile() override; + + /* Do not allow definition of NcFile involving copying any NcFile or NcGroup. + Because the destructor closes the file and releases al resources such + an action could leave NcFile objects in an invalid state */ + NcFile& operator =(const NcGroup & rhs) = delete; + NcFile& operator =(const NcFile & rhs) = delete; + NcFile(const NcGroup& rhs) = delete; + NcFile(const NcFile& rhs) = delete; + + NcFile& operator =(NcFile&& rhs) = delete; + NcFile(NcFile&& rhs) = delete; + + /*! Opens a netCDF file. \param filePath Name of netCDF optional path. \aram ncFileFlags File flags from netcdf.h @@ -105,9 +118,6 @@ namespace netCDF //! Close a file before destructor call void close(); - /*! destructor */ - virtual ~NcFile(); //closes file and releases all resources - //! Synchronize an open netcdf dataset to disk void sync(); @@ -119,16 +129,6 @@ namespace netCDF //! Leave define mode, used for classic model void enddef(); - - - private: - /* Do not allow definition of NcFile involving copying any NcFile or NcGroup. - Because the destructor closes the file and releases al resources such - an action could leave NcFile objects in an invalid state */ - NcFile& operator =(const NcGroup & rhs); - NcFile& operator =(const NcFile & rhs); - NcFile(const NcGroup& rhs); - NcFile(const NcFile& rhs); }; } diff --git a/cxx4/ncFill.cpp b/cxx4/ncFill.cpp index e6720fb..b816c16 100644 --- a/cxx4/ncFill.cpp +++ b/cxx4/ncFill.cpp @@ -19,10 +19,6 @@ fill values are written when you create non-record variables or when you write a beyond data that has not yet been written. */ -//NcFill constructor -NcFill::~NcFill() { - -}; void NcFill::set_Fill( int ncid, int fillmode, int *old_modep ) { ncCheck(nc_set_fill(ncid, fillmode, old_modep ),__FILE__,__LINE__); diff --git a/cxx4/ncFill.h b/cxx4/ncFill.h index cf70f2a..56a209a 100644 --- a/cxx4/ncFill.h +++ b/cxx4/ncFill.h @@ -20,13 +20,7 @@ namespace netCDF class NcFill { public: - ~NcFill(); - - //constructor - NcFill(); - - //member function - void set_Fill(int, int, int*); + void set_Fill(int ncid, int fillmode, int* old_modep); }; } diff --git a/cxx4/ncFilter.cpp b/cxx4/ncFilter.cpp index b3ff766..6b630a1 100644 --- a/cxx4/ncFilter.cpp +++ b/cxx4/ncFilter.cpp @@ -9,11 +9,6 @@ using namespace std; using namespace netCDF; -// Constructor for filtering object -NcFilter::~NcFilter() { - -}; - /* Define a new variable filter for either compression or decompression. The below method allows for setting of the filter which is to be used wen writing a variable. */ void NcFilter::setFilter(unsigned int ncid, unsigned int varid, unsigned int filterId, size_t nparams, const unsigned int* parms) diff --git a/cxx4/ncFilter.h b/cxx4/ncFilter.h index 88e43da..7ff1269 100644 --- a/cxx4/ncFilter.h +++ b/cxx4/ncFilter.h @@ -12,11 +12,6 @@ namespace netCDF class NcFilter { public: - ~NcFilter(); - - //constructor - NcFilter (); - /* Member functions: setFilter: allows for filter definition of a variable when writing getFilter: querys about a filter (if any) associated with the variable diff --git a/cxx4/ncFloat.cpp b/cxx4/ncFloat.cpp index 5531c82..f09e1c5 100644 --- a/cxx4/ncFloat.cpp +++ b/cxx4/ncFloat.cpp @@ -11,10 +11,6 @@ namespace netCDF { NcFloat::NcFloat() : NcType(NC_FLOAT){ } -NcFloat::~NcFloat() { -} - - // equivalence operator bool NcFloat::operator==(const NcFloat & rhs) { // simply check the netCDF id. diff --git a/cxx4/ncFloat.h b/cxx4/ncFloat.h index a01311e..2e08cf5 100644 --- a/cxx4/ncFloat.h +++ b/cxx4/ncFloat.h @@ -13,10 +13,6 @@ namespace netCDF /*! equivalence operator */ bool operator==(const NcFloat & rhs); - - /*! destructor */ - ~NcFloat(); - /*! Constructor */ NcFloat(); }; diff --git a/cxx4/ncGroup.cpp b/cxx4/ncGroup.cpp index aa543f1..9c06f27 100644 --- a/cxx4/ncGroup.cpp +++ b/cxx4/ncGroup.cpp @@ -42,38 +42,6 @@ using namespace netCDF; ///////////////////////////////////////////// -NcGroup::~NcGroup() -{ -} - -// Constructor generates a null object. -NcGroup::NcGroup() : - nullObject(true), - myId(-1) -{} - - -// constructor -NcGroup::NcGroup(const int groupId) : - nullObject(false), - myId(groupId) -{ } - -// assignment operator -NcGroup& NcGroup::operator=(const NcGroup & rhs) -{ - nullObject = rhs.nullObject; - myId = rhs.myId; - return *this; -} - -// The copy constructor. -NcGroup::NcGroup(const NcGroup& rhs): - nullObject(rhs.nullObject), - myId(rhs.myId) -{} - - // equivalence operator bool NcGroup::operator==(const NcGroup & rhs) const { diff --git a/cxx4/ncGroup.h b/cxx4/ncGroup.h index 99f5af8..1f7e211 100644 --- a/cxx4/ncGroup.h +++ b/cxx4/ncGroup.h @@ -55,21 +55,16 @@ namespace netCDF All //!< Select from contents of current, parents and child groups. }; - - /*! assignment operator */ - NcGroup& operator=(const NcGroup& rhs); - - /*! Constructor generates a \ref isNull "null object". */ - NcGroup(); - //* constructor */ - NcGroup(int groupId); - - /*! The copy constructor. */ - NcGroup(const NcGroup& rhs); + NcGroup(int groupId) : nullObject(false), myId(groupId) {} - /*! destructor */ - virtual ~NcGroup(); + /*! Constructor generates a \ref isNull "null object". */ + NcGroup() = default; + virtual ~NcGroup() = default; + NcGroup(const NcGroup& rhs) = default; + NcGroup(NcGroup&& rhs) = default; + NcGroup& operator=(const NcGroup& rhs) = default; + NcGroup& operator=(NcGroup&& rhs) = default; /*! equivalence operator */ bool operator==(const NcGroup& rhs) const; @@ -563,14 +558,8 @@ namespace netCDF protected: - - /*! assignment operator */ - /* NcGroup& operator=(const NcGroup& rhs); */ - - bool nullObject; - - int myId; - + bool nullObject{true}; + int myId{-1}; }; } diff --git a/cxx4/ncGroupAtt.cpp b/cxx4/ncGroupAtt.cpp index b8d8e06..371aec0 100644 --- a/cxx4/ncGroupAtt.cpp +++ b/cxx4/ncGroupAtt.cpp @@ -23,24 +23,6 @@ namespace netCDF { using namespace netCDF; -// assignment operator -NcGroupAtt& NcGroupAtt::operator=(const NcGroupAtt & rhs) -{ - NcAtt::operator=(rhs); // assign base class parts - return *this; -} - -//! The copy constructor. -NcGroupAtt::NcGroupAtt(const NcGroupAtt& rhs): - NcAtt(rhs) // invoke base class copy constructor -{} - - -// Constructor generates a null object. -NcGroupAtt::NcGroupAtt() : - NcAtt() // invoke base class constructor -{} - // equivalence operator (doesn't bother compaing varid's of each object). bool NcGroupAtt::operator==(const NcGroupAtt & rhs) { diff --git a/cxx4/ncGroupAtt.h b/cxx4/ncGroupAtt.h index 59212ec..c55056e 100644 --- a/cxx4/ncGroupAtt.h +++ b/cxx4/ncGroupAtt.h @@ -12,15 +12,11 @@ namespace netCDF class NcGroupAtt : public NcAtt { public: - - /*! assignment operator */ - NcGroupAtt& operator= (const NcGroupAtt& rhs); - - /*! Constructor generates a \ref isNull "null object". */ - NcGroupAtt (); - - /*! The copy constructor. */ - NcGroupAtt(const NcGroupAtt& rhs) ; + NcGroupAtt () = default; + NcGroupAtt(const NcGroupAtt& rhs) = default; + NcGroupAtt& operator= (const NcGroupAtt& rhs) = default; + NcGroupAtt(NcGroupAtt&& rhs) = default; + NcGroupAtt& operator= (NcGroupAtt&& rhs) = default; /*! Constructor for an existing global attribute. diff --git a/cxx4/ncInt.cpp b/cxx4/ncInt.cpp index f607912..67d7afc 100644 --- a/cxx4/ncInt.cpp +++ b/cxx4/ncInt.cpp @@ -11,10 +11,6 @@ namespace netCDF { NcInt::NcInt() : NcType(NC_INT){ } -NcInt::~NcInt() { -} - - // equivalence operator bool NcInt::operator==(const NcInt & rhs) { // simply check the netCDF id. diff --git a/cxx4/ncInt.h b/cxx4/ncInt.h index e8f0e0e..e952ca3 100644 --- a/cxx4/ncInt.h +++ b/cxx4/ncInt.h @@ -14,9 +14,6 @@ namespace netCDF /*! equivalence operator */ bool operator==(const NcInt & rhs); - /*! destructor */ - ~NcInt(); - /*! Constructor */ NcInt(); }; diff --git a/cxx4/ncInt64.cpp b/cxx4/ncInt64.cpp index f3c1023..b0125e3 100644 --- a/cxx4/ncInt64.cpp +++ b/cxx4/ncInt64.cpp @@ -11,10 +11,6 @@ namespace netCDF { NcInt64::NcInt64() : NcType(NC_INT64){ } -NcInt64::~NcInt64() { -} - - // equivalence operator bool NcInt64::operator==(const NcInt64 & rhs) { // simply check the netCDF id. diff --git a/cxx4/ncInt64.h b/cxx4/ncInt64.h index 80ccb3d..1d1250e 100644 --- a/cxx4/ncInt64.h +++ b/cxx4/ncInt64.h @@ -14,9 +14,6 @@ namespace netCDF /*! equivalence operator */ bool operator==(const NcInt64 & rhs); - /*! destructor */ - ~NcInt64(); - /*! Constructor */ NcInt64(); }; diff --git a/cxx4/ncOpaqueType.cpp b/cxx4/ncOpaqueType.cpp index 44080ff..552ba10 100644 --- a/cxx4/ncOpaqueType.cpp +++ b/cxx4/ncOpaqueType.cpp @@ -10,14 +10,6 @@ using namespace netCDF::exceptions; // Class represents a netCDF variable. using namespace netCDF; -// assignment operator -NcOpaqueType& NcOpaqueType::operator=(const NcOpaqueType& rhs) -{ - // assign base class parts - NcType::operator=(rhs); - return *this; -} - // assignment operator NcOpaqueType& NcOpaqueType::operator=(const NcType& rhs) { @@ -30,19 +22,6 @@ NcOpaqueType& NcOpaqueType::operator=(const NcType& rhs) return *this; } -// The copy constructor. -NcOpaqueType::NcOpaqueType(const NcOpaqueType& rhs): - NcType(rhs) -{ -} - - -// Constructor generates a null object. -NcOpaqueType::NcOpaqueType() : - NcType() // invoke base class constructor -{} - - // constructor NcOpaqueType::NcOpaqueType(const NcGroup& grp, const string& name) : NcType(grp,name) diff --git a/cxx4/ncOpaqueType.h b/cxx4/ncOpaqueType.h index 8b466ff..0cdd847 100644 --- a/cxx4/ncOpaqueType.h +++ b/cxx4/ncOpaqueType.h @@ -14,9 +14,12 @@ namespace netCDF class NcOpaqueType : public NcType { public: - - /*! Constructor generates a \ref isNull "null object". */ - NcOpaqueType(); + NcOpaqueType() = default; + ~NcOpaqueType() = default; + NcOpaqueType(const NcOpaqueType& rhs) = default; + NcOpaqueType(NcOpaqueType&& rhs) = default; + NcOpaqueType& operator=(const NcOpaqueType& rhs) = default; + NcOpaqueType& operator=(NcOpaqueType&& rhs) = default; /*! Constructor. @@ -33,21 +36,12 @@ namespace netCDF \param ncType A Nctype object. */ NcOpaqueType(const NcType& ncType); - - /*! assignment operator */ - NcOpaqueType& operator=(const NcOpaqueType& rhs); /*! Assignment operator. This assigns from the base type NcType object. Will throw an exception if the NcType is not the base of an Opaque type. */ NcOpaqueType& operator=(const NcType& rhs); - - /*! The copy constructor.*/ - NcOpaqueType(const NcOpaqueType& rhs); - - /*! destructor */ - ~NcOpaqueType(){;} /*! Returns the size of the opaque type in bytes. */ size_t getTypeSize() const; diff --git a/cxx4/ncShort.cpp b/cxx4/ncShort.cpp index 5f43e06..a27f469 100644 --- a/cxx4/ncShort.cpp +++ b/cxx4/ncShort.cpp @@ -11,10 +11,6 @@ namespace netCDF { NcShort::NcShort() : NcType(NC_SHORT){ } -NcShort::~NcShort() { -} - - // equivalence operator bool NcShort::operator==(const NcShort & rhs) { // simply check the netCDF id. diff --git a/cxx4/ncShort.h b/cxx4/ncShort.h index 3a7d448..5ed8ca4 100644 --- a/cxx4/ncShort.h +++ b/cxx4/ncShort.h @@ -14,9 +14,6 @@ namespace netCDF /*! equivalence operator */ bool operator==(const NcShort & rhs); - /*! destructor */ - ~NcShort(); - /*! Constructor */ NcShort(); }; diff --git a/cxx4/ncString.cpp b/cxx4/ncString.cpp index 676f26e..8a1de41 100644 --- a/cxx4/ncString.cpp +++ b/cxx4/ncString.cpp @@ -11,10 +11,6 @@ namespace netCDF { NcString::NcString() : NcType(NC_STRING){ } -NcString::~NcString() { -} - - // equivalence operator bool NcString::operator==(const NcString & rhs) { // simply check the netCDF id. diff --git a/cxx4/ncString.h b/cxx4/ncString.h index 3d2074e..4de9797 100644 --- a/cxx4/ncString.h +++ b/cxx4/ncString.h @@ -14,9 +14,6 @@ namespace netCDF /*! equivalence operator */ bool operator==(const NcString & rhs); - /*! destructor */ - ~NcString(); - /*! Constructor */ NcString(); }; diff --git a/cxx4/ncType.cpp b/cxx4/ncType.cpp index 471c0e1..bcb01a2 100644 --- a/cxx4/ncType.cpp +++ b/cxx4/ncType.cpp @@ -23,28 +23,6 @@ namespace netCDF { using namespace netCDF; -// assignment operator -NcType& NcType::operator=(const NcType & rhs) -{ - nullObject = rhs.nullObject; - myId= rhs.myId; - groupId = rhs.groupId; - return *this; -} - -// The copy constructor. -NcType::NcType(const NcType& rhs): - nullObject(rhs.nullObject), - myId(rhs.myId), - groupId(rhs.groupId) -{} - - -// Constructor generates a null object. -NcType::NcType() : - nullObject(true) -{} - // constructor NcType::NcType(const NcGroup& grp, const string& name) : nullObject (false) @@ -54,14 +32,6 @@ NcType::NcType(const NcGroup& grp, const string& name) : myId = typTmp.getId(); } -// constructor for a global type -NcType::NcType(nc_type id) : - nullObject(false), - myId(id), - groupId(0) -{ -} - // Constructor for a non-global type NcType::NcType(const netCDF::NcGroup& grp, nc_type id): nullObject(false), diff --git a/cxx4/ncType.h b/cxx4/ncType.h index c763c92..37213f3 100644 --- a/cxx4/ncType.h +++ b/cxx4/ncType.h @@ -43,7 +43,13 @@ namespace netCDF }; /*! Constructor generates a \ref isNull "null object". */ - NcType(); + NcType() = default; + NcType(const NcType& rhs) = default; + NcType(NcType&& rhs) = default; + NcType& operator=(const NcType& rhs) = default; + NcType& operator=(NcType&& rhs) = default; + + virtual ~NcType() = default; /*! Constructor for a non-global type. @@ -69,13 +75,7 @@ namespace netCDF This object describes the "essential" information for a netCDF global type. \param id type id */ - NcType(nc_type id); - - /*! The copy constructor. */ - NcType(const NcType& rhs); - - /*! destructor */ - virtual ~NcType() {} + NcType(nc_type id) : nullObject(false), myId(id), groupId(0) {} /*! equivalence operator */ bool operator==(const NcType&) const; @@ -139,25 +139,13 @@ namespace netCDF friend bool operator>(const NcType& lhs,const NcType& rhs); protected: - - /*! assignment operator */ - NcType& operator=(const NcType& rhs); - - bool nullObject; + bool nullObject{true}; /*! the type Id */ - nc_type myId; + nc_type myId{-1}; /*! the group Id */ - int groupId; - - /*! An ncid associated with a particular open file - (returned from nc_open). - This is required by many of the functions ncType uses, - such as nc_inq_type */ - int g_fileId; - + int groupId{-1}; }; - } #endif diff --git a/cxx4/ncUbyte.cpp b/cxx4/ncUbyte.cpp index 5e12d3b..e4ba043 100644 --- a/cxx4/ncUbyte.cpp +++ b/cxx4/ncUbyte.cpp @@ -11,10 +11,6 @@ namespace netCDF { NcUbyte::NcUbyte() : NcType(NC_UBYTE){ } -NcUbyte::~NcUbyte() { -} - - // equivalence operator bool NcUbyte::operator==(const NcUbyte & rhs) { // simply check the netCDF id. diff --git a/cxx4/ncUbyte.h b/cxx4/ncUbyte.h index caf73a7..4a5b876 100644 --- a/cxx4/ncUbyte.h +++ b/cxx4/ncUbyte.h @@ -14,9 +14,6 @@ namespace netCDF /*! equivalence operator */ bool operator==(const NcUbyte & rhs); - /*! destructor */ - ~NcUbyte(); - /*! Constructor */ NcUbyte(); }; diff --git a/cxx4/ncUint.cpp b/cxx4/ncUint.cpp index cdd7f06..843c4f6 100644 --- a/cxx4/ncUint.cpp +++ b/cxx4/ncUint.cpp @@ -11,10 +11,6 @@ namespace netCDF { NcUint::NcUint() : NcType(NC_UINT){ } -NcUint::~NcUint() { -} - - // equivalence operator bool NcUint::operator==(const NcUint & rhs) { // simply check the netCDF id. diff --git a/cxx4/ncUint.h b/cxx4/ncUint.h index 1ab2c34..8647205 100644 --- a/cxx4/ncUint.h +++ b/cxx4/ncUint.h @@ -14,9 +14,6 @@ namespace netCDF /*! equivalence operator */ bool operator==(const NcUint & rhs); - /*! destructor */ - ~NcUint(); - /*! Constructor */ NcUint(); }; diff --git a/cxx4/ncUint64.cpp b/cxx4/ncUint64.cpp index 7af5823..085bb70 100644 --- a/cxx4/ncUint64.cpp +++ b/cxx4/ncUint64.cpp @@ -11,10 +11,6 @@ namespace netCDF { NcUint64::NcUint64() : NcType(NC_UINT64){ } -NcUint64::~NcUint64() { -} - - // equivalence operator bool NcUint64::operator==(const NcUint64 & rhs) { // simply check the netCDF id. diff --git a/cxx4/ncUint64.h b/cxx4/ncUint64.h index fb7d2a2..0b51f85 100644 --- a/cxx4/ncUint64.h +++ b/cxx4/ncUint64.h @@ -14,9 +14,6 @@ namespace netCDF /*! equivalence operator */ bool operator==(const NcUint64 & rhs); - /*! destructor */ - ~NcUint64(); - /*! Constructor */ NcUint64(); }; diff --git a/cxx4/ncUshort.cpp b/cxx4/ncUshort.cpp index 7eeadf9..4af5770 100644 --- a/cxx4/ncUshort.cpp +++ b/cxx4/ncUshort.cpp @@ -11,10 +11,6 @@ namespace netCDF { NcUshort::NcUshort() : NcType(NC_USHORT){ } -NcUshort::~NcUshort() { -} - - // equivalence operator bool NcUshort::operator==(const NcUshort & rhs) { // simply check the netCDF id. diff --git a/cxx4/ncUshort.h b/cxx4/ncUshort.h index 27119db..9ae1a54 100644 --- a/cxx4/ncUshort.h +++ b/cxx4/ncUshort.h @@ -14,9 +14,6 @@ namespace netCDF /*! equivalence operator */ bool operator==(const NcUshort & rhs); - /*! destructor */ - ~NcUshort(); - /*! Constructor */ NcUshort(); }; diff --git a/cxx4/ncVar.cpp b/cxx4/ncVar.cpp index 76d4feb..20145b5 100644 --- a/cxx4/ncVar.cpp +++ b/cxx4/ncVar.cpp @@ -26,22 +26,6 @@ namespace netCDF { using namespace netCDF; -// assignment operator -NcVar& NcVar::operator=(const NcVar & rhs) -{ - nullObject = rhs.nullObject; - myId = rhs.myId; - groupId = rhs.groupId; - return *this; -} - -// The copy constructor. -NcVar::NcVar(const NcVar& rhs) : - nullObject(rhs.nullObject), - myId(rhs.myId), - groupId(rhs.groupId) -{} - // equivalence operator bool NcVar::operator==(const NcVar & rhs) const @@ -62,21 +46,6 @@ bool NcVar::operator!=(const NcVar & rhs) const ///////////////// -// Constructor generates a null object. -NcVar::NcVar() : nullObject(true), - myId(-1), - groupId(-1) -{} - -// Constructor for a variable (must already exist in the netCDF file.) -NcVar::NcVar (const NcGroup& grp, const int& varId) : - nullObject (false), - myId (varId), - groupId(grp.getId()) -{} - - - // Gets parent group. NcGroup NcVar::getParentGroup() const { return NcGroup(groupId); diff --git a/cxx4/ncVar.h b/cxx4/ncVar.h index 9eeb2f6..a964821 100644 --- a/cxx4/ncVar.h +++ b/cxx4/ncVar.h @@ -65,11 +65,8 @@ namespace netCDF nc_FLETCHER32 = NC_FLETCHER32 //!< Selects the Fletcher32 checksum filter. }; - /*! destructor */ - ~NcVar(){}; - /*! Constructor generates a \ref isNull "null object". */ - NcVar (); + NcVar () = default; /*! Constructor for a variable . @@ -77,10 +74,11 @@ namespace netCDF \param grp Parent NcGroup object. \param varId Id of the is NcVar object. */ - NcVar (const NcGroup& grp, const int& varId); - - /*! assignment operator */ - NcVar& operator =(const NcVar& rhs); + NcVar (const NcGroup& grp, const int& varId) : + nullObject (false), + myId (varId), + groupId(grp.getId() + ) {} /*! equivalence operator */ bool operator==(const NcVar& rhs) const; @@ -88,9 +86,6 @@ namespace netCDF /*! != operator */ bool operator!=(const NcVar& rhs) const; - /*! The copy constructor. */ - NcVar(const NcVar& ncVar); - /*! Name of this NcVar object.*/ std::string getName() const; @@ -100,7 +95,6 @@ namespace netCDF /*! Returns the variable type. */ NcType getType() const; - /*! Rename the variable. */ void rename( const std::string& newname ) const; @@ -1131,21 +1125,11 @@ namespace netCDF */ void putVar(const std::vector& startp, const std::vector& countp, const std::vector& stridep, const std::vector& imapp, const long long* dataValues) const; - - private: - - bool nullObject; - - int myId; - - int groupId; - + bool nullObject {true}; + int myId {-1}; + int groupId {-1}; }; - - } - - #endif diff --git a/cxx4/ncVlenType.cpp b/cxx4/ncVlenType.cpp index 07daaf0..8d32613 100644 --- a/cxx4/ncVlenType.cpp +++ b/cxx4/ncVlenType.cpp @@ -22,13 +22,6 @@ using namespace netCDF::exceptions; // Class represents a netCDF variable. using namespace netCDF; -// assignment operator -NcVlenType& NcVlenType::operator=(const NcVlenType& rhs) -{ - NcType::operator=(rhs); // assign base class parts - return *this; -} - // assignment operator NcVlenType& NcVlenType::operator=(const NcType& rhs) { @@ -41,18 +34,6 @@ NcVlenType& NcVlenType::operator=(const NcType& rhs) return *this; } -// The copy constructor. -NcVlenType::NcVlenType(const NcVlenType& rhs): - NcType(rhs) -{ -} - - -// Constructor generates a null object. -NcVlenType::NcVlenType() : - NcType() // invoke base class constructor -{} - // constructor NcVlenType::NcVlenType(const NcGroup& grp, const string& name) : NcType(grp,name) diff --git a/cxx4/ncVlenType.h b/cxx4/ncVlenType.h index cfcdd99..806fd3a 100644 --- a/cxx4/ncVlenType.h +++ b/cxx4/ncVlenType.h @@ -14,9 +14,12 @@ namespace netCDF class NcVlenType : public NcType { public: - - /*! Constructor generates a \ref isNull "null object". */ - NcVlenType(); + NcVlenType() = default; + NcVlenType(const NcVlenType& rhs) = default; + NcVlenType(NcVlenType&& rhs) = default; + NcVlenType& operator=(const NcVlenType& rhs) = default; + NcVlenType& operator=(NcVlenType&& rhs) = default; + ~NcVlenType() = default; /*! Constructor. @@ -33,24 +36,14 @@ namespace netCDF \param ncType A Nctype object. */ NcVlenType(const NcType& ncType); - - /*! assignment operator */ - NcVlenType& operator=(const NcVlenType& rhs); /*! Assignment operator. This assigns from the base type NcType object. Will throw an exception if the NcType is not the base of a Vlen type. */ NcVlenType& operator=(const NcType& rhs); - - /*! The copy constructor. */ - NcVlenType(const NcVlenType& rhs); - - ~NcVlenType(){;} - /*! Returns the base type. */ NcType getBaseType() const; - }; } diff --git a/cxx4/test_classic.cpp b/cxx4/test_classic.cpp index 2146eb5..fed7d82 100644 --- a/cxx4/test_classic.cpp +++ b/cxx4/test_classic.cpp @@ -16,9 +16,9 @@ int main() cout << "Test creation of classic format file" << endl; { NcFile ncFile("test_classic.nc", NcFile::replace, NcFile::classic); - NcDim dim1 = ncFile.addDim("dim1",11); - NcDim dim2 = ncFile.addDim("dim2"); - NcDim dim3 = ncFile.addDim("dim3",13); + [[maybe_unused]] NcDim dim1 = ncFile.addDim("dim1",11); + [[maybe_unused]] NcDim dim2 = ncFile.addDim("dim2"); + [[maybe_unused]] NcDim dim3 = ncFile.addDim("dim3",13); NcVar var_gw = ncFile.addVar("George_Washington", ncInt, dim1); // The following fails, I don't know why... diff --git a/cxx4/test_dim.cpp b/cxx4/test_dim.cpp index e0b1130..10d361f 100644 --- a/cxx4/test_dim.cpp +++ b/cxx4/test_dim.cpp @@ -39,8 +39,8 @@ int main() cout < dimArray(2); dimArray[0]=dim1; dimArray[1]=dim2; vector stringArray(2); stringArray[0] = "dim1"; stringArray[1] = "dim2"; - NcVar varA1_3 = ncFile.addVar("varA1_3",ncByte,dimArray); - NcVar varA1_4 = ncFile.addVar("varA1_4","byte",stringArray); + ncFile.addVar("varA1_3",ncByte,dimArray); + ncFile.addVar("varA1_4","byte",stringArray); - NcVar varA1_5 = groupB.addVar("varA1_5",ncByte,dim4); - NcVar varA1_6 = groupB.addVar("varA1_6",ncByte,dim2); + groupB.addVar("varA1_5",ncByte,dim4); + groupB.addVar("varA1_6",ncByte,dim2); dimArray[0]=dim1; dimArray[1]=dim7; - NcVar varA1_7 = groupB.addVar("varA1_7",ncByte,dimArray); + groupB.addVar("varA1_7",ncByte,dimArray); dimArray[0]=dim1; dimArray[1]=dim2; - NcVar varA1_8 = groupC.addVar("varA1_8",ncByte,dimArray); + groupC.addVar("varA1_8",ncByte,dimArray); cout <<" ----------- passed\n"; } @@ -79,30 +79,30 @@ int main() NcGroup groupB(groupA.addGroup("groupB")); NcGroup groupC(groupA.addGroup("groupC")); - NcDim dim1 = ncFile.addDim("dim1",11); - NcDim dim2 = ncFile.addDim("dim2"); - NcDim dim3 = ncFile.addDim("dim3",13); - NcDim dim4 = groupB.addDim("dim4",14); - NcDim dim5 = groupB.addDim("dim5",15); - NcDim dim6 = groupB.addDim("dim6",16); - NcDim dim7 = groupB.addDim("dim7",17); - - - NcVar var_1 = ncFile.addVar("var_1", ncByte,dim1); - NcVar varA_1 = groupA.addVar("varA_1", ncByte,dim1); - NcVar varA_2 = groupA.addVar("varA_2", ncByte,dim1); - NcVar varA0_1 = groupA0.addVar("varA0_1",ncByte,dim1); - NcVar varA0_2 = groupA0.addVar("varA0_2",ncByte,dim1); - NcVar varA0_3 = groupA0.addVar("varA0_3",ncByte,dim1); - NcVar varB_1 = groupB.addVar("varB_1", ncByte,dim1); - NcVar varB_2 = groupB.addVar("varB_2", ncByte,dim1); - NcVar varB_3 = groupB.addVar("varB_3", ncByte,dim1); - NcVar varB_4 = groupB.addVar("varB_4", ncByte,dim1); - NcVar varC_1 = groupC.addVar("varC_1", ncByte,dim1); - NcVar varC_2 = groupC.addVar("varC_2", ncByte,dim1); - NcVar varC_3 = groupC.addVar("varC_3", ncByte,dim1); - NcVar varC_4 = groupC.addVar("varC_4", ncByte,dim1); - NcVar varC_5 = groupC.addVar("varC_5", ncByte,dim1); + [[maybe_unused]] NcDim dim1 = ncFile.addDim("dim1",11); + [[maybe_unused]] NcDim dim2 = ncFile.addDim("dim2"); + [[maybe_unused]] NcDim dim3 = ncFile.addDim("dim3",13); + [[maybe_unused]] NcDim dim4 = groupB.addDim("dim4",14); + [[maybe_unused]] NcDim dim5 = groupB.addDim("dim5",15); + [[maybe_unused]] NcDim dim6 = groupB.addDim("dim6",16); + [[maybe_unused]] NcDim dim7 = groupB.addDim("dim7",17); + + + [[maybe_unused]] NcVar var_1 = ncFile.addVar("var_1", ncByte,dim1); + [[maybe_unused]] NcVar varA_1 = groupA.addVar("varA_1", ncByte,dim1); + [[maybe_unused]] NcVar varA_2 = groupA.addVar("varA_2", ncByte,dim1); + [[maybe_unused]] NcVar varA0_1 = groupA0.addVar("varA0_1",ncByte,dim1); + [[maybe_unused]] NcVar varA0_2 = groupA0.addVar("varA0_2",ncByte,dim1); + [[maybe_unused]] NcVar varA0_3 = groupA0.addVar("varA0_3",ncByte,dim1); + [[maybe_unused]] NcVar varB_1 = groupB.addVar("varB_1", ncByte,dim1); + [[maybe_unused]] NcVar varB_2 = groupB.addVar("varB_2", ncByte,dim1); + [[maybe_unused]] NcVar varB_3 = groupB.addVar("varB_3", ncByte,dim1); + [[maybe_unused]] NcVar varB_4 = groupB.addVar("varB_4", ncByte,dim1); + [[maybe_unused]] NcVar varC_1 = groupC.addVar("varC_1", ncByte,dim1); + [[maybe_unused]] NcVar varC_2 = groupC.addVar("varC_2", ncByte,dim1); + [[maybe_unused]] NcVar varC_3 = groupC.addVar("varC_3", ncByte,dim1); + [[maybe_unused]] NcVar varC_4 = groupC.addVar("varC_4", ncByte,dim1); + [[maybe_unused]] NcVar varC_5 = groupC.addVar("varC_5", ncByte,dim1); { cout < a1(10),b1(10);