NetCDF-C++  4.3.1-developer
ncGroupAtt.cpp
1 #include "ncGroupAtt.h"
2 #include "ncGroup.h"
3 #include "ncCheck.h"
4 #include <netcdf.h>
5 using namespace std;
6 
7 
8 namespace netCDF {
9  // Global comparator operator ==============
10  // comparator operator
11  bool operator<(const NcGroupAtt& lhs,const NcGroupAtt& rhs)
12  {
13  return false;
14  }
15 
16  // comparator operator
17  bool operator>(const NcGroupAtt& lhs,const NcGroupAtt& rhs)
18  {
19  return true;
20  }
21 }
22 
23 
24 using namespace netCDF;
25 
26 // assignment operator
27 NcGroupAtt& NcGroupAtt::operator=(const NcGroupAtt & rhs)
28 {
29  NcAtt::operator=(rhs); // assign base class parts
30  return *this;
31 }
32 
34 NcGroupAtt::NcGroupAtt(const NcGroupAtt& rhs):
35  NcAtt(rhs) // invoke base class copy constructor
36 {}
37 
38 
39 // Constructor generates a null object.
41  NcAtt() // invoke base class constructor
42 {}
43 
44 // equivalence operator (doesn't bother compaing varid's of each object).
46 {
47  if(nullObject)
48  return nullObject == rhs.isNull();
49  else
50  return myName == rhs.myName && groupId == rhs.groupId;
51 }
52 
53 // Constructor for an existing global attribute.
54 NcGroupAtt::NcGroupAtt(const NcGroup& grp, const int index):
55  NcAtt(false)
56 {
57  groupId = grp.getId();
58  varId = NC_GLOBAL;
59  // get the name of this attribute
60  char attName[NC_MAX_NAME+1];
61  ncCheck(nc_inq_attname(groupId,varId, index, attName),__FILE__,__LINE__);
62  ncCheck(nc_inq_attname(groupId,varId,index,attName),__FILE__,__LINE__);
63  myName = attName;
64 }
65 
C++ API for netCDF4.
Definition: ncAtt.h:9
int getId() const
Gets the group id.
Definition: ncGroup.cpp:141
Class represents a netCDF group.
Definition: ncGroup.h:27
Class represents a netCDF group attribute.
Definition: ncGroupAtt.h:12
bool isNull() const
Returns true if this object is null (i.e.
Definition: ncAtt.h:103
void ncCheck(int retCode, const char *file, int line)
Function checks error code and if necessary throws an exception.
Definition: ncCheck.cpp:11
NcGroupAtt()
Constructor generates a null object.
Definition: ncGroupAtt.cpp:40
bool operator==(const NcGroupAtt &rhs)
equivalence operator
Definition: ncGroupAtt.cpp:45
Abstract base class represents inherited by ncVarAtt and ncGroupAtt.
Definition: ncAtt.h:13

Return to the Main Unidata NetCDF page.
Generated on Fri Nov 11 2016 15:28:29 for NetCDF-C++. NetCDF is a Unidata library.