HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PXL_DeepChannelList.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: PXL_DeepChannelList.h (PXL Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __PXL_DeepChannelList__
12 #define __PXL_DeepChannelList__
13 
14 #include "PXL_API.h"
15 #include <UT/UT_IntrusivePtr.h>
16 #include <UT/UT_StringArray.h>
17 #include "PXL_Forward.h"
18 
20  : public UT_IntrusiveRefCounter<PXL_DeepChannelList>
21 {
22 public:
24  {
25  public:
27  bool ord=false)
28  : myName(name)
29  , myTupleSize(size)
30  , myOffset(offset)
31  , myOrdinal(ord)
32  {
33  }
34  bool operator==(const ChannelInfo &i) const
35  {
36  return myName == i.myName
37  && myTupleSize == i.myTupleSize
38  && myOffset == i.myOffset
39  && myOrdinal == i.myOrdinal;
40  }
41  bool operator!=(const ChannelInfo &i) const { return !(*this == i); }
42  const UT_StringHolder &name() const { return myName; }
43  int tupleSize() const { return myTupleSize; }
44  int offset() const { return myOffset; }
45  bool isOrdinal() const { return myOrdinal; }
46  private:
47  UT_StringHolder myName;
48  int myTupleSize;
49  int myOffset;
50  bool myOrdinal;
51  };
53  : myChannels()
54  , myMaxSize(0)
55  , myTotalSize(0)
56  {}
57 
58  /// Add a channel to the channel list
59  void addChannel(const UT_StringHolder &name, int size,
60  bool ord=false)
61  {
62  myChannels.append(ChannelInfo(name, size, myTotalSize,ord));
63  myMaxSize = SYSmax(myMaxSize, size);
64  myTotalSize += size;
65  }
66 
67  /// @{
68  /// Comparison
69  bool isEqual(const PXL_DeepChannelList &src) const;
70  bool operator==(const PXL_DeepChannelList &s) const
71  { return isEqual(s); }
72  bool operator!=(const PXL_DeepChannelList &s) const
73  { return !isEqual(s); }
74  /// @}
75 
76  /// Number of channels in the channel list
77  int channelCount() const { return myChannels.entries(); }
78 
79  /// Return the name of the given channel
80  const UT_StringHolder &name(int i) const
81  { return myChannels(i).name(); }
82  /// Return tuple size of the given channel
83  int tupleSize(int i) const
84  { return myChannels(i).tupleSize(); }
85  /// Return the "offset" of a given channel. This assumes a linear array of
86  /// interleaved channel data.
87  int offset(int i) const
88  { return myChannels(i).offset(); }
89  /// Return whether the channel data can be interpolated
90  bool isOrdinal(int i) const
91  { return myChannels(i).isOrdinal(); }
92  /// Return the maximum tuple size of all channels
93  int maxSize() const { return myMaxSize; }
94  /// Return the sum of the sizes of all channels
95  int totalSize() const { return myTotalSize; }
96 
97  /// Return -1 if channel isn't found
98  int findChannel(const char *name) const;
99 
100  /// Dump the channel list to stdout
101  void dump(const char *msg="") const;
102 private:
103  UT_Array<ChannelInfo> myChannels;
104  int myMaxSize;
105  int myTotalSize;
106 };
107 
108 #endif
#define SYSmax(a, b)
Definition: SYS_Math.h:1952
GLdouble s
Definition: glad.h:3009
const UT_StringHolder & name() const
A reference counter base class for use with UT_IntrusivePtr.
#define PXL_API
Definition: PXL_API.h:10
int tupleSize(int i) const
Return tuple size of the given channel.
GLintptr offset
Definition: glcorearb.h:665
int offset(int i) const
const UT_StringHolder & name(int i) const
Return the name of the given channel.
bool operator!=(const PXL_DeepChannelList &s) const
int totalSize() const
Return the sum of the sizes of all channels.
GLuint const GLchar * name
Definition: glcorearb.h:786
GLsizeiptr size
Definition: glcorearb.h:664
void addChannel(const UT_StringHolder &name, int size, bool ord=false)
Add a channel to the channel list.
int maxSize() const
Return the maximum tuple size of all channels.
int channelCount() const
Number of channels in the channel list.
bool operator!=(const ChannelInfo &i) const
bool isOrdinal(int i) const
Return whether the channel data can be interpolated.
bool operator==(const ChannelInfo &i) const
ChannelInfo(const UT_StringHolder &name, int size, int offset, bool ord=false)
bool operator==(const PXL_DeepChannelList &s) const
GLenum src
Definition: glcorearb.h:1793