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 HIO_GLSLFX_CONFIG_H
25 #define 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 
38 
47 {
48 public:
57  enum Role {
58  RoleNone = 0,
59  RoleColor = 1,
60  };
61 
66  class Parameter {
67  public:
68  Parameter(std::string const & name,
69  VtValue const & defaultValue,
70  std::string const & docString = "",
71  Role const & role = RoleNone) :
72  name(name),
73  defaultValue(defaultValue),
74  docString(docString),
75  role(role) { }
76 
77  std::string name;
78  VtValue defaultValue;
79  std::string docString;
80  Role role;
81  };
82 
83  typedef std::vector<Parameter> Parameters;
84 
89  class Texture {
90  public:
91  Texture(std::string const & name,
92  VtValue const & defaultValue,
93  std::string const & docString = "") :
94  name(name),
95  defaultValue(defaultValue),
96  docString(docString) { }
97 
98  std::string name;
99  VtValue defaultValue;
100  std::string docString;
101  };
102 
103  typedef std::vector<Texture> Textures;
104 
109  class Attribute {
110  public:
111  Attribute(std::string const & name,
112  std::string const & docString = "") :
113  name(name),
114  docString(docString) { }
115 
116  std::string name;
117  std::string docString;
118  };
119 
120  typedef std::vector<Attribute> Attributes;
121 
126  HIO_API
127  static HioGlslfxConfig * Read(std::string const & input,
128  std::string const & filename,
129  std::string *errorStr);
130 
131  typedef std::vector<std::string> SourceKeys;
132 
134 
136  HIO_API
137  SourceKeys GetSourceKeys(TfToken const & shaderStageKey) const;
138 
140  HIO_API
141  Parameters GetParameters() const;
142 
144  HIO_API
145  Textures GetTextures() const;
146 
148  HIO_API
149  Attributes GetAttributes() const;
150 
152  HIO_API
154 
155 private:
156  // private ctor. should only be called by ::Read
157  HioGlslfxConfig(VtDictionary const & dict, std::string *errorStr);
158 
159  void _Init(VtDictionary const & dict, std::string *errorStr);
160 
161  Parameters _GetParameters(VtDictionary const & dict,
162  std::string *errorStr) const;
163  Textures _GetTextures(VtDictionary const & dict,
164  std::string *errorStr) const;
165 
166  Attributes _GetAttributes(VtDictionary const & dict,
167  std::string *errorStr) const;
168 
169  MetadataDictionary _GetMetadata(VtDictionary const & dict,
170  std::string *errorStr) const;
171 
172  typedef std::map<std::string, SourceKeys> _SourceKeyMap;
173  _SourceKeyMap _GetSourceKeyMap(VtDictionary const & dict,
174  std::string *errorStr) const;
175 
176  Parameters _params;
177  Textures _textures;
178  Attributes _attributes;
179  MetadataDictionary _metadata;
180  _SourceKeyMap _sourceKeyMap;
181 };
182 
183 
184 PXR_NAMESPACE_CLOSE_SCOPE
185 
186 #endif
HIO_API Parameters GetParameters() const
Return the parameters specified in the configuration.
A map with string keys and VtValue values.
Definition: dictionary.h:61
A class representing an attribute.
Definition: glslfxConfig.h:109
A class representing the configuration of a glslfx file.
Definition: glslfxConfig.h:46
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:89
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:89
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:66
static HIO_API HioGlslfxConfig * Read(std::string const &input, std::string const &filename, std::string *errorStr)
Create a new HioGlslfxConfig from an input string.
HIO_API Textures GetTextures() const
Return the textures specified in the configuration.
Role
Enumerates Roles that parameters can have.
Definition: glslfxConfig.h:57
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:182