mirror of
https://github.com/Unidata/netcdf-cxx4.git
synced 2025-02-23 19:09:11 +08:00
Reworking this so that we can avoid the refactor cascade.
This commit is contained in:
parent
8df4a0fd59
commit
37035ffc79
@ -9,6 +9,8 @@ using namespace std;
|
||||
using namespace netCDF;
|
||||
using namespace netCDF::exceptions;
|
||||
|
||||
extern int g_ncid = -1;
|
||||
|
||||
// destructor
|
||||
NcFile::~NcFile()
|
||||
{
|
||||
@ -112,6 +114,8 @@ void NcFile::open(const string& filePath, const FileMode fMode, const FileFormat
|
||||
ncCheck(nc_create(filePath.c_str(), format | NC_CLOBBER, &myId),__FILE__,__LINE__);
|
||||
break;
|
||||
}
|
||||
|
||||
g_ncid = myId;
|
||||
nullObject=false;
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include "ncCheck.h"
|
||||
using namespace std;
|
||||
|
||||
|
||||
extern int g_ncid;
|
||||
|
||||
namespace netCDF {
|
||||
// Global comparator operator ==============
|
||||
@ -62,7 +62,6 @@ NcType::NcType(nc_type id) :
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// Constructor for a non-global type
|
||||
NcType::NcType(const netCDF::NcGroup& grp, nc_type id):
|
||||
nullObject(false),
|
||||
@ -92,7 +91,7 @@ NcGroup NcType::getParentGroup() const {
|
||||
}
|
||||
|
||||
// Returns the type name.
|
||||
string NcType::getName(int ncid) const{
|
||||
string NcType::getName() const{
|
||||
char charName[NC_MAX_NAME+1];
|
||||
size_t *sizep=NULL;
|
||||
|
||||
@ -100,16 +99,16 @@ string NcType::getName(int ncid) const{
|
||||
netcdf file ID (ncid), which is not *groupid*.
|
||||
Working around this for now. */
|
||||
|
||||
ncCheck(nc_inq_type(ncid,myId,charName,sizep),__FILE__,__LINE__);
|
||||
ncCheck(nc_inq_type(g_ncid,myId,charName,sizep),__FILE__,__LINE__);
|
||||
return string(charName);
|
||||
|
||||
};
|
||||
|
||||
// Returns the size in bytes
|
||||
size_t NcType::getSize(int ncid) const{
|
||||
size_t NcType::getSize() const{
|
||||
char* charName=NULL;
|
||||
size_t sizep;
|
||||
ncCheck(nc_inq_type(ncid,myId,charName,&sizep),__FILE__,__LINE__);
|
||||
ncCheck(nc_inq_type(g_ncid,myId,charName,&sizep),__FILE__,__LINE__);
|
||||
return sizep;
|
||||
};
|
||||
|
||||
|
@ -104,19 +104,16 @@ namespace netCDF
|
||||
- NcFloat String returned is "float".
|
||||
- NcDouble String returned is "double".
|
||||
- NcString String returned is "string".
|
||||
|
||||
- @param[in] ncid ncid generated by nc_open, or pulled from ncFile.myId().
|
||||
*/
|
||||
std::string getName(int ncid) const;
|
||||
std::string getName() const;
|
||||
|
||||
/*!
|
||||
The size in bytes.
|
||||
This function will work on any type, including atomic and any user defined type, whether
|
||||
compound, opaque, enumeration, or variable length array.
|
||||
|
||||
@param[in] ncid ncid generated by nc_open, or pulled from ncFile.myId()
|
||||
*/
|
||||
size_t getSize(int ncid) const;
|
||||
size_t getSize() const;
|
||||
|
||||
/*!
|
||||
The type class returned as enumeration type.
|
||||
|
Loading…
Reference in New Issue
Block a user