HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HUSD_OutputProcessor.h
Go to the documentation of this file.
1 /*
2  * Copyright 2019 Side Effects Software Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 
18 #ifndef __HUSD_OutputProcessor_h__
19 #define __HUSD_OutputProcessor_h__
20 
21 #include "HUSD_API.h"
22 #include <UT/UT_Function.h>
23 #include <UT/UT_SharedPtr.h>
24 #include <UT/UT_StringArray.h>
25 #include <UT/UT_StringMap.h>
26 
27 class UT_Options;
28 class UT_String;
29 class OP_Node;
31 
32 // ============================================================================
33 /// Performs processing on a USD output path during a save operation.
34 ///
36 {
37 public:
38  /// Standard virtual destructor for this abstract base class.
39  virtual ~HUSD_OutputProcessor() = default;
40 
41  virtual void beginSave(OP_Node *config_node,
42  const UT_Options &config_overrides,
43  OP_Node *lop_node,
44  fpreal t)
45  { }
46 
47  virtual bool processSavePath(const UT_StringRef &asset_path,
48  const UT_StringRef &referencing_layer_path,
49  bool asset_is_layer,
50  UT_String &newpath,
52  { return false; }
53 
54  virtual bool processReferencePath(const UT_StringRef &asset_path,
55  const UT_StringRef &referencing_layer_path,
56  bool asset_is_layer,
57  UT_String &newpath,
59  { return false; }
60 
61  virtual bool processLayer(const UT_StringRef &identifier,
63  { return false; }
64 
65  virtual UT_StringHolder displayName() const = 0;
66  virtual const PI_EditScriptedParms *parameters() const = 0;
67 
68  virtual bool hidden() const
69  { return false; }
70 };
74 
75 // ============================================================================
76 /// Keeps a list of known processors that can translate a USD output path
77 /// during a save operation.
78 ///
80 {
81 public:
82  /// Returns a singelton instance.
83  static HUSD_OutputProcessorRegistry &get();
84 
85  /// Returns a list of the names of all available processors.
86  UT_StringArray processorNames() const;
87 
88  /// Returns the processor that matches the supplied name.
89  HUSD_OutputProcessorPtr createProcessor(const UT_StringRef &name) const;
90 
91  /// Adds the processor to the list of known processors.
92  void registerOutputProcessor(
93  const UT_StringHolder &name,
94  const HUSD_OutputProcessorFactory &factory);
95 
96  /// Removes the processor from the list of known processors.
97  void unregisterOutputProcessor(
98  const UT_StringRef &name);
99 
100  /// Removes all processors from the registry. Should only be called on
101  /// shutdown of the process.
102  void clear();
103 
104 private:
105  /// Map of known output processors, keyed by their internal names.
106  UT_StringMap<HUSD_OutputProcessorFactory> myProcessorFactories;
107 };
108 
111 
112 #endif
virtual void beginSave(OP_Node *config_node, const UT_Options &config_overrides, OP_Node *lop_node, fpreal t)
virtual bool hidden() const
virtual bool processSavePath(const UT_StringRef &asset_path, const UT_StringRef &referencing_layer_path, bool asset_is_layer, UT_String &newpath, UT_String &error)
#define HUSD_API
Definition: HUSD_API.h:32
< returns > If no error
Definition: snippets.dox:2
virtual bool processLayer(const UT_StringRef &identifier, UT_String &error)
std::shared_ptr< T > UT_SharedPtr
Wrapper around std::shared_ptr.
Definition: UT_SharedPtr.h:36
HUSD_API HUSD_OutputProcessorPtr HUSDcreateOutputProcessor(const UT_StringRef &name)
UT_Array< HUSD_OutputProcessorPtr > HUSD_OutputProcessorArray
GLuint const GLchar * name
Definition: glcorearb.h:786
std::function< T > UT_Function
Definition: UT_Function.h:37
GLdouble t
Definition: glad.h:2397
A map of string to various well defined value types.
Definition: UT_Options.h:84
fpreal64 fpreal
Definition: SYS_Types.h:277
virtual bool processReferencePath(const UT_StringRef &asset_path, const UT_StringRef &referencing_layer_path, bool asset_is_layer, UT_String &newpath, UT_String &error)
UT_Function< HUSD_OutputProcessorPtr()> HUSD_OutputProcessorFactory
UT_SharedPtr< HUSD_OutputProcessor > HUSD_OutputProcessorPtr