All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
chaserRegistry.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_CHASER_REGISTRY_H
25 #define PXRUSDMAYA_CHASER_REGISTRY_H
26 
28 
29 #include "usdMaya/api.h"
30 #include "usdMaya/chaser.h"
31 #include "usdMaya/jobArgs.h"
32 #include "usdMaya/util.h"
33 
34 #include "pxr/pxr.h"
35 
36 #include "pxr/base/tf/declarePtrs.h"
37 #include "pxr/base/tf/registryManager.h"
38 #include "pxr/base/tf/singleton.h"
39 
40 #include "pxr/usd/usd/stage.h"
41 
42 #include <functional>
43 
44 PXR_NAMESPACE_OPEN_SCOPE
45 
46 
48 
59 {
60 public:
61 
69  public:
70  typedef UsdMayaUtil::MDagPathMap<SdfPath> DagToUsdMap;
71 
72  PXRUSDMAYA_API
74  const UsdStagePtr& stage,
75  const DagToUsdMap& dagToUsdMap,
76  const UsdMayaJobExportArgs& jobArgs);
77 
82  PXRUSDMAYA_API
83  UsdStagePtr GetStage() const;
84 
89  PXRUSDMAYA_API
90  const DagToUsdMap& GetDagToUsdMap() const;
91 
96  PXRUSDMAYA_API
97  const UsdMayaJobExportArgs& GetJobArgs() const;
98 
99  private:
100  UsdStagePtr _stage;
101  const DagToUsdMap& _dagToUsdMap;
102  const UsdMayaJobExportArgs& _jobArgs;
103  };
104 
105  typedef std::function<UsdMayaChaser* (const FactoryContext&)> FactoryFn;
106 
111  PXRUSDMAYA_API
112  bool RegisterFactory(
113  const std::string& name,
114  FactoryFn fn);
115 
117  PXRUSDMAYA_API
118  UsdMayaChaserRefPtr Create(
119  const std::string& name,
120  const FactoryContext& context) const;
121 
123  PXRUSDMAYA_API
124  std::vector<std::string> GetAllRegisteredChasers() const;
125 
126  PXRUSDMAYA_API
127  static UsdMayaChaserRegistry& GetInstance();
128 
129 private:
132  friend class TfSingleton<UsdMayaChaserRegistry>;
133 };
134 
139 #define PXRUSDMAYA_DEFINE_CHASER_FACTORY(name, contextArgName) \
140 static UsdMayaChaser* _ChaserFactory_##name(const UsdMayaChaserRegistry::FactoryContext&); \
141 TF_REGISTRY_FUNCTION_WITH_TAG(UsdMayaChaserRegistry, name) {\
142  UsdMayaChaserRegistry::GetInstance().RegisterFactory(#name, &_ChaserFactory_##name); \
143 }\
144 UsdMayaChaser* _ChaserFactory_##name(const UsdMayaChaserRegistry::FactoryContext& contextArgName)
145 
146 
147 PXR_NAMESPACE_CLOSE_SCOPE
148 
149 #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
std::map< MDagPath, V, _CmpDag > MDagPathMap
Mapping of DAG paths to an arbitrary type.
Definition: util.h:97
PXRUSDMAYA_API UsdStagePtr GetStage() const
Returns the exported stage.
PXRUSDMAYA_API std::vector< std::string > GetAllRegisteredChasers() const
Returns the names of all registered chasers.
PXRUSDMAYA_API UsdMayaChaserRefPtr Create(const std::string &name, const FactoryContext &context) const
Creates a chaser using the factoring registered to name.
PXRUSDMAYA_API const UsdMayaJobExportArgs & GetJobArgs() const
Returns the current job args.
PXRUSDMAYA_API const DagToUsdMap & GetDagToUsdMap() const
Returns a map that maps full MDagPath&#39;s to Usd prim paths.
PXRUSDMAYA_API bool RegisterFactory(const std::string &name, FactoryFn fn)
Register a chaser factory.
Holds data that can be accessed when constructing a UsdMayaChaser object.
Registry for chaser plugins.
Enable a concrete base class for use with TfWeakPtr.
Definition: weakBase.h:142