HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GA_TupleUtils.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: GA_TupleUtils.h ( GA Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __GA_TupleUtils__
12 #define __GA_TupleUtils__
13 
14 #include "GA_API.h"
15 
16 /// @brief Collection of useful functions for working with tuple data.
17 ///
18 /// This class is a collection of common functions (static methods) useful
19 /// for working with tuple data.
20 
22 {
23 public:
24  // componentAsRange() and componentWSizeAsRange() are convenience methods
25  // for many operations taking a component or a tuple size argument with an
26  // optional component.
27  // Rather than performing the logic again and again, you can simply write:
28  // int i, end;
29  // for (i = componentAsRange(input_comp, tuple_size, end); i < end; i++)
30  // { .... }
31  // or
32  // int i, end;
33  // for (i = componentWSizeAsRange(input_comp, tuple_size,
34  // input_tuple_size, end);
35  // i < end; i++)
36  // { .... }
37  //
38  static inline int componentAsRange(int component, int tuple_size,
39  int &end)
40  {
41  if (component < 0)
42  {
43  end = tuple_size;
44  return 0;
45  }
46  end = component+1;
47  return (end <= tuple_size) ? component : end;
48  }
49  static inline int sizeAsRange(int size, int tuple_size, int &end)
50  {
51  end = SYSmin(tuple_size, size);
52  return 0;
53  }
54  static inline int componentWSizeAsRange(int component, int size,
55  int tuple_size, int &end)
56  {
57  if (component < 0)
58  {
59  end = SYSmin(tuple_size, size);
60  return 0;
61  }
62  end = component+1;
63  return (end <= tuple_size) ? component : end;
64  }
65  static inline int startWSizeAsRange(int start, int size,
66  int tuple_size, int &end)
67  {
68  end = SYSmin(tuple_size, start+size);
69  return start;
70  }
71 };
72 
73 #endif
GLuint start
Definition: glcorearb.h:474
#define GA_API
Definition: GA_API.h:12
GLsizeiptr size
Definition: glcorearb.h:663
static int startWSizeAsRange(int start, int size, int tuple_size, int &end)
Definition: GA_TupleUtils.h:65
Collection of useful functions for working with tuple data.
Definition: GA_TupleUtils.h:21
static int sizeAsRange(int size, int tuple_size, int &end)
Definition: GA_TupleUtils.h:49
GLuint GLuint end
Definition: glcorearb.h:474
static int componentWSizeAsRange(int component, int size, int tuple_size, int &end)
Definition: GA_TupleUtils.h:54
static int componentAsRange(int component, int tuple_size, int &end)
Definition: GA_TupleUtils.h:38
#define SYSmin(a, b)
Definition: SYS_Math.h:1366