Skip to content

Commit

Permalink
Merge branch 'type-classes-refactor' into plasmafair-main
Browse files Browse the repository at this point in the history
* type-classes-refactor:
  Refactor classes for atomic types
  Remove unused private member from `NcCompoundType`
  Inline `NcCompoundType` ctor/dtors
  Inline `NcEnumType` ctor/dtor
  • Loading branch information
ZedThree committed Jan 4, 2024
2 parents 6520b9d + 0a6d0f1 commit 57425ea
Show file tree
Hide file tree
Showing 36 changed files with 127 additions and 667 deletions.
20 changes: 0 additions & 20 deletions cxx4/ncByte.cpp

This file was deleted.

28 changes: 0 additions & 28 deletions cxx4/ncByte.h

This file was deleted.

18 changes: 0 additions & 18 deletions cxx4/ncChar.cpp

This file was deleted.

24 changes: 0 additions & 24 deletions cxx4/ncChar.h

This file was deleted.

18 changes: 0 additions & 18 deletions cxx4/ncCompoundType.cpp
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -42,12 +30,6 @@ bool NcCompoundType::operator==(const NcCompoundType& rhs)
return myId ==rhs.myId && groupId == rhs.groupId;
}

// constructor
NcCompoundType::NcCompoundType(const NcGroup& grp, const string& name):
NcType(grp,name)
{
}

// constructor
// The copy constructor.
NcCompoundType::NcCompoundType(const NcType& rhs):
Expand Down
22 changes: 1 addition & 21 deletions cxx4/ncCompoundType.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,7 @@ namespace netCDF
class NcCompoundType : public NcType
{
public:
NcCompoundType() = default;
~NcCompoundType() = default;
NcCompoundType(const NcCompoundType& rhs) = default;
NcCompoundType(NcCompoundType&& rhs) = default;
NcCompoundType& operator=(const NcCompoundType& rhs) = default;
NcCompoundType& operator=(NcCompoundType&& rhs) = default;

/*!
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.
Expand Down Expand Up @@ -98,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<int> getMemberShape(int memberIndex) const;


private:

int myOffset;

};

}
Expand Down
18 changes: 0 additions & 18 deletions cxx4/ncDouble.cpp

This file was deleted.

25 changes: 0 additions & 25 deletions cxx4/ncDouble.h

This file was deleted.

37 changes: 0 additions & 37 deletions cxx4/ncEnumType.cpp
Original file line number Diff line number Diff line change
@@ -1,32 +1,13 @@
#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;
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)
{
Expand All @@ -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)
Expand Down
25 changes: 4 additions & 21 deletions cxx4/ncEnumType.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down
1 change: 0 additions & 1 deletion cxx4/ncFile.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "ncFile.h"
#include "ncCheck.h"
#include "ncException.h"
#include "ncByte.h"
#include<iostream>
#include<string>
#include<sstream>
Expand Down
18 changes: 0 additions & 18 deletions cxx4/ncFloat.cpp

This file was deleted.

24 changes: 0 additions & 24 deletions cxx4/ncFloat.h

This file was deleted.

15 changes: 2 additions & 13 deletions cxx4/ncGroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <cstddef>
#include <ncException.h>
#include <tuple>
Expand Down Expand Up @@ -1163,7 +1152,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__);
Expand Down
2 changes: 1 addition & 1 deletion cxx4/ncGroup.h
Original file line number Diff line number Diff line change
Expand Up @@ -511,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;


/*!
Expand Down
Loading

0 comments on commit 57425ea

Please sign in to comment.