NetCDF-C++ 4.3.2
Loading...
Searching...
No Matches
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 class NcVar; // forward declaration.
19 class NcDim; // forward declaration.
20 class NcVlenType; // forward declaration.
21 class NcCompoundType; // forward declaration.
22 class NcOpaqueType; // forward declaration.
23
25 class NcGroup
26 {
27
28 public:
29
42
55
56
58 NcGroup& operator=(const NcGroup& rhs);
59
61 NcGroup();
62
63 //* constructor */
64 NcGroup(int groupId);
65
67 NcGroup(const NcGroup& rhs);
68
70 virtual ~NcGroup();
71
73 bool operator==(const NcGroup& rhs) const;
74
76 bool operator!=(const NcGroup& rhs) const;
77
79 friend bool operator<(const NcGroup& lhs,const NcGroup& rhs);
80
82 friend bool operator>(const NcGroup& lhs,const NcGroup& rhs);
83
84 // /////////////
85 // NcGroup-related methods
86 // /////////////
87
94 std::string getName(bool fullName=false) const;
95
101 NcGroup getParentGroup() const ;
102
107 int getId() const;
108
116
123 std::multimap<std::string,NcGroup> getGroups(NcGroup::GroupLocation location=ChildrenGrps) const;
124
125
133 std::set<NcGroup> getGroups(const std::string& name,NcGroup::GroupLocation location=ChildrenGrps) const;
134
144 NcGroup getGroup(const std::string& name,NcGroup::GroupLocation location=ChildrenGrps) const;
145
152 NcGroup addGroup(const std::string& name) const;
153
154
156 bool isNull() const {return nullObject;}
157
159 bool isRootGroup() const;
160
161 // /////////////
162 // NcVar-related accessors
163 // /////////////
164
170 int getVarCount(NcGroup::Location location=Current) const;
171
177 std::multimap<std::string,NcVar> getVars(NcGroup::Location location=Current) const;
178
185 std::set<NcVar> getVars(const std::string& name,NcGroup::Location location=Current) const;
186
195 NcVar getVar(const std::string& name,NcGroup::Location location=Current) const;
196
205 NcVar addVar(const std::string& name, const NcType& ncType) const;
206
217 NcVar addVar(const std::string& name, const std::string& typeName, const std::string& dimName) const;
218
229 NcVar addVar(const std::string& name, const NcType& ncType, const NcDim& ncDim) const;
230
241 NcVar addVar(const std::string& name, const std::string& typeName, const std::vector<std::string>& dimNames) const;
242
243
254 NcVar addVar(const std::string& name, const NcType& ncType, const std::vector<NcDim>& ncDimVector) const;
255
256 // /////////////
257 // NcGroupAtt-related methods
258 // /////////////
259
265 int getAttCount(NcGroup::Location location=Current) const;
266
272 std::multimap<std::string,NcGroupAtt> getAtts(NcGroup::Location location=Current) const;
273
280 std::set<NcGroupAtt> getAtts(const std::string& name,NcGroup::Location location=Current) const;
281
290 NcGroupAtt getAtt(const std::string& name,NcGroup::Location location=Current) const;
291
292
295 NcGroupAtt putAtt(const std::string& name, size_t len, const char** dataValues) const ;
296
299 NcGroupAtt putAtt(const std::string& name, const std::string& dataValues) const ;
302 NcGroupAtt putAtt(const std::string& name, const NcType& type, short datumValue) const ;
305 NcGroupAtt putAtt(const std::string& name, const NcType& type, int datumValue) const ;
308 NcGroupAtt putAtt(const std::string& name, const NcType& type, long datumValue) const ;
311 NcGroupAtt putAtt(const std::string& name, const NcType& type, float datumValue) const ;
314 NcGroupAtt putAtt(const std::string& name, const NcType& type, double datumValue) const ;
317 NcGroupAtt putAtt(const std::string& name, const NcType& type, unsigned short datumValue) const ;
320 NcGroupAtt putAtt(const std::string& name, const NcType& type, unsigned int datumValue) const ;
323 NcGroupAtt putAtt(const std::string& name, const NcType& type, unsigned long long datumValue) const ;
326 NcGroupAtt putAtt(const std::string& name, const NcType& type, long long datumValue) const ;
329 NcGroupAtt putAtt(const std::string& name, const NcType& type, size_t len, const unsigned char* dataValues) const ;
332 NcGroupAtt putAtt(const std::string& name, const NcType& type, size_t len, const signed char* dataValues) const ;
335 NcGroupAtt putAtt(const std::string& name, const NcType& type, size_t len, const short* dataValues) const ;
338 NcGroupAtt putAtt(const std::string& name, const NcType& type, size_t len, const int* dataValues) const ;
341 NcGroupAtt putAtt(const std::string& name, const NcType& type, size_t len, const long* dataValues) const ;
344 NcGroupAtt putAtt(const std::string& name, const NcType& type, size_t len, const float* dataValues) const ;
347 NcGroupAtt putAtt(const std::string& name, const NcType& type, size_t len, const double* dataValues) const ;
350 NcGroupAtt putAtt(const std::string& name, const NcType& type, size_t len, const unsigned short* dataValues) const ;
353 NcGroupAtt putAtt(const std::string& name, const NcType& type, size_t len, const unsigned int* dataValues) const ;
356 NcGroupAtt putAtt(const std::string& name, const NcType& type, size_t len, const unsigned long long* dataValues) const ;
359 NcGroupAtt putAtt(const std::string& name, const NcType& type, size_t len, const long long* dataValues) const ;
375 NcGroupAtt putAtt(const std::string& name, const NcType& type, size_t len, const void* dataValues) const ;
376
377
378
379 // /////////////
380 // NcDim-related methods
381 // /////////////
382
388 int getDimCount(NcGroup::Location location=Current) const;
389
395 std::multimap<std::string,NcDim> getDims(NcGroup::Location location=Current) const;
396
403 std::set<NcDim> getDims(const std::string& name,NcGroup::Location location=Current) const;
404
412 NcDim getDim(const std::string& name,NcGroup::Location location=Current) const;
413
421 NcDim addDim(const std::string& name, size_t dimSize) const;
422
428 NcDim addDim(const std::string& name) const;
429
430 // /////////////
431 // NcType-related methods
432 // /////////////
433
439 int getTypeCount(NcGroup::Location location=Current) const;
440
441
448 int getTypeCount(NcType::ncType enumType, NcGroup::Location location=Current) const;
449
450
457 std::multimap<std::string,NcType> getTypes(NcGroup::Location location=Current) const;
458
459
467 std::set<NcType> getTypes(const std::string& name, NcGroup::Location location=Current) const;
468
475 std::set<NcType> getTypes(NcType::ncType enumType, NcGroup::Location location=Current) const;
476
477
486 std::set<NcType> getTypes(const std::string& name, NcType::ncType enumType, NcGroup::Location location=Current) const;
487
488
498 NcType getType(const std::string& name, NcGroup::Location location=Current) const;
499
500
508 NcEnumType addEnumType(const std::string& name,NcEnumType::ncEnumType basetype) const;
509
510
517 NcVlenType addVlenType(const std::string& name,NcType& basetype) const;
518
519
526 NcOpaqueType addOpaqueType(const std::string& name, size_t size) const;
527
528
535 NcCompoundType addCompoundType(const std::string& name, size_t size) const;
536
537
549 std::map<std::string,NcGroup> getCoordVars(NcGroup::Location location=Current) const;
550
560 void getCoordVar(const std::string& coordVarName, NcDim& ncDim, NcVar& ncVar, NcGroup::Location location=Current) const;
561
562
563 protected:
564
566 /* NcGroup& operator=(const NcGroup& rhs); */
567
569
570 int myId;
571
572 };
573
574}
575#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:26
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:150
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...
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:65
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:1275
bool operator!=(const NcGroup &rhs) const
!= operator
Definition ncGroup.cpp:89
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:1256
NcGroup getGroup(const std::string &name, NcGroup::GroupLocation location=ChildrenGrps) const
Gets the named child NcGroup object.
Definition ncGroup.cpp:239
int getTypeCount(NcGroup::Location location=Current) const
Gets the number of type objects.
Definition ncGroup.cpp:1025
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:144
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:1212
int getVarCount(NcGroup::Location location=Current) const
Gets the number of NcVar objects in this group.
Definition ncGroup.cpp:282
std::multimap< std::string, NcGroupAtt > getAtts(NcGroup::Location location=Current) const
Gets the collection of NcGroupAtt objects.
Definition ncGroup.cpp:545
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:52
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:598
bool isRootGroup() const
Returns true if this is the root group, otherwise returns false.
Definition ncGroup.cpp:122
void getCoordVar(const 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:1333
NcGroup addGroup(const std::string &name) const
Adds a new child netCDF group object.
Definition ncGroup.cpp:268
Location
The enumeration list contains the options for selecting groups.
Definition ncGroup.h:47
@ ParentsAndCurrent
Select from contents of current and parents groups.
Definition ncGroup.h:51
@ Current
Select from contents of current group.
Definition ncGroup.h:48
@ Children
Select from contents of children groups.
Definition ncGroup.h:50
@ ChildrenAndCurrent
Select from contents of current and child groups.
Definition ncGroup.h:52
@ All
Select from contents of current, parents and child groups.
Definition ncGroup.h:53
@ Parents
Select from contents of parents groups.
Definition ncGroup.h:49
bool operator==(const NcGroup &rhs) const
equivalence operator
Definition ncGroup.cpp:80
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:316
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:1285
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:34
@ ParentsAndCurrentGrps
Select from set of parent groups(includes the current group).
Definition ncGroup.h:39
@ ChildrenOfChildrenGrps
Select from set of all children of children in the current group.
Definition ncGroup.h:37
@ ParentsGrps
Select from set of parent groups (excludes the current group).
Definition ncGroup.h:36
@ AllGrps
Select from set of parent groups, current groups and all the children beneath.
Definition ncGroup.h:40
@ ChildrenGrps
Select from the set of children in the current group.
Definition ncGroup.h:35
@ AllChildrenGrps
Select from set of all children of the current group and beneath.
Definition ncGroup.h:38
NcOpaqueType addOpaqueType(const std::string &name, size_t size) const
Adds a new netCDF Opaque type.
Definition ncGroup.cpp:1266
std::string getName(bool fullName=false) const
Gets the group name.
Definition ncGroup.cpp:100
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:510
NcEnumType addEnumType(const std::string &name, NcEnumType::ncEnumType basetype) const
Adds a new netCDF enum type.
Definition ncGroup.cpp:1246
NcGroup getParentGroup() const
Gets the parent group.
Definition ncGroup.cpp:128
NcVar getVar(const std::string &name, NcGroup::Location location=Current) const
Gets the named NcVar object.
Definition ncGroup.cpp:391
bool nullObject
assignment operator
Definition ncGroup.h:568
NcDim getDim(const std::string &name, NcGroup::Location location=Current) const
Gets the named NcDim object.
Definition ncGroup.cpp:969
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:403
bool isNull() const
Returns true if this object is null (i.e.
Definition ncGroup.h:156
std::multimap< std::string, NcGroup > getGroups(NcGroup::GroupLocation location=ChildrenGrps) const
Gets the collection of NcGroup objects.
Definition ncGroup.cpp:186
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:1107
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:889
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:924
Class represents a netCDF opaque type.
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 for NetCDF-C++. NetCDF is a Unidata library.