All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
shadingModeRegistry.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 PXRUSDMAYA_SHADING_MODE_REGISTRY_H
25 #define PXRUSDMAYA_SHADING_MODE_REGISTRY_H
26 
28 
29 #include "usdMaya/api.h"
33 
34 #include "pxr/pxr.h"
35 
36 #include "pxr/base/tf/registryManager.h"
37 #include "pxr/base/tf/singleton.h"
38 #include "pxr/base/tf/staticTokens.h"
39 #include "pxr/base/tf/token.h"
40 #include "pxr/base/tf/weakBase.h"
41 
42 #include <maya/MObject.h>
43 
44 #include <string>
45 
46 
47 PXR_NAMESPACE_OPEN_SCOPE
48 
49 
50 #define PXRUSDMAYA_SHADINGMODE_TOKENS \
51  (none) \
52  (displayColor)
53 
54 TF_DECLARE_PUBLIC_TOKENS(UsdMayaShadingModeTokens,
55  PXRUSDMAYA_API,
56  PXRUSDMAYA_SHADINGMODE_TOKENS);
57 
58 
60 
68 {
69 public:
70 
71  static UsdMayaShadingModeExporterCreator GetExporter(const TfToken& name) {
72  return GetInstance()._GetExporter(name);
73  }
74  static UsdMayaShadingModeImporter GetImporter(const TfToken& name) {
75  return GetInstance()._GetImporter(name);
76  }
77  static TfTokenVector ListExporters() {
78  return GetInstance()._ListExporters();
79  }
80  static TfTokenVector ListImporters() {
81  return GetInstance()._ListImporters();
82  }
83 
84  PXRUSDMAYA_API
85  static UsdMayaShadingModeRegistry& GetInstance();
86 
87  PXRUSDMAYA_API
88  bool RegisterExporter(
89  const std::string& name,
90  UsdMayaShadingModeExporterCreator fn);
91 
92  PXRUSDMAYA_API
93  bool RegisterImporter(
94  const std::string& name,
95  UsdMayaShadingModeImporter fn);
96 
97 private:
98  UsdMayaShadingModeExporterCreator _GetExporter(const TfToken& name);
99  UsdMayaShadingModeImporter _GetImporter(const TfToken& name);
100 
101  TfTokenVector _ListExporters();
102  TfTokenVector _ListImporters();
103 
106  friend class TfSingleton<UsdMayaShadingModeRegistry>;
107 };
108 
109 #define DEFINE_SHADING_MODE_IMPORTER(name, contextName) \
110 static MObject _ShadingModeImporter_##name(UsdMayaShadingModeImportContext*); \
111 TF_REGISTRY_FUNCTION_WITH_TAG(UsdMayaShadingModeImportContext, name) {\
112  UsdMayaShadingModeRegistry::GetInstance().RegisterImporter(#name, &_ShadingModeImporter_##name); \
113 }\
114 MObject _ShadingModeImporter_##name(UsdMayaShadingModeImportContext* contextName)
115 
116 
117 PXR_NAMESPACE_CLOSE_SCOPE
118 
119 
120 #endif
Manage a single instance of an object (see.
Definition: singleton.h:122
#define TF_DECLARE_WEAK_PTRS(type)
Define standard weak pointer types.
Definition: declarePtrs.h:62
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:89
#define TF_DECLARE_PUBLIC_TOKENS(...)
Macro to define public tokens.
Definition: staticTokens.h:118
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:438
We understand that shading may want to be imported/exported in many ways across studios.
Enable a concrete base class for use with TfWeakPtr.
Definition: weakBase.h:142