NetCDF-C++  4.3.1-developer
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 
15 namespace 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  {
43  };
44 
48  enum Location
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
NcGroupAtt getAtt(const std::string &name, NcGroup::Location location=Current) const
Gets the named NcGroupAtt object.
Definition: ncGroup.cpp:593
GroupLocation
The enumeration list contains the options for selecting groups (used for returned set of NcGroup obje...
Definition: ncGroup.h:35
Base class inherited by NcOpaque, NcVlen, NcCompound and NcEnum classes.
Definition: ncType.h:14
bool isNull() const
Returns true if this object is null (i.e.
Definition: ncGroup.h:158
bool operator==(const NcGroup &rhs) const
equivalence operator
Definition: ncGroup.cpp:77
Select from set of all children of the current group and beneath.
Definition: ncGroup.h:40
int getDimCount(NcGroup::Location location=Current) const
Gets the number of NcDim objects.
Definition: ncGroup.cpp:904
NcGroup getParentGroup() const
Gets the parent group.
Definition: ncGroup.cpp:125
friend bool operator>(const NcGroup &lhs, const NcGroup &rhs)
comparator operator
Definition: ncGroup.cpp:34
C++ API for netCDF4.
Definition: ncAtt.h:9
bool nullObject
assignment operator
Definition: ncGroup.h:570
std::multimap< std::string, NcGroup > getGroups(NcGroup::GroupLocation location=ChildrenGrps) const
Gets the collection of NcGroup objects.
Definition: ncGroup.cpp:183
Select from contents of current group.
Definition: ncGroup.h:50
Location
The enumeration list contains the options for selecting groups.
Definition: ncGroup.h:48
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...
Select from contents of parents groups.
Definition: ncGroup.h:51
Select from the set of children in the current group.
Definition: ncGroup.h:37
NcType getType(const std::string &name, NcGroup::Location location=Current) const
Gets the NcType object with a given name.
Definition: ncGroup.cpp:1227
int getAttCount(NcGroup::Location location=Current) const
Gets the number of group attributes.
Definition: ncGroup.cpp:507
Class represents a netCDF compound type.
int getId() const
Gets the group id.
Definition: ncGroup.cpp:141
Class represents a netCDF enum type.
Definition: ncEnumType.h:15
Select from set of parent groups(includes the current group).
Definition: ncGroup.h:41
NcVlenType addVlenType(const std::string &name, NcType &basetype) const
Adds a new netCDF Vlen type.
Definition: ncGroup.cpp:1271
std::string getName(bool fullName=false) const
Gets the group name.
Definition: ncGroup.cpp:97
Class represents a netCDF VLEN type.
Definition: ncVlenType.h:14
NcEnumType addEnumType(const std::string &name, NcEnumType::ncEnumType basetype) const
Adds a new netCDF enum type.
Definition: ncGroup.cpp:1261
Class represents a netCDF group.
Definition: ncGroup.h:27
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 getGroupCount(NcGroup::GroupLocation location=ChildrenGrps) const
Gets the number of NcGroup objects.
Definition: ncGroup.cpp:147
Class represents a netCDF group attribute.
Definition: ncGroupAtt.h:12
ncType
List of netCDF types that can be represented.
Definition: ncType.h:25
Select from set of parent groups, current groups and all the children beneath.
Definition: ncGroup.h:42
NcGroup getGroup(const std::string &name, NcGroup::GroupLocation location=ChildrenGrps) const
Gets the named child NcGroup object.
Definition: ncGroup.cpp:236
virtual ~NcGroup()
destructor
Definition: ncGroup.cpp:44
NcGroup & operator=(const NcGroup &rhs)
assignment operator
Definition: ncGroup.cpp:62
NcVar addVar(const std::string &name, const NcType &ncType) const
Adds a new netCDF scalar variable.
Definition: ncGroup.cpp:400
std::multimap< std::string, NcDim > getDims(NcGroup::Location location=Current) const
Gets the collection of NcDim objects.
Definition: ncGroup.cpp:939
Select from contents of current, parents and child groups.
Definition: ncGroup.h:55
Class represents a netCDF dimension.
Definition: ncDim.h:13
NcGroup addGroup(const std::string &name) const
Adds a new child netCDF group object.
Definition: ncGroup.cpp:265
Select from contents of current and parents groups.
Definition: ncGroup.h:53
friend bool operator<(const NcGroup &lhs, const NcGroup &rhs)
comparator operator
Definition: ncGroup.cpp:28
NcDim getDim(const std::string &name, NcGroup::Location location=Current) const
Gets the named NcDim object.
Definition: ncGroup.cpp:984
std::multimap< std::string, NcType > getTypes(NcGroup::Location location=Current) const
Gets the collection of NcType objects.
Definition: ncGroup.cpp:1122
Select from contents of children groups.
Definition: ncGroup.h:52
std::multimap< std::string, NcGroupAtt > getAtts(NcGroup::Location location=Current) const
Gets the collection of NcGroupAtt objects.
Definition: ncGroup.cpp:542
bool isRootGroup() const
Returns true if this is the root group, otherwise returns false.
Definition: ncGroup.cpp:119
NcDim addDim(const std::string &name, size_t dimSize) const
Adds a new netCDF dimension.
int getVarCount(NcGroup::Location location=Current) const
Gets the number of NcVar objects in this group.
Definition: ncGroup.cpp:279
Select from contents of current and child groups.
Definition: ncGroup.h:54
std::multimap< std::string, NcVar > getVars(NcGroup::Location location=Current) const
Get the collection of NcVar objects.
Definition: ncGroup.cpp:313
ncEnumType
List of NetCDF-4 Enumeration types.
Definition: ncEnumType.h:20
NcVar getVar(const std::string &name, NcGroup::Location location=Current) const
Gets the named NcVar object.
Definition: ncGroup.cpp:388
Select from set of parent groups (excludes the current group).
Definition: ncGroup.h:38
NcCompoundType addCompoundType(const std::string &name, size_t size) const
Adds a new netCDF UserDefined type.
Definition: ncGroup.cpp:1290
Class represents a netCDF opaque type.
Definition: ncOpaqueType.h:14
int getTypeCount(NcGroup::Location location=Current) const
Gets the number of type objects.
Definition: ncGroup.cpp:1040
Class represents a netCDF variable.
Definition: ncVar.h:33
std::map< std::string, NcGroup > getCoordVars(NcGroup::Location location=Current) const
Gets a collection of coordinate variables.
Definition: ncGroup.cpp:1300
NcGroup()
Constructor generates a null object.
Definition: ncGroup.cpp:49
NcOpaqueType addOpaqueType(const std::string &name, size_t size) const
Adds a new netCDF Opaque type.
Definition: ncGroup.cpp:1281
bool operator!=(const NcGroup &rhs) const
!= operator
Definition: ncGroup.cpp:86
Select from set of all children of children in the current group.
Definition: ncGroup.h:39

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