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  const UT_Options &stage_variables)
46  { }
47 
48  virtual bool processSavePath(const UT_StringRef &asset_path,
49  const UT_StringRef &referencing_layer_path,
50  bool asset_is_layer,
51  UT_String &newpath,
53  { return false; }
54 
55  virtual bool processReferencePath(const UT_StringRef &asset_path,
56  const UT_StringRef &referencing_layer_path,
57  bool asset_is_layer,
58  UT_String &newpath,
60  { return false; }
61 
63  const UT_StringRef &asset_expression,
64  const UT_StringRef &referencing_layer_path,
65  bool asset_is_layer,
66  UT_String &newpath,
68  { return false; }
69 
70  virtual bool processLayer(const UT_StringRef &identifier,
72  { return false; }
73 
74  virtual UT_StringHolder displayName() const = 0;
75  virtual const PI_EditScriptedParms *parameters() const = 0;
76 
77  virtual bool hidden() const
78  { return false; }
79 };
83 
84 // ============================================================================
85 /// Keeps a list of known processors that can translate a USD output path
86 /// during a save operation.
87 ///
89 {
90 public:
91  /// Returns a singelton instance.
92  static HUSD_OutputProcessorRegistry &get();
93 
94  /// Returns a list of the names of all available processors.
95  UT_StringArray processorNames() const;
96 
97  /// Returns the processor that matches the supplied name.
98  HUSD_OutputProcessorPtr createProcessor(const UT_StringRef &name) const;
99 
100  /// Adds the processor to the list of known processors.
101  void registerOutputProcessor(
102  const UT_StringHolder &name,
103  const HUSD_OutputProcessorFactory &factory);
104 
105  /// Removes the processor from the list of known processors.
106  void unregisterOutputProcessor(
107  const UT_StringRef &name);
108 
109  /// Removes all processors from the registry. Should only be called on
110  /// shutdown of the process.
111  void clear();
112 
113 private:
114  /// Map of known output processors, keyed by their internal names.
115  UT_StringMap<HUSD_OutputProcessorFactory> myProcessorFactories;
116 };
117 
120 
121 #endif
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 void beginSave(OP_Node *config_node, const UT_Options &config_overrides, OP_Node *lop_node, fpreal t, const UT_Options &stage_variables)
virtual bool processReferenceExpression(const UT_StringRef &asset_expression, const UT_StringRef &referencing_layer_path, bool asset_is_layer, UT_String &newpath, UT_String &error)
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