FastUIDraw
shareable_value_list.hpp
Go to the documentation of this file.
1 /*!
2  * \file shareable_value_list.hpp
3  * \brief file shareable_value_list.hpp
4  *
5  * Copyright 2019 by Intel.
6  *
7  * Contact: kevin.rogovin@gmail.com
8  *
9  * This Source Code Form is subject to the
10  * terms of the Mozilla Public License, v. 2.0.
11  * If a copy of the MPL was not distributed with
12  * this file, You can obtain one at
13  * http://mozilla.org/MPL/2.0/.
14  *
15  * \author Kevin Rogovin <kevin.rogovin@gmail.com>
16  *
17  */
18 
19 
20 #ifndef FASTUIDRAW_SHAREABLE_VALUE_LIST_HPP
21 #define FASTUIDRAW_SHAREABLE_VALUE_LIST_HPP
22 
23 #include <fastuidraw/util/util.hpp>
26 
27 namespace fastuidraw
28 {
29  namespace glsl
30  {
31 /*!\addtogroup GLSL
32  * @{
33  */
34  /*!
35  * \brief
36  * A shareable_value_list is a list of values and their types
37  * that a shader will have computed after running. These can
38  * be used is shader-chaining to get some of the values made
39  * from a dependee shader.
40  */
42  {
43  public:
44  /*!
45  * \brief
46  * Enumeration to define the types of the a shareable value
47  * can be.
48  */
49  enum type_t
50  {
51  type_float, /*!< corresponds to float in GLSL */
52  type_uint, /*!< corresponds to uint in GLSL */
53  type_int, /*!< corresponds to int in GLSL */
54 
55  type_number_types,
56  };
57 
58  /*!
59  * Swap operation
60  * \param obj object with which to swap
61  */
62  void
64  {
65  m_data.swap(obj.m_data);
66  }
67 
68  /*!
69  * Returns an array indexed by \ref type_t that
70  * holds the number of shareable variables for
71  * each type.
72  */
75  {
77  for (unsigned int i = 0; i < type_number_types; ++i)
78  {
79  R[i] = m_data[i].size();
80  }
81  return R;
82  }
83 
84  /*!
85  * Returns the names of the shareable values of the
86  * specified type.
87  * \param q type
88  */
90  shareable_values(enum type_t q) const
91  {
92  return m_data[q].get();
93  }
94 
95  /*!
96  * Add a shareable value
97  * \param pname name by which to reference the shareable value
98  * \param q type of the shareable value
99  */
102  {
103  m_data[q].push_back(pname);
104  return *this;
105  }
106 
107  /*!
108  * Add an uint shareable value, equivalent to
109  * \code
110  * add_shareable_value(pname, type_uint);
111  * \endcode
112  */
115  {
116  return add_shareable_value(pname, type_uint);
117  }
118 
119  /*!
120  * Add an uint shareable value, equivalent to
121  * \code
122  * add_shareable_value(pname, type_int);
123  * \endcode
124  */
127  {
128  return add_shareable_value(pname, type_int);
129  }
130 
131  /*!
132  * Add an uint shareable value, equivalent to
133  * \code
134  * add_shareable_value(pname, type_smooth);
135  * \endcode
136  */
139  {
140  return add_shareable_value(pname, type_float);
141  }
142  private:
144  };
145 
146 /*! @} */
147  }
148 }
149 
150 #endif
A shareable_value_list is a list of values and their types that a shader will have computed after run...
all classes and functions of FastUIDraw are in the namespace fastuidraw.
Definition: colorstop.hpp:28
shareable_value_list & add_shareable_value(c_string pname, enum type_t q)
type_t
Enumeration to define the types of the a shareable value can be.
vecN is a simple static array class with no virtual functions and no memory overhead. Supports runtim array index checking and STL style iterators via pointer iterators.
Definition: vecN.hpp:42
c_array< const c_string > shareable_values(enum type_t q) const
file c_array.hpp
shareable_value_list & add_uint(c_string pname)
file util.hpp
vecN< unsigned int, type_number_types > number_shareable_values(void) const
A c_array is a wrapper over a C pointer with a size parameter to facilitate bounds checking and provi...
Definition: c_array.hpp:43
shareable_value_list & add_int(c_string pname)
const char * c_string
Conveniant typedef for C-style strings.
Definition: util.hpp:135
shareable_value_list & add_float(c_string pname)
void swap(shareable_value_list &obj)
file string_array.hpp