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) { return isEqual(s); }
71  bool operator!=(const PXL_DeepChannelList &s) { return !isEqual(s); }
72  /// @}
73 
74  /// Number of channels in the channel list
75  int channelCount() const { return myChannels.entries(); }
76 
77  /// Return the name of the given channel
78  const UT_StringHolder &name(int i) const
79  { return myChannels(i).name(); }
80  /// Return tuple size of the given channel
81  int tupleSize(int i) const
82  { return myChannels(i).tupleSize(); }
83  /// Return the "offset" of a given channel. This assumes a linear array of
84  /// interleaved channel data.
85  int offset(int i) const
86  { return myChannels(i).offset(); }
87  /// Return whether the channel data can be interpolated
88  bool isOrdinal(int i) const
89  { return myChannels(i).isOrdinal(); }
90  /// Return the maximum tuple size of all channels
91  int maxSize() const { return myMaxSize; }
92  /// Return the sum of the sizes of all channels
93  int totalSize() const { return myTotalSize; }
94 
95  /// Return -1 if channel isn't found
96  int findChannel(const char *name) const;
97 
98  /// Dump the channel list to stdout
99  void dump(const char *msg="") const;
100 private:
101  UT_Array<ChannelInfo> myChannels;
102  int myMaxSize;
103  int myTotalSize;
104 };
105 
106 #endif
#define SYSmax(a, b)
Definition: SYS_Math.h:1570
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.
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
bool operator!=(const PXL_DeepChannelList &s)
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 PXL_DeepChannelList &s)
bool operator==(const ChannelInfo &i) const
ChannelInfo(const UT_StringHolder &name, int size, int offset, bool ord=false)
GLenum src
Definition: glcorearb.h:1793