All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
glslfxConfig.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 Pixar
3 //
4 // Licensed under the Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 #ifndef PXR_IMAGING_HIO_GLSLFX_CONFIG_H
25 #define PXR_IMAGING_HIO_GLSLFX_CONFIG_H
26 
28 
29 #include "pxr/pxr.h"
30 #include "pxr/imaging/hio/api.h"
31 #include "pxr/base/tf/token.h"
32 #include "pxr/base/vt/dictionary.h"
33 
34 #include <string>
35 
36 PXR_NAMESPACE_OPEN_SCOPE
37 
46 {
47 public:
56  enum Role {
57  RoleNone = 0,
58  RoleColor = 1,
59  };
60 
65  class Parameter {
66  public:
67  Parameter(std::string const & name,
68  VtValue const & defaultValue,
69  std::string const & docString = "",
70  Role const & role = RoleNone) :
71  name(name),
72  defaultValue(defaultValue),
73  docString(docString),
74  role(role) { }
75 
76  std::string name;
77  VtValue defaultValue;
78  std::string docString;
79  Role role;
80  };
81 
82  typedef std::vector<Parameter> Parameters;
83 
88  class Texture {
89  public:
90  Texture(std::string const & name,
91  VtValue const & defaultValue,
92  std::string const & docString = "") :
93  name(name),
94  defaultValue(defaultValue),
95  docString(docString) { }
96 
97  std::string name;
98  VtValue defaultValue;
99  std::string docString;
100  };
101 
102  typedef std::vector<Texture> Textures;
103 
108  class Attribute {
109  public:
110  Attribute(std::string const & name,
111  VtValue const & defaultValue,
112  std::string const & docString = "") :
113  name(name),
114  defaultValue(defaultValue),
115  docString(docString) { }
116 
117  std::string name;
118  VtValue defaultValue;
119  std::string docString;
120  };
121 
122  typedef std::vector<Attribute> Attributes;
123 
128  HIO_API
129  static HioGlslfxConfig * Read(TfToken const & technique,
130  std::string const & input,
131  std::string const & filename,
132  std::string *errorStr);
133 
134  typedef std::vector<std::string> SourceKeys;
135 
137 
139  HIO_API
140  SourceKeys GetSourceKeys(TfToken const & shaderStageKey) const;
141 
143  HIO_API
144  Parameters GetParameters() const;
145 
147  HIO_API
148  Textures GetTextures() const;
149 
151  HIO_API
152  Attributes GetAttributes() const;
153 
155  HIO_API
157 
158 private:
159  // private ctor. should only be called by ::Read
160  HioGlslfxConfig(TfToken const& technique,
161  VtDictionary const & dict,
162  std::string *errorStr);
163 
164  void _Init(VtDictionary const & dict, std::string *errorStr);
165 
166  Parameters _GetParameters(VtDictionary const & dict,
167  std::string *errorStr) const;
168  Textures _GetTextures(VtDictionary const & dict,
169  std::string *errorStr) const;
170 
171  Attributes _GetAttributes(VtDictionary const & dict,
172  std::string *errorStr) const;
173 
174  MetadataDictionary _GetMetadata(VtDictionary const & dict,
175  std::string *errorStr) const;
176 
177  typedef std::map<std::string, SourceKeys> _SourceKeyMap;
178  _SourceKeyMap _GetSourceKeyMap(VtDictionary const & dict,
179  std::string *errorStr) const;
180 
181  TfToken _technique;
182  Parameters _params;
183  Textures _textures;
184  Attributes _attributes;
185  MetadataDictionary _metadata;
186  _SourceKeyMap _sourceKeyMap;
187 };
188 
189 
190 PXR_NAMESPACE_CLOSE_SCOPE
191 
192 #endif
HIO_API Parameters GetParameters() const
Return the parameters specified in the configuration.
A map with string keys and VtValue values.
Definition: dictionary.h:63
A class representing an attribute.
Definition: glslfxConfig.h:108
static HIO_API HioGlslfxConfig * Read(TfToken const &technique, std::string const &input, std::string const &filename, std::string *errorStr)
Create a new HioGlslfxConfig from an input string.
A class representing the configuration of a glslfx file.
Definition: glslfxConfig.h:45
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:87
HIO_API SourceKeys GetSourceKeys(TfToken const &shaderStageKey) const
Return the set of source keys for a particular shader stage.
A class representing a texture.
Definition: glslfxConfig.h:88
HIO_API Attributes GetAttributes() const
Returns the attributes specified in the configuration.
HIO_API MetadataDictionary GetMetadata() const
Returns the metadata specified in the configuration.
A class representing a parameter.
Definition: glslfxConfig.h:65
HIO_API Textures GetTextures() const
Return the textures specified in the configuration.
Role
Enumerates Roles that parameters can have.
Definition: glslfxConfig.h:56
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:174