NetCDF-C++ 4.3.1
ncGroup.h
1#include <string>
2#include <vector>
3#include <set>
4#include <map>
5#include "ncType.h"
6#include "ncEnumType.h"
7#include "ncGroupAtt.h"
8
9
10
11#ifndef NcGroupClass
12#define NcGroupClass
13
14
15namespace netCDF
16{
17
18 static int file_id;
19
20 class NcVar; // forward declaration.
21 class NcDim; // forward declaration.
22 class NcVlenType; // forward declaration.
23 class NcCompoundType; // forward declaration.
24 class NcOpaqueType; // forward declaration.
25
27 class NcGroup
28 {
29
30 public:
31
36 {
42 AllGrps
43 };
44
49 {
55 All
56 };
57
58
60 NcGroup& operator=(const NcGroup& rhs);
61
63 NcGroup();
64
65 //* constructor */
66 NcGroup(int groupId);
67
69 NcGroup(const NcGroup& rhs);
70
72 virtual ~NcGroup();
73
75 bool operator==(const NcGroup& rhs) const;
76
78 bool operator!=(const NcGroup& rhs) const;
79
81 friend bool operator<(const NcGroup& lhs,const NcGroup& rhs);
82
84 friend bool operator>(const NcGroup& lhs,const NcGroup& rhs);
85
86 // /////////////
87 // NcGroup-related methods
88 // /////////////
89
96 std::string getName(bool fullName=false) const;
97
103 NcGroup getParentGroup() const ;
104
109 int getId() const;
110
118
125 std::multimap<std::string,NcGroup> getGroups(NcGroup::GroupLocation location=ChildrenGrps) const;
126
127
135 std::set<NcGroup> getGroups(const std::string& name,NcGroup::GroupLocation location=ChildrenGrps) const;
136
146 NcGroup getGroup(const std::string& name,NcGroup::GroupLocation location=ChildrenGrps) const;
147
154 NcGroup addGroup(const std::string& name) const;
155
156
158 bool isNull() const {return nullObject;}
159
161 bool isRootGroup() const;
162
163 // /////////////
164 // NcVar-related accessors
165 // /////////////
166
172 int getVarCount(NcGroup::Location location=Current) const;
173
179 std::multimap<std::string,NcVar> getVars(NcGroup::Location location=Current) const;
180
187 std::set<NcVar> getVars(const std::string& name,NcGroup::Location location=Current) const;
188
197 NcVar getVar(const std::string& name,NcGroup::Location location=Current) const;
198
207 NcVar addVar(const std::string& name, const NcType& ncType) const;
208
219 NcVar addVar(const std::string& name, const std::string& typeName, const std::string& dimName) const;
220
231 NcVar addVar(const std::string& name, const NcType& ncType, const NcDim& ncDim) const;
232
243 NcVar addVar(const std::string& name, const std::string& typeName, const std::vector<std::string>& dimNames) const;
244
245
256 NcVar addVar(const std::string& name, const NcType& ncType, const std::vector<NcDim>& ncDimVector) const;
257
258 // /////////////
259 // NcGroupAtt-related methods
260 // /////////////
261
267 int getAttCount(NcGroup::Location location=Current) const;
268
274 std::multimap<std::string,NcGroupAtt> getAtts(NcGroup::Location location=Current) const;
275
282 std::set<NcGroupAtt> getAtts(const std::string& name,NcGroup::Location location=Current) const;
283
292 NcGroupAtt getAtt(const std::string& name,NcGroup::Location location=Current) const;
293
294
297 NcGroupAtt putAtt(const std::string& name, size_t len, const char** dataValues) const ;
298
301 NcGroupAtt putAtt(const std::string& name, const std::string& dataValues) const ;
304 NcGroupAtt putAtt(const std::string& name, const NcType& type, short datumValue) const ;
307 NcGroupAtt putAtt(const std::string& name, const NcType& type, int datumValue) const ;
310 NcGroupAtt putAtt(const std::string& name, const NcType& type, long datumValue) const ;
313 NcGroupAtt putAtt(const std::string& name, const NcType& type, float datumValue) const ;
316 NcGroupAtt putAtt(const std::string& name, const NcType& type, double datumValue) const ;
319 NcGroupAtt putAtt(const std::string& name, const NcType& type, unsigned short datumValue) const ;
322 NcGroupAtt putAtt(const std::string& name, const NcType& type, unsigned int datumValue) const ;
325 NcGroupAtt putAtt(const std::string& name, const NcType& type, unsigned long long datumValue) const ;
328 NcGroupAtt putAtt(const std::string& name, const NcType& type, long long datumValue) const ;
331 NcGroupAtt putAtt(const std::string& name, const NcType& type, size_t len, const unsigned char* dataValues) const ;
334 NcGroupAtt putAtt(const std::string& name, const NcType& type, size_t len, const signed char* dataValues) const ;
337 NcGroupAtt putAtt(const std::string& name, const NcType& type, size_t len, const short* dataValues) const ;
340 NcGroupAtt putAtt(const std::string& name, const NcType& type, size_t len, const int* dataValues) const ;
343 NcGroupAtt putAtt(const std::string& name, const NcType& type, size_t len, const long* dataValues) const ;
346 NcGroupAtt putAtt(const std::string& name, const NcType& type, size_t len, const float* dataValues) const ;
349 NcGroupAtt putAtt(const std::string& name, const NcType& type, size_t len, const double* dataValues) const ;
352 NcGroupAtt putAtt(const std::string& name, const NcType& type, size_t len, const unsigned short* dataValues) const ;
355 NcGroupAtt putAtt(const std::string& name, const NcType& type, size_t len, const unsigned int* dataValues) const ;
358 NcGroupAtt putAtt(const std::string& name, const NcType& type, size_t len, const unsigned long long* dataValues) const ;
361 NcGroupAtt putAtt(const std::string& name, const NcType& type, size_t len, const long long* dataValues) const ;
377 NcGroupAtt putAtt(const std::string& name, const NcType& type, size_t len, const void* dataValues) const ;
378
379
380
381 // /////////////
382 // NcDim-related methods
383 // /////////////
384
390 int getDimCount(NcGroup::Location location=Current) const;
391
397 std::multimap<std::string,NcDim> getDims(NcGroup::Location location=Current) const;
398
405 std::set<NcDim> getDims(const std::string& name,NcGroup::Location location=Current) const;
406
414 NcDim getDim(const std::string& name,NcGroup::Location location=Current) const;
415
423 NcDim addDim(const std::string& name, size_t dimSize) const;
424
430 NcDim addDim(const std::string& name) const;
431
432 // /////////////
433 // NcType-related methods
434 // /////////////
435
441 int getTypeCount(NcGroup::Location location=Current) const;
442
443
450 int getTypeCount(NcType::ncType enumType, NcGroup::Location location=Current) const;
451
452
459 std::multimap<std::string,NcType> getTypes(NcGroup::Location location=Current) const;
460
461
469 std::set<NcType> getTypes(const std::string& name, NcGroup::Location location=Current) const;
470
477 std::set<NcType> getTypes(NcType::ncType enumType, NcGroup::Location location=Current) const;
478
479
488 std::set<NcType> getTypes(const std::string& name, NcType::ncType enumType, NcGroup::Location location=Current) const;
489
490
500 NcType getType(const std::string& name, NcGroup::Location location=Current) const;
501
502
510 NcEnumType addEnumType(const std::string& name,NcEnumType::ncEnumType basetype) const;
511
512
519 NcVlenType addVlenType(const std::string& name,NcType& basetype) const;
520
521
528 NcOpaqueType addOpaqueType(const std::string& name, size_t size) const;
529
530
537 NcCompoundType addCompoundType(const std::string& name, size_t size) const;
538
539
551 std::map<std::string,NcGroup> getCoordVars(NcGroup::Location location=Current) const;
552
562 void getCoordVar(std::string& coordVarName, NcDim& ncDim, NcVar& ncVar, NcGroup::Location location=Current) const;
563
564
565 protected:
566
568 /* NcGroup& operator=(const NcGroup& rhs); */
569
571
572 int myId;
573
574 };
575
576}
577#endif
Class represents a netCDF compound type.
Class represents a netCDF dimension.
Definition: ncDim.h:13
Class represents a netCDF enum type.
Definition: ncEnumType.h:16
ncEnumType
List of NetCDF-4 Enumeration types.
Definition: ncEnumType.h:20
Class represents a netCDF group attribute.
Definition: ncGroupAtt.h:13
Class represents a netCDF group.
Definition: ncGroup.h:28
std::set< NcType > getTypes(const std::string &name, NcGroup::Location location=Current) const
Gets the collection of NcType objects with a given name.
NcGroupAtt putAtt(const std::string &name, const NcType &type, long datumValue) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
NcGroupAtt putAtt(const std::string &name, const NcType &type, size_t len, const double *dataValues) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
NcGroupAtt putAtt(const std::string &name, const NcType &type, short datumValue) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
NcGroupAtt putAtt(const std::string &name, const NcType &type, long long datumValue) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
int getGroupCount(NcGroup::GroupLocation location=ChildrenGrps) const
Gets the number of NcGroup objects.
Definition: ncGroup.cpp:147
virtual ~NcGroup()
destructor
Definition: ncGroup.cpp:44
NcGroupAtt putAtt(const std::string &name, const NcType &type, size_t len, const long long *dataValues) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
NcVar addVar(const std::string &name, const NcType &ncType, const std::vector< NcDim > &ncDimVector) const
Adds a new multi-dimensional netCDF variable.
NcGroupAtt putAtt(const std::string &name, const NcType &type, size_t len, const short *dataValues) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
friend bool operator>(const NcGroup &lhs, const NcGroup &rhs)
comparator operator
Definition: ncGroup.cpp:34
NcGroupAtt putAtt(const std::string &name, const NcType &type, size_t len, const unsigned short *dataValues) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
NcGroup & operator=(const NcGroup &rhs)
assignment operator
Definition: ncGroup.cpp:62
NcGroupAtt putAtt(const std::string &name, const NcType &type, size_t len, const unsigned char *dataValues) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
NcDim addDim(const std::string &name) const
Adds a new unlimited netCDF dimension.
NcGroupAtt putAtt(const std::string &name, const NcType &type, int datumValue) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
NcCompoundType addCompoundType(const std::string &name, size_t size) const
Adds a new netCDF UserDefined type.
Definition: ncGroup.cpp:1290
bool operator!=(const NcGroup &rhs) const
!= operator
Definition: ncGroup.cpp:86
NcGroupAtt putAtt(const std::string &name, const NcType &type, unsigned long long datumValue) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
NcVlenType addVlenType(const std::string &name, NcType &basetype) const
Adds a new netCDF Vlen type.
Definition: ncGroup.cpp:1271
NcGroup getGroup(const std::string &name, NcGroup::GroupLocation location=ChildrenGrps) const
Gets the named child NcGroup object.
Definition: ncGroup.cpp:236
void getCoordVar(std::string &coordVarName, NcDim &ncDim, NcVar &ncVar, NcGroup::Location location=Current) const
Gets the NcDim and NcVar object pair for a named coordinate variable.
Definition: ncGroup.cpp:1339
int getTypeCount(NcGroup::Location location=Current) const
Gets the number of type objects.
Definition: ncGroup.cpp:1040
NcVar addVar(const std::string &name, const std::string &typeName, const std::string &dimName) const
Adds a new netCDF variable.
int getId() const
Gets the group id.
Definition: ncGroup.cpp:141
NcGroupAtt putAtt(const std::string &name, const NcType &type, size_t len, const long *dataValues) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
NcGroupAtt putAtt(const std::string &name, const NcType &type, unsigned short datumValue) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
NcType getType(const std::string &name, NcGroup::Location location=Current) const
Gets the NcType object with a given name.
Definition: ncGroup.cpp:1227
int getVarCount(NcGroup::Location location=Current) const
Gets the number of NcVar objects in this group.
Definition: ncGroup.cpp:279
std::multimap< std::string, NcGroupAtt > getAtts(NcGroup::Location location=Current) const
Gets the collection of NcGroupAtt objects.
Definition: ncGroup.cpp:542
NcGroupAtt putAtt(const std::string &name, const NcType &type, double datumValue) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
NcGroupAtt putAtt(const std::string &name, const NcType &type, size_t len, const int *dataValues) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
std::set< NcVar > getVars(const std::string &name, NcGroup::Location location=Current) const
Gets all NcVar objects with a given name.
NcGroupAtt putAtt(const std::string &name, size_t len, const char **dataValues) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
NcGroup()
Constructor generates a null object.
Definition: ncGroup.cpp:49
NcDim addDim(const std::string &name, size_t dimSize) const
Adds a new netCDF dimension.
NcGroupAtt getAtt(const std::string &name, NcGroup::Location location=Current) const
Gets the named NcGroupAtt object.
Definition: ncGroup.cpp:593
bool isRootGroup() const
Returns true if this is the root group, otherwise returns false.
Definition: ncGroup.cpp:119
NcGroup addGroup(const std::string &name) const
Adds a new child netCDF group object.
Definition: ncGroup.cpp:265
Location
The enumeration list contains the options for selecting groups.
Definition: ncGroup.h:49
@ ParentsAndCurrent
Select from contents of current and parents groups.
Definition: ncGroup.h:53
@ Current
Select from contents of current group.
Definition: ncGroup.h:50
@ Children
Select from contents of children groups.
Definition: ncGroup.h:52
@ ChildrenAndCurrent
Select from contents of current and child groups.
Definition: ncGroup.h:54
@ All
Select from contents of current, parents and child groups.
Definition: ncGroup.h:55
@ Parents
Select from contents of parents groups.
Definition: ncGroup.h:51
bool operator==(const NcGroup &rhs) const
equivalence operator
Definition: ncGroup.cpp:77
NcGroupAtt putAtt(const std::string &name, const NcType &type, size_t len, const unsigned int *dataValues) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
std::multimap< std::string, NcVar > getVars(NcGroup::Location location=Current) const
Get the collection of NcVar objects.
Definition: ncGroup.cpp:313
NcVar addVar(const std::string &name, const NcType &ncType, const NcDim &ncDim) const
Adds a new netCDF variable.
NcVar addVar(const std::string &name, const std::string &typeName, const std::vector< std::string > &dimNames) const
Adds a new netCDF multi-dimensional variable.
std::set< NcType > getTypes(const std::string &name, NcType::ncType enumType, NcGroup::Location location=Current) const
Gets the collection of NcType objects with a given name and data type.
std::map< std::string, NcGroup > getCoordVars(NcGroup::Location location=Current) const
Gets a collection of coordinate variables.
Definition: ncGroup.cpp:1300
NcGroupAtt putAtt(const std::string &name, const NcType &type, size_t len, const void *dataValues) const
Creates a new NetCDF group attribute or if already exisiting replaces it.
NcGroupAtt putAtt(const std::string &name, const NcType &type, size_t len, const signed char *dataValues) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
GroupLocation
The enumeration list contains the options for selecting groups (used for returned set of NcGroup obje...
Definition: ncGroup.h:36
@ ParentsAndCurrentGrps
Select from set of parent groups(includes the current group).
Definition: ncGroup.h:41
@ ChildrenOfChildrenGrps
Select from set of all children of children in the current group.
Definition: ncGroup.h:39
@ ParentsGrps
Select from set of parent groups (excludes the current group).
Definition: ncGroup.h:38
@ AllGrps
Select from set of parent groups, current groups and all the children beneath.
Definition: ncGroup.h:42
@ ChildrenGrps
Select from the set of children in the current group.
Definition: ncGroup.h:37
@ AllChildrenGrps
Select from set of all children of the current group and beneath.
Definition: ncGroup.h:40
NcOpaqueType addOpaqueType(const std::string &name, size_t size) const
Adds a new netCDF Opaque type.
Definition: ncGroup.cpp:1281
std::string getName(bool fullName=false) const
Gets the group name.
Definition: ncGroup.cpp:97
NcGroupAtt putAtt(const std::string &name, const NcType &type, float datumValue) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
int getAttCount(NcGroup::Location location=Current) const
Gets the number of group attributes.
Definition: ncGroup.cpp:507
NcEnumType addEnumType(const std::string &name, NcEnumType::ncEnumType basetype) const
Adds a new netCDF enum type.
Definition: ncGroup.cpp:1261
NcGroup getParentGroup() const
Gets the parent group.
Definition: ncGroup.cpp:125
NcVar getVar(const std::string &name, NcGroup::Location location=Current) const
Gets the named NcVar object.
Definition: ncGroup.cpp:388
bool nullObject
assignment operator
Definition: ncGroup.h:570
NcDim getDim(const std::string &name, NcGroup::Location location=Current) const
Gets the named NcDim object.
Definition: ncGroup.cpp:984
NcGroupAtt putAtt(const std::string &name, const NcType &type, unsigned int datumValue) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
NcVar addVar(const std::string &name, const NcType &ncType) const
Adds a new netCDF scalar variable.
Definition: ncGroup.cpp:400
bool isNull() const
Returns true if this object is null (i.e.
Definition: ncGroup.h:158
std::multimap< std::string, NcGroup > getGroups(NcGroup::GroupLocation location=ChildrenGrps) const
Gets the collection of NcGroup objects.
Definition: ncGroup.cpp:183
friend bool operator<(const NcGroup &lhs, const NcGroup &rhs)
comparator operator
Definition: ncGroup.cpp:28
NcGroupAtt putAtt(const std::string &name, const NcType &type, size_t len, const unsigned long long *dataValues) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
std::multimap< std::string, NcType > getTypes(NcGroup::Location location=Current) const
Gets the collection of NcType objects.
Definition: ncGroup.cpp:1122
NcGroupAtt putAtt(const std::string &name, const std::string &dataValues) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
std::set< NcGroupAtt > getAtts(const std::string &name, NcGroup::Location location=Current) const
Gets all NcGroupAtt objects with a given name.
int getDimCount(NcGroup::Location location=Current) const
Gets the number of NcDim objects.
Definition: ncGroup.cpp:904
std::set< NcDim > getDims(const std::string &name, NcGroup::Location location=Current) const
Gets NcDim objects with a given name.
NcGroupAtt putAtt(const std::string &name, const NcType &type, size_t len, const float *dataValues) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
std::multimap< std::string, NcDim > getDims(NcGroup::Location location=Current) const
Gets the collection of NcDim objects.
Definition: ncGroup.cpp:939
Class represents a netCDF opaque type.
Definition: ncOpaqueType.h:15
Base class inherited by NcOpaque, NcVlen, NcCompound and NcEnum classes.
Definition: ncType.h:15
ncType
List of netCDF types that can be represented.
Definition: ncType.h:26
Class represents a netCDF variable.
Definition: ncVar.h:34
Class represents a netCDF VLEN type.
Definition: ncVlenType.h:15
C++ API for netCDF4.
Definition: ncAtt.h:10

Return to the Main Unidata NetCDF page.
Generated on Wed Nov 10 2021 15:25:08 for NetCDF-C++. NetCDF is a Unidata library.