Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor classes for atomic types #146

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 0 additions & 33 deletions cxx4/ncAtt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
26 changes: 10 additions & 16 deletions cxx4/ncAtt.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;}
Expand Down Expand Up @@ -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};
};

}
Expand Down
24 changes: 0 additions & 24 deletions cxx4/ncByte.cpp

This file was deleted.

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

This file was deleted.

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

This file was deleted.

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

This file was deleted.

37 changes: 0 additions & 37 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 All @@ -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)
{
Expand All @@ -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)
{
Expand All @@ -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):
Expand Down
29 changes: 1 addition & 28 deletions cxx4/ncCompoundType.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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<int> getMemberShape(int memberIndex) const;


private:

int myOffset;

};

}
Expand Down
22 changes: 0 additions & 22 deletions cxx4/ncDim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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)
Expand Down
Loading