All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
usdInPluginRegistry.h
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 PXRUSDKATANA_USDIN_PLUGINREGISTRY_H
25 #define PXRUSDKATANA_USDIN_PLUGINREGISTRY_H
26 
27 #include "pxr/pxr.h"
28 #include "usdKatana/usdInPrivateData.h"
29 
30 #include "pxr/usd/usd/prim.h"
31 #include "pxr/base/tf/type.h"
32 
33 #include <FnGeolib/op/FnGeolibOp.h>
34 
35 PXR_NAMESPACE_OPEN_SCOPE
36 
38 
41 {
42 public:
44  template <typename T>
45  static void RegisterUsdType(
46  const std::string& opName)
47  {
48  if (TfType tfType = TfType::Find<T>()) {
49  _RegisterUsdType(tfType.GetTypeName(), opName);
50  }
51  else {
52  TF_CODING_ERROR("Could not find type.");
53  }
54  }
55 
57  template <typename T>
59  const std::string& opName)
60  {
61  if (TfType tfType = TfType::Find<T>()) {
62  _RegisterUsdTypeForSite(tfType.GetTypeName(), opName);
63  }
64  else {
65  TF_CODING_ERROR("Could not find type.");
66  }
67  }
68 
70  static void RegisterUnknownUsdType(const std::string& opName)
71  {
72  _RegisterUsdType(TfType::GetUnknownType().GetTypeName(), opName);
73  }
74 
77  static void RegisterKind(
78  const TfToken& kind,
79  const std::string& opName);
80 
84  static void RegisterKindForSite(
85  const TfToken& kind,
86  const std::string& opName);
87 
90  static bool HasKindsForSite();
91 
98  static bool FindUsdType(
99  const TfToken& usdTypeName,
100  std::string* opName);
101 
108  static bool FindUsdTypeForSite(
109  const TfToken& usdTypeName,
110  std::string* opName);
111 
114  static bool FindKind(
115  const TfToken& kind,
116  std::string* opName);
117 
121  static bool FindKindForSite(
122  const TfToken& kind,
123  std::string* opName);
124 
125 
130 
137  static void RegisterLightListFnc(LightListFnc);
138 
141  static void ExecuteLightListFncs(
143 
144 
145 
146 
147 
148  typedef void (*OpDirectExecFnc)(
149  const PxrUsdKatanaUsdInPrivateData& privateData,
150  FnKat::GroupAttribute opArgs,
151  FnKat::GeolibCookInterface& interface);
152 
162  static void RegisterOpDirectExecFnc(
163  const std::string& opName,
164  OpDirectExecFnc fnc);
165 
171  static void ExecuteOpDirectExecFnc(
172  const std::string& opName,
173  const PxrUsdKatanaUsdInPrivateData& privateData,
174  FnKat::GroupAttribute opArgs,
175  FnKat::GeolibCookInterface& interface);
176 
177 
178 
179 
186  static void RegisterLocationDecoratorOp(const std::string& opName);
187 
188 
189  // \brief Run the registered plug-in ops at a katana location
192  static FnKat::GroupAttribute ExecuteLocationDecoratorOps(
193  const PxrUsdKatanaUsdInPrivateData& privateData,
194  FnKat::GroupAttribute opArgs,
195  FnKat::GeolibCookInterface& interface);
196 
197 
198 private:
199  static void _RegisterUsdType(
200  const std::string& tfTypeName,
201  const std::string& opName);
202 
203  static void _RegisterUsdTypeForSite(
204  const std::string& tfTypeName,
205  const std::string& opName);
206 
207  static bool _DoFindKind(
208  const TfToken& kind,
209  std::string* opName,
210  const std::map<TfToken, std::string>& reg);
211 
212 };
213 
216 #define PXRUSDKATANA_USDIN_PLUGIN_DECLARE(T) \
217 PXR_NAMESPACE_USING_DIRECTIVE \
218 class T : public FnKat::GeolibOp\
219 {\
220 public:\
221  static void setup(FnKat::GeolibSetupInterface& interface);\
222  static void cook(FnKat::GeolibCookInterface& interface);\
223  static void directExec(const PxrUsdKatanaUsdInPrivateData& privateData, \
224  FnKat::GroupAttribute opArgs, \
225  Foundry::Katana::GeolibCookInterface &interface);\
226 };\
227 
228 #define PXRUSDKATANA_USDIN_PLUGIN_DEFINE(T, argsName, opArgsName, interfaceName) \
231 void T::setup(FnKat::GeolibSetupInterface& interface) {\
232  interface.setThreading(FnKat::GeolibSetupInterface::ThreadModeConcurrent);\
233 }\
234 void _PxrUsdKatana_PrimReaderFn_##T(\
235  const PxrUsdKatanaUsdInPrivateData&,\
236  FnKat::GroupAttribute, \
237  Foundry::Katana::GeolibCookInterface &);\
238 void T::cook(FnKat::GeolibCookInterface& interface) \
239 {\
240  if (PxrUsdKatanaUsdInPrivateData* args \
241  = PxrUsdKatanaUsdInPrivateData::GetPrivateData(interface)) {\
242  _PxrUsdKatana_PrimReaderFn_##T(*args, interface.getOpArg(), interface);\
243  }\
244 }\
245 void T::directExec(const PxrUsdKatanaUsdInPrivateData& privateData, \
246  FnKat::GroupAttribute opArgs, \
247  Foundry::Katana::GeolibCookInterface &interface)\
248 {\
249  _PxrUsdKatana_PrimReaderFn_##T(privateData, opArgs, interface);\
250 }\
251 void _PxrUsdKatana_PrimReaderFn_##T(\
252  const PxrUsdKatanaUsdInPrivateData& argsName,\
253  FnKat::GroupAttribute opArgsName,\
254  Foundry::Katana::GeolibCookInterface &interfaceName )\
255 
256 
259 #define PXRUSDKATANA_USDIN_PLUGIN_DECLARE_WITH_FLUSH(T) \
260 PXR_NAMESPACE_USING_DIRECTIVE \
261 class T : public FnKat::GeolibOp\
262 {\
263 public:\
264  static void setup(FnKat::GeolibSetupInterface& interface);\
265  static void cook(FnKat::GeolibCookInterface& interface);\
266  static void flush();\
267  static void directExec(const PxrUsdKatanaUsdInPrivateData& privateData, \
268  FnKat::GroupAttribute opArgs, \
269  Foundry::Katana::GeolibCookInterface &interface);\
270 };\
271 
272 #define PXRUSDKATANA_USDIN_PLUGIN_DEFINE_WITH_FLUSH(T, argsName, opArgsName, interfaceName, flushFnc) \
275 void T::setup(FnKat::GeolibSetupInterface& interface) {\
276  interface.setThreading(FnKat::GeolibSetupInterface::ThreadModeConcurrent);\
277 }\
278 void T::flush() {\
279  flushFnc();\
280 }\
281 void _PxrUsdKatana_PrimReaderFn_##T(\
282  const PxrUsdKatanaUsdInPrivateData&,\
283  FnKat::GroupAttribute, \
284  Foundry::Katana::GeolibCookInterface &);\
285 void T::cook(FnKat::GeolibCookInterface& interface) \
286 {\
287  if (PxrUsdKatanaUsdInPrivateData* args \
288  = PxrUsdKatanaUsdInPrivateData::GetPrivateData(interface)) {\
289  _PxrUsdKatana_PrimReaderFn_##T(*args, interface.getOpArg(), interface);\
290  }\
291 }\
292 void T::directExec(const PxrUsdKatanaUsdInPrivateData& privateData, \
293  FnKat::GroupAttribute opArgs,\
294  Foundry::Katana::GeolibCookInterface &interface)\
295 {\
296  _PxrUsdKatana_PrimReaderFn_##T(privateData, opArgs, interface);\
297 }\
298 void _PxrUsdKatana_PrimReaderFn_##T(\
299  const PxrUsdKatanaUsdInPrivateData& argsName,\
300  FnKat::GroupAttribute opArgsName, \
301  Foundry::Katana::GeolibCookInterface &interfaceName )\
302 
303 #define USD_OP_REGISTER_PLUGIN(PLUGIN_CLASS, PLUGIN_NAME, PLUGIN_MAJOR_VERSION, PLUGIN_MINOR_VERSION) \
306  REGISTER_PLUGIN(PLUGIN_CLASS, PLUGIN_NAME, PLUGIN_MAJOR_VERSION, PLUGIN_MINOR_VERSION) \
307  PxrUsdKatanaUsdInPluginRegistry::RegisterOpDirectExecFnc(PLUGIN_NAME, PLUGIN_CLASS::directExec);
308 
309 
310 PXR_NAMESPACE_CLOSE_SCOPE
311 
312 #endif // PXRUSDKATANA_USDIN_PLUGINREGISTRY_H
Private data for each non-root invocation of PxrUsdIn.
static void RegisterKindForSite(const TfToken &kind, const std::string &opName)
Registers opName to extend or override the core op for kind (and possibly other kinds that are descen...
Maintains the registry for usd types and kind.
static TF_API TfType const & GetUnknownType()
Return an empty TfType, representing the unknown type.
static void RegisterLocationDecoratorOp(const std::string &opName)
Register an op name which will be called for every katana location created from a UsdPrim...
static void RegisterUnknownUsdType(const std::string &opName)
Register opName to handle the prims with an unknown usd type .
static bool FindUsdType(const TfToken &usdTypeName, std::string *opName)
Finds a reader if one exists for usdTypeName.
void(* LightListFnc)(PxrUsdKatanaUtilsLightListAccess &)
The signature for a plug-in &quot;light list&quot; function.
#define TF_CODING_ERROR(fmt, args)
Issue an internal programming error, but continue execution.
Definition: diagnostic.h:87
static void RegisterUsdTypeForSite(const std::string &opName)
Register site-specific opName to handle the usd type .
static bool FindKind(const TfToken &kind, std::string *opName)
Finds a reader if one exists for kind.
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:89
static void ExecuteOpDirectExecFnc(const std::string &opName, const PxrUsdKatanaUsdInPrivateData &privateData, FnKat::GroupAttribute opArgs, FnKat::GeolibCookInterface &interface)
Directly invoke the cook method of a PxrUsdIn extension op Ops called in this manner should retrieve ...
Utility class for building a light list.
Definition: utils.h:198
static void RegisterUsdType(const std::string &opName)
Register opName to handle the usd type .
static void ExecuteLightListFncs(PxrUsdKatanaUtilsLightListAccess &access)
Run the registered plug-in light list functions at a light path.
static bool FindKindForSite(const TfToken &kind, std::string *opName)
Finds a reader that extends or overrides the core op, if one exists, for kind.
static bool HasKindsForSite()
Returns true if there are any site-specific ops registered for at least one kind. ...
static void RegisterLightListFnc(LightListFnc)
Register a plug-in function to be called at a light path.
static void RegisterOpDirectExecFnc(const std::string &opName, OpDirectExecFnc fnc)
Makes an PxrUsdIn kind.
static bool FindUsdTypeForSite(const TfToken &usdTypeName, std::string *opName)
Finds a site-specific reader if one exists for usdTypeName.
TfType represents a dynamic runtime type.
Definition: type.h:70
static FnKat::GroupAttribute ExecuteLocationDecoratorOps(const PxrUsdKatanaUsdInPrivateData &privateData, FnKat::GroupAttribute opArgs, FnKat::GeolibCookInterface &interface)
and UsdPrim.
static void RegisterKind(const TfToken &kind, const std::string &opName)
Registers opName to handle kind (and possibly other kinds that are descendents of kind in the kind hi...