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  {}
58 
59  /// Add a channel to the channel list
60  void addChannel(const UT_StringHolder &name, int size,
61  bool ord=false)
62  {
63  myChannels.append(ChannelInfo(name, size, myTotalSize,ord));
64  myMaxSize = SYSmax(myMaxSize, size);
65  myTotalSize += size;
66  }
67 
68  /// @{
69  /// Comparison
70  bool isEqual(const PXL_DeepChannelList &src) const;
71  bool operator==(const PXL_DeepChannelList &s) { return isEqual(s); }
72  bool operator!=(const PXL_DeepChannelList &s) { return !isEqual(s); }
73  /// @}
74 
75  /// Number of channels in the channel list
76  int channelCount() const { return myChannels.entries(); }
77 
78  /// Return the name of the given channel
79  const UT_StringHolder &name(int i) const
80  { return myChannels(i).name(); }
81  /// Return tuple size of the given channel
82  int tupleSize(int i) const
83  { return myChannels(i).tupleSize(); }
84  /// Return the "offset" of a given channel. This assumes a linear array of
85  /// interleaved channel data.
86  int offset(int i) const
87  { return myChannels(i).offset(); }
88  /// Return whether the channel data can be interpolated
89  bool isOrdinal(int i) const
90  { return myChannels(i).isOrdinal(); }
91  /// Return the maximum tuple size of all channels
92  int maxSize() const { return myMaxSize; }
93  /// Return the sum of the sizes of all channels
94  int totalSize() const { return myTotalSize; }
95 
96  /// Return -1 if channel isn't found
97  int findChannel(const char *name) const;
98 
99  /// Dump the channel list to stdout
100  void dump(const char *msg="") const;
101 private:
102  UT_Array<ChannelInfo> myChannels;
103  int myMaxSize;
104  int myTotalSize;
105 };
106 
107 #endif
#define SYSmax(a, b)
Definition: SYS_Math.h:1367
const UT_StringHolder & name() const
A reference counter base class for use with UT_IntrusivePtr.
png_uint_32 i
Definition: png.h:2877
#define PXL_API
Definition: PXL_API.h:10
GLsizeiptr size
Definition: glcorearb.h:663
int tupleSize(int i) const
Return tuple size of the given channel.
int offset(int i) const
const UT_StringHolder & name(int i) const
Return the name of the given channel.
GLintptr offset
Definition: glcorearb.h:664
int totalSize() const
Return the sum of the sizes of all channels.
GLuint const GLchar * name
Definition: glcorearb.h:785
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:1792