File: ncCompoundType.h

package info (click to toggle)
netcdf-cxx 4.3.1-5
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 3,456 kB
  • sloc: cpp: 8,506; sh: 4,548; ansic: 4,251; xml: 173; makefile: 145
file content (119 lines) | stat: -rw-r--r-- 3,684 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#include <string>
#include <vector>
#include "ncType.h"
#include "netcdf.h"

#ifndef NcCompoundTypeClass
#define NcCompoundTypeClass


namespace netCDF
{
  class NcGroup;  // forward declaration.

  /*! 
    Class represents a netCDF compound type
  */
  class NcCompoundType : public NcType
  {
  public:

    /*! Constructor generates a \ref isNull "null object". */
    NcCompoundType();

    /*! 
      Constructor.
      The compound Type must already exist in the netCDF file. New netCDF compound types can be 
      added using NcGroup::addNcCompoundType();
      \param grp        The parent group where this type is defined.
      \param name       Name of new type.
    */
    NcCompoundType(const NcGroup& grp, const std::string& name);

    /*! 
      Constructor.
      Constructs from the base type NcType object. Will throw an exception if the NcType is not the base of a Compound type.
      \param ncType     A Nctype object.
    */
    NcCompoundType(const NcType& ncType);

    /*! assignment operator */
    NcCompoundType& operator=(const NcCompoundType& rhs);
      
    /*! 
      Assignment operator.
      This assigns from the base type NcType object. Will throw an exception if the NcType is not the base of a Compound type.
    */
    NcCompoundType& operator=(const NcType& rhs);
      
    /*! The copy constructor. */
    NcCompoundType(const NcCompoundType& rhs);
      
    /*! equivalence operator */
    bool operator==(const NcCompoundType & rhs);

    /*! destructor */
    ~NcCompoundType(){;}
      
      
    /*!  
      Adds a named field.
      \param memName       Name of new field.
      \param newMemberType The type of the new member.
      \param offset        Offset of this member in bytes, obtained by a call to offsetof. For example 
the offset of a member "mem4" in structure struct1 is: offsetof(struct1,mem4).
    */
    void addMember(const std::string& memName, const NcType& newMemberType,size_t offset);

    /*!  
      Adds a named array field.
      \param memName       Name of new field.
      \param newMemberType The type of the new member.
      \param offset        Offset of this member in bytes, obtained by a call to offsetof. For example 
                           the offset of a member "mem4" in structure struct1 is: offsetof(struct1,mem4).
      \param shape         The shape of the array field.
    */
    void addMember(const std::string& memName, const NcType& newMemberType, size_t offset, const std::vector<int>& shape);


    /*! Returns number of members in this NcCompoundType object. */
    size_t  getMemberCount() const;
      
    /*! Returns a NcType object for a single member. */
    NcType getMember(int memberIndex) const;

    /*! Returns name of member field. */
    std::string getMemberName(int memberIndex) const;

    /*! Returns index of named member field. */
    int getMemberIndex(const std::string& memberName) const;

    /*! Returns the offset of the member with given index. */
    size_t getMemberOffset(const int index) const;

    /*! 
      Returns the number of dimensions of a member with the given index. 
      \param Index of member (numbering starts at zero).
      \return The number of dimensions of the field. Non-array fields have 0 dimensions.
    */
    int getMemberDimCount(int memberIndex) const;
      
      
    /*! 
      Returns the shape of a given member. 
      \param Index of member (numbering starts at zero).
      \return The size of the dimensions of the field. Non-array fields have 0 dimensions.
    */
    std::vector<int> getMemberShape(int memberIndex) const;
      
      
  private:
      
    int myOffset;
      
  };
  
}


#endif