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 deleted file mode 100644 index 86b2ff4..0000000 --- a/cxx4/ncByte.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include "ncByte.h" -#include "netcdf.h" -using namespace netCDF; - -// create an instance of NcByte called netCDF::ncByte -namespace netCDF { - NcByte ncByte; -} - -// constructor -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. - return myId == rhs.myId; -} diff --git a/cxx4/ncByte.h b/cxx4/ncByte.h deleted file mode 100644 index 6535594..0000000 --- a/cxx4/ncByte.h +++ /dev/null @@ -1,30 +0,0 @@ -#include "ncType.h" - -#ifndef NcByteClass -#define NcByteClass - -namespace netCDF -{ - - /*! Class represents a netCDF atomic Byte type. */ - class NcByte : public NcType - { - public: - - /*! equivalence operator */ - bool operator==(const NcByte & rhs); - - /*! storage size */ - int sizeoff(); - - ~NcByte(); - - /*! Constructor */ - NcByte(); - }; - - /*! A global instance of the NcByte class within the netCDF namespace. */ - extern NcByte ncByte; - -} -#endif diff --git a/cxx4/ncChar.cpp b/cxx4/ncChar.cpp deleted file mode 100644 index c5483b6..0000000 --- a/cxx4/ncChar.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "ncChar.h" -#include "netcdf.h" -using namespace netCDF; - -// create an instance of NcChar called netCDF::ncChar -namespace netCDF { - NcChar ncChar; -} - -// constructor -NcChar::NcChar() : NcType(NC_CHAR){ -} - -NcChar::~NcChar() { -} - - -// equivalence operator -bool NcChar::operator==(const NcChar & rhs) { - // simply check the netCDF id. - return myId == rhs.myId; -} diff --git a/cxx4/ncChar.h b/cxx4/ncChar.h deleted file mode 100644 index bd689ce..0000000 --- a/cxx4/ncChar.h +++ /dev/null @@ -1,27 +0,0 @@ -#include "ncType.h" - -#ifndef NcCharClass -#define NcCharClass - -namespace netCDF -{ - - /*! Class represents a netCDF atomic Char type. */ - class NcChar : public NcType - { - public: - - /*! equivalence operator */ - bool operator==(const NcChar & rhs); - - ~NcChar(); - - /*! Constructor */ - NcChar(); - }; - - /*! A global instance of the NcChar class within the netCDF namespace. */ - extern NcChar ncChar; - -} -#endif diff --git a/cxx4/ncCompoundType.cpp b/cxx4/ncCompoundType.cpp index 7698946..cc88b68 100644 --- a/cxx4/ncCompoundType.cpp +++ b/cxx4/ncCompoundType.cpp @@ -1,18 +1,6 @@ #include "ncGroup.h" #include "ncCheck.h" #include "ncCompoundType.h" -#include "ncByte.h" -#include "ncUbyte.h" -#include "ncChar.h" -#include "ncShort.h" -#include "ncUshort.h" -#include "ncInt.h" -#include "ncUint.h" -#include "ncInt64.h" -#include "ncUint64.h" -#include "ncFloat.h" -#include "ncDouble.h" -#include "ncString.h" #include "ncException.h" using namespace std; @@ -21,13 +9,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 +21,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 +30,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 deleted file mode 100644 index 6043024..0000000 --- a/cxx4/ncDouble.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "ncDouble.h" -#include "netcdf.h" -using namespace netCDF; - -// create an instance of NcDouble called netCDF::ncDouble -namespace netCDF { - NcDouble ncDouble; -} - -// constructor -NcDouble::NcDouble() : NcType(NC_DOUBLE){ -} - -NcDouble::~NcDouble() { -} - - -// equivalence operator -bool NcDouble::operator==(const NcDouble & rhs) { - // simply check the netCDF id. - return myId == rhs.myId; -} diff --git a/cxx4/ncDouble.h b/cxx4/ncDouble.h deleted file mode 100644 index db9b00e..0000000 --- a/cxx4/ncDouble.h +++ /dev/null @@ -1,28 +0,0 @@ -#include "ncType.h" - -#ifndef NcDoubleClass -#define NcDoubleClass - -namespace netCDF -{ - - /*! Class represents a netCDF atomic Double type. */ - class NcDouble : public NcType - { - public: - - /*! equivalence operator */ - bool operator==(const NcDouble & rhs); - - /*! destructor */ - ~NcDouble(); - - /*! Constructor */ - NcDouble(); - }; - - /*! A global instance of the NcDouble class within the netCDF namespace. */ - extern NcDouble ncDouble; - -} -#endif diff --git a/cxx4/ncEnumType.cpp b/cxx4/ncEnumType.cpp index f3a3ad4..8cbd18e 100644 --- a/cxx4/ncEnumType.cpp +++ b/cxx4/ncEnumType.cpp @@ -1,18 +1,6 @@ #include "ncEnumType.h" #include "ncGroup.h" #include "ncCheck.h" -#include "ncByte.h" -#include "ncUbyte.h" -#include "ncChar.h" -#include "ncShort.h" -#include "ncUshort.h" -#include "ncInt.h" -#include "ncUint.h" -#include "ncInt64.h" -#include "ncUint64.h" -#include "ncFloat.h" -#include "ncDouble.h" -#include "ncString.h" #include "ncException.h" using namespace std; using namespace netCDF; @@ -20,13 +8,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 +20,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..1d9eff7 100644 --- a/cxx4/ncFile.cpp +++ b/cxx4/ncFile.cpp @@ -1,7 +1,6 @@ #include "ncFile.h" #include "ncCheck.h" #include "ncException.h" -#include "ncByte.h" #include #include #include @@ -37,11 +36,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 deleted file mode 100644 index 5531c82..0000000 --- a/cxx4/ncFloat.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "ncFloat.h" -#include "netcdf.h" -using namespace netCDF; - -// create an instance of NcFloat called netCDF::ncFloat -namespace netCDF { - NcFloat ncFloat; -} - -// constructor -NcFloat::NcFloat() : NcType(NC_FLOAT){ -} - -NcFloat::~NcFloat() { -} - - -// equivalence operator -bool NcFloat::operator==(const NcFloat & rhs) { - // simply check the netCDF id. - return myId == rhs.myId; -} diff --git a/cxx4/ncFloat.h b/cxx4/ncFloat.h deleted file mode 100644 index a01311e..0000000 --- a/cxx4/ncFloat.h +++ /dev/null @@ -1,28 +0,0 @@ -#include "ncType.h" - -#ifndef NcFloatClass -#define NcFloatClass - -namespace netCDF -{ - - /*! Class represents a netCDF atomic Float type. */ - class NcFloat : public NcType - { - public: - - /*! equivalence operator */ - bool operator==(const NcFloat & rhs); - - /*! destructor */ - ~NcFloat(); - - /*! Constructor */ - NcFloat(); - }; - - /*! A global instance of the NcFloat class within the netCDF namespace. */ - extern NcFloat ncFloat; - -} -#endif diff --git a/cxx4/ncGroup.cpp b/cxx4/ncGroup.cpp index aa543f1..965dd5f 100644 --- a/cxx4/ncGroup.cpp +++ b/cxx4/ncGroup.cpp @@ -5,18 +5,7 @@ #include "ncCompoundType.h" #include "ncOpaqueType.h" #include "ncGroupAtt.h" -#include "ncByte.h" -#include "ncUbyte.h" -#include "ncChar.h" -#include "ncShort.h" -#include "ncUshort.h" -#include "ncInt.h" -#include "ncUint.h" -#include "ncInt64.h" -#include "ncUint64.h" -#include "ncFloat.h" -#include "ncDouble.h" -#include "ncString.h" + #include #include #include "ncCheck.h" @@ -42,38 +31,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 { @@ -1269,7 +1226,7 @@ NcEnumType NcGroup::addEnumType(const string& name,NcEnumType::ncEnumType baseTy // Adds a new netCDF Vlen type. -NcVlenType NcGroup::addVlenType(const string& name,NcType& baseType) const { +NcVlenType NcGroup::addVlenType(const string& name, const NcType& baseType) const { ncCheckDefineMode(myId); nc_type typeId; ncCheck(nc_def_vlen(myId, name.c_str(), baseType.getId(),&typeId),__FILE__,__LINE__); diff --git a/cxx4/ncGroup.h b/cxx4/ncGroup.h index 99f5af8..cb034d0 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; @@ -516,7 +511,7 @@ namespace netCDF \param basetype A NcType object to be used for the basetype. \return The NcVlenType object for this new netCDF vlen type. */ - NcVlenType addVlenType(const std::string& name,NcType& basetype) const; + NcVlenType addVlenType(const std::string& name, const NcType& basetype) 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 deleted file mode 100644 index f607912..0000000 --- a/cxx4/ncInt.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "ncInt.h" -#include "netcdf.h" -using namespace netCDF; - -// create an instance of NcInt called netCDF::ncInt -namespace netCDF { - NcInt ncInt; -} - -// constructor -NcInt::NcInt() : NcType(NC_INT){ -} - -NcInt::~NcInt() { -} - - -// equivalence operator -bool NcInt::operator==(const NcInt & rhs) { - // simply check the netCDF id. - return myId == rhs.myId; -} diff --git a/cxx4/ncInt.h b/cxx4/ncInt.h deleted file mode 100644 index e8f0e0e..0000000 --- a/cxx4/ncInt.h +++ /dev/null @@ -1,28 +0,0 @@ -#include "ncType.h" - -#ifndef NcIntClass -#define NcIntClass - -namespace netCDF -{ - - /*! Class represents a netCDF atomic Int type. */ - class NcInt : public NcType - { - public: - - /*! equivalence operator */ - bool operator==(const NcInt & rhs); - - /*! destructor */ - ~NcInt(); - - /*! Constructor */ - NcInt(); - }; - - /*! A global instance of the NcInt class within the netCDF namespace. */ - extern NcInt ncInt; - -} -#endif diff --git a/cxx4/ncInt64.cpp b/cxx4/ncInt64.cpp deleted file mode 100644 index f3c1023..0000000 --- a/cxx4/ncInt64.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "ncInt64.h" -#include "netcdf.h" -using namespace netCDF; - -// create an instance of NcInt64 called netCDF::ncInt64 -namespace netCDF { - NcInt64 ncInt64; -} - -// constructor -NcInt64::NcInt64() : NcType(NC_INT64){ -} - -NcInt64::~NcInt64() { -} - - -// equivalence operator -bool NcInt64::operator==(const NcInt64 & rhs) { - // simply check the netCDF id. - return myId == rhs.myId; -} diff --git a/cxx4/ncInt64.h b/cxx4/ncInt64.h deleted file mode 100644 index 80ccb3d..0000000 --- a/cxx4/ncInt64.h +++ /dev/null @@ -1,28 +0,0 @@ -#include "ncType.h" - -#ifndef NcInt64Class -#define NcInt64Class - -namespace netCDF -{ - - /*! Class represents a netCDF atomic Int64 type. */ - class NcInt64 : public NcType - { - public: - - /*! equivalence operator */ - bool operator==(const NcInt64 & rhs); - - /*! destructor */ - ~NcInt64(); - - /*! Constructor */ - NcInt64(); - }; - - /*! A global instance of the NcInt64 class within the netCDF namespace. */ - extern NcInt64 ncInt64; - -} -#endif 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 deleted file mode 100644 index 5f43e06..0000000 --- a/cxx4/ncShort.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "ncShort.h" -#include "netcdf.h" -using namespace netCDF; - -// create an instance of NcShort called netCDF::ncShort -namespace netCDF { - NcShort ncShort; -} - -// constructor -NcShort::NcShort() : NcType(NC_SHORT){ -} - -NcShort::~NcShort() { -} - - -// equivalence operator -bool NcShort::operator==(const NcShort & rhs) { - // simply check the netCDF id. - return myId == rhs.myId; -} diff --git a/cxx4/ncShort.h b/cxx4/ncShort.h deleted file mode 100644 index 3a7d448..0000000 --- a/cxx4/ncShort.h +++ /dev/null @@ -1,28 +0,0 @@ -#include "ncType.h" - -#ifndef NcShortClass -#define NcShortClass - -namespace netCDF -{ - - /*! Class represents a netCDF atomic Short type. */ - class NcShort : public NcType - { - public: - - /*! equivalence operator */ - bool operator==(const NcShort & rhs); - - /*! destructor */ - ~NcShort(); - - /*! Constructor */ - NcShort(); - }; - - /*! A global instance of the NcShort class within the netCDF namespace. */ - extern NcShort ncShort; - -} -#endif diff --git a/cxx4/ncString.cpp b/cxx4/ncString.cpp deleted file mode 100644 index 676f26e..0000000 --- a/cxx4/ncString.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "ncString.h" -#include "netcdf.h" -using namespace netCDF; - -// create an instance of NcString called netCDF::ncString -namespace netCDF { - NcString ncString; -} - -// constructor -NcString::NcString() : NcType(NC_STRING){ -} - -NcString::~NcString() { -} - - -// equivalence operator -bool NcString::operator==(const NcString & rhs) { - // simply check the netCDF id. - return myId == rhs.myId; -} diff --git a/cxx4/ncString.h b/cxx4/ncString.h deleted file mode 100644 index 3d2074e..0000000 --- a/cxx4/ncString.h +++ /dev/null @@ -1,28 +0,0 @@ -#include "ncType.h" - -#ifndef NcStringClass -#define NcStringClass - -namespace netCDF -{ - - /*! Class represents a netCDF atomic String type. */ - class NcString : public NcType - { - public: - - /*! equivalence operator */ - bool operator==(const NcString & rhs); - - /*! destructor */ - ~NcString(); - - /*! Constructor */ - NcString(); - }; - - /*! A global instance of the NcString class within the netCDF namespace. */ - extern NcString ncString; - -} -#endif diff --git a/cxx4/ncType.cpp b/cxx4/ncType.cpp index 471c0e1..d607e87 100644 --- a/cxx4/ncType.cpp +++ b/cxx4/ncType.cpp @@ -19,31 +19,22 @@ namespace netCDF { { return true; } -} - -using namespace netCDF; -// assignment operator -NcType& NcType::operator=(const NcType & rhs) -{ - nullObject = rhs.nullObject; - myId= rhs.myId; - groupId = rhs.groupId; - return *this; + const NcByte ncByte{}; + const NcUbyte ncUbyte{}; + const NcChar ncChar{}; + const NcShort ncShort{}; + const NcUshort ncUshort{}; + const NcInt ncInt{}; + const NcUint ncUint{}; + const NcInt64 ncInt64{}; + const NcUint64 ncUint64{}; + const NcFloat ncFloat{}; + const NcDouble ncDouble{}; + const NcString ncString{}; } -// 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) -{} +using namespace netCDF; // constructor NcType::NcType(const NcGroup& grp, const string& name) : @@ -54,14 +45,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..ab0ea60 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,119 @@ 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; + int groupId{-1}; + }; + + /// Intermediate base class for atomic types + class NcAtomicType : public NcType { + public: + using NcType::NcType; + + bool operator==(const NcAtomicType& rhs) { + return myId == rhs.myId; + } + }; + + /// netCDF atomic byte type + class NcByte : public NcAtomicType { + public: + NcByte() : NcAtomicType(NC_BYTE) {} + }; + + extern const NcByte ncByte; + + /// netCDF atomic unsigned byte type + class NcUbyte : public NcAtomicType { + public: + NcUbyte() : NcAtomicType(NC_UBYTE) {} + }; + + extern const NcUbyte ncUbyte; + + /// netCDF atomic char type + class NcChar : public NcAtomicType { + public: + NcChar() : NcAtomicType(NC_CHAR) {} + }; + + extern const NcChar ncChar; + + /// netCDF atomic short type + class NcShort : public NcAtomicType { + public: + NcShort() : NcAtomicType(NC_SHORT) {} + }; + + extern const NcShort ncShort; + + /// netCDF atomic unsigned short type + class NcUshort : public NcAtomicType { + public: + NcUshort() : NcAtomicType(NC_USHORT) {} + }; + + extern const NcUshort ncUshort; + + /// netCDF atomic int type + class NcInt : public NcAtomicType { + public: + NcInt() : NcAtomicType(NC_INT) {} + }; + + extern const NcInt ncInt; + + /// netCDF atomic unsigned int type + class NcUint : public NcAtomicType { + public: + NcUint() : NcAtomicType(NC_UINT) {} + }; + + extern const NcUint ncUint; + + /// netCDF atomic 64-bit int type + class NcInt64 : public NcAtomicType { + public: + NcInt64() : NcAtomicType(NC_INT64) {} + }; - /*! 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; + extern const NcInt64 ncInt64; + /// netCDF atomic unsigned 64-bit int type + class NcUint64 : public NcAtomicType { + public: + NcUint64() : NcAtomicType(NC_UINT64) {} + }; + + extern const NcUint64 ncUint64; + + /// netCDF atomic float type + class NcFloat : public NcAtomicType { + public: + NcFloat() : NcAtomicType(NC_FLOAT) {} + }; + + extern const NcFloat ncFloat; + + /// netCDF atomic double type + class NcDouble : public NcAtomicType { + public: + NcDouble() : NcAtomicType(NC_DOUBLE) {} + }; + + extern const NcDouble ncDouble; + + /// netCDF atomic string type + class NcString : public NcAtomicType { + public: + NcString() : NcAtomicType(NC_STRING) {} }; + extern const NcString ncString; } #endif diff --git a/cxx4/ncUbyte.cpp b/cxx4/ncUbyte.cpp deleted file mode 100644 index 5e12d3b..0000000 --- a/cxx4/ncUbyte.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "ncUbyte.h" -#include "netcdf.h" -using namespace netCDF; - -// create an instance of NcUbyte called netCDF::ncUbyte -namespace netCDF { - NcUbyte ncUbyte; -} - -// constructor -NcUbyte::NcUbyte() : NcType(NC_UBYTE){ -} - -NcUbyte::~NcUbyte() { -} - - -// equivalence operator -bool NcUbyte::operator==(const NcUbyte & rhs) { - // simply check the netCDF id. - return myId == rhs.myId; -} diff --git a/cxx4/ncUbyte.h b/cxx4/ncUbyte.h deleted file mode 100644 index caf73a7..0000000 --- a/cxx4/ncUbyte.h +++ /dev/null @@ -1,28 +0,0 @@ -#include "ncType.h" - -#ifndef NcUbyteClass -#define NcUbyteClass - -namespace netCDF -{ - - /*! Class represents a netCDF atomic Ubyte type. */ - class NcUbyte : public NcType - { - public: - - /*! equivalence operator */ - bool operator==(const NcUbyte & rhs); - - /*! destructor */ - ~NcUbyte(); - - /*! Constructor */ - NcUbyte(); - }; - - /*! A global instance of the NcUbyte class within the netCDF namespace. */ - extern NcUbyte ncUbyte; - -} -#endif diff --git a/cxx4/ncUint.cpp b/cxx4/ncUint.cpp deleted file mode 100644 index cdd7f06..0000000 --- a/cxx4/ncUint.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "ncUint.h" -#include "netcdf.h" -using namespace netCDF; - -// create an instance of NcUint called netCDF::ncUint -namespace netCDF { - NcUint ncUint; -} - -// constructor -NcUint::NcUint() : NcType(NC_UINT){ -} - -NcUint::~NcUint() { -} - - -// equivalence operator -bool NcUint::operator==(const NcUint & rhs) { - // simply check the netCDF id. - return myId == rhs.myId; -} diff --git a/cxx4/ncUint.h b/cxx4/ncUint.h deleted file mode 100644 index 1ab2c34..0000000 --- a/cxx4/ncUint.h +++ /dev/null @@ -1,28 +0,0 @@ -#include "ncType.h" - -#ifndef NcUintClass -#define NcUintClass - -namespace netCDF -{ - - /*! Class represents a netCDF atomic Uint type. */ - class NcUint : public NcType - { - public: - - /*! equivalence operator */ - bool operator==(const NcUint & rhs); - - /*! destructor */ - ~NcUint(); - - /*! Constructor */ - NcUint(); - }; - - /*! A global instance of the NcUint class within the netCDF namespace. */ - extern NcUint ncUint; - -} -#endif diff --git a/cxx4/ncUint64.cpp b/cxx4/ncUint64.cpp deleted file mode 100644 index 7af5823..0000000 --- a/cxx4/ncUint64.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "ncUint64.h" -#include "netcdf.h" -using namespace netCDF; - -// create an instance of NcUint64 called netCDF::ncUint64 -namespace netCDF { - NcUint64 ncUint64; -} - -// constructor -NcUint64::NcUint64() : NcType(NC_UINT64){ -} - -NcUint64::~NcUint64() { -} - - -// equivalence operator -bool NcUint64::operator==(const NcUint64 & rhs) { - // simply check the netCDF id. - return myId == rhs.myId; -} diff --git a/cxx4/ncUint64.h b/cxx4/ncUint64.h deleted file mode 100644 index fb7d2a2..0000000 --- a/cxx4/ncUint64.h +++ /dev/null @@ -1,28 +0,0 @@ -#include "ncType.h" - -#ifndef NcUint64Class -#define NcUint64Class - -namespace netCDF -{ - - /*! Class represents a netCDF atomic Uint64 type.*/ - class NcUint64 : public NcType - { - public: - - /*! equivalence operator */ - bool operator==(const NcUint64 & rhs); - - /*! destructor */ - ~NcUint64(); - - /*! Constructor */ - NcUint64(); - }; - - /*! A global instance of the NcUint64 class within the netCDF namespace. */ - extern NcUint64 ncUint64; - -} -#endif diff --git a/cxx4/ncUshort.cpp b/cxx4/ncUshort.cpp deleted file mode 100644 index 7eeadf9..0000000 --- a/cxx4/ncUshort.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "ncUshort.h" -#include "netcdf.h" -using namespace netCDF; - -// create an instance of NcUshort called netCDF::ncUshort -namespace netCDF { - NcUshort ncUshort; -} - -// constructor -NcUshort::NcUshort() : NcType(NC_USHORT){ -} - -NcUshort::~NcUshort() { -} - - -// equivalence operator -bool NcUshort::operator==(const NcUshort & rhs) { - // simply check the netCDF id. - return myId == rhs.myId; -} diff --git a/cxx4/ncUshort.h b/cxx4/ncUshort.h deleted file mode 100644 index 27119db..0000000 --- a/cxx4/ncUshort.h +++ /dev/null @@ -1,28 +0,0 @@ -#include "ncType.h" - -#ifndef NcUshortClass -#define NcUshortClass - -namespace netCDF -{ - - /*! Class represents a netCDF atomic Ushort type. */ - class NcUshort : public NcType - { - public: - - /*! equivalence operator */ - bool operator==(const NcUshort & rhs); - - /*! destructor */ - ~NcUshort(); - - /*! Constructor */ - NcUshort(); - }; - - // declare that the class instance ncUshort is known by all.... - extern NcUshort ncUshort; - -} -#endif 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..3388345 100644 --- a/cxx4/ncVar.h +++ b/cxx4/ncVar.h @@ -6,18 +6,6 @@ #include "netcdf.h" #include "ncVarAtt.h" #include "ncGroup.h" -#include "ncByte.h" -#include "ncUbyte.h" -#include "ncChar.h" -#include "ncShort.h" -#include "ncUshort.h" -#include "ncInt.h" -#include "ncUint.h" -#include "ncInt64.h" -#include "ncUint64.h" -#include "ncFloat.h" -#include "ncDouble.h" -#include "ncString.h" #ifndef NcVarClass #define NcVarClass @@ -65,11 +53,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 +62,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 +74,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 +83,6 @@ namespace netCDF /*! Returns the variable type. */ NcType getType() const; - /*! Rename the variable. */ void rename( const std::string& newname ) const; @@ -1131,21 +1113,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..9c15795 100644 --- a/cxx4/ncVlenType.cpp +++ b/cxx4/ncVlenType.cpp @@ -2,18 +2,6 @@ #include "ncGroup.h" #include "ncCheck.h" #include "ncException.h" -#include "ncByte.h" -#include "ncUbyte.h" -#include "ncChar.h" -#include "ncShort.h" -#include "ncUshort.h" -#include "ncInt.h" -#include "ncUint.h" -#include "ncInt64.h" -#include "ncUint64.h" -#include "ncFloat.h" -#include "ncDouble.h" -#include "ncString.h" #include using namespace std; using namespace netCDF; @@ -22,13 +10,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 +22,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/netcdf b/cxx4/netcdf index 18f7734..7ef4296 100644 --- a/cxx4/netcdf +++ b/cxx4/netcdf @@ -5,28 +5,16 @@ extern "C" { #include } #include -#include -#include #include #include #include -#include #include #include #include -#include #include #include -#include -#include #include -#include -#include #include -#include -#include -#include -#include #include #include #include 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);