HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
extComputationContextInternal.h
Go to the documentation of this file.
1 //
2 // Copyright 2017 Pixar
3 //
4 // Licensed under the terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 #ifndef PXR_IMAGING_HD_EXT_COMPUTATION_CONTEXT_INTERNAL_H
8 #define PXR_IMAGING_HD_EXT_COMPUTATION_CONTEXT_INTERNAL_H
9 
10 #include "pxr/pxr.h"
11 
12 #include "pxr/imaging/hd/api.h"
14 
15 #include <map>
16 
18 
19 ///
20 /// Hydra implementation of the HdExtComputationContext public interface.
21 /// The class provides additional API for setting up the context.
22 ///
24 public:
25  HD_API
27 
28  HD_API
30 
31  ///
32  /// Obtains the value of an named input to the computation.
33  ///
34  /// The code will issue a coding error and return a empty value
35  /// if the input is missing.
36  ///
37  HD_API
38  virtual const VtValue &GetInputValue(const TfToken &name) const override;
39 
40  ///
41  /// Obtains the value of an named input to the computation.
42  ///
43  /// If the input isn't present, nullptr will be returned.
44  ///
45  HD_API
46  virtual const VtValue *GetOptionalInputValuePtr(
47  const TfToken &name) const override;
48  ///
49  /// Sets the value of the specified output.
50  ///
51  HD_API
52  virtual void SetOutputValue(const TfToken &name,
53  const VtValue &output) override;
54 
55 
56  /// Adds the named input to the execution environment.
57  /// If the input already exists, the value is not replaced.
58  HD_API
59  void SetInputValue(const TfToken &name, const VtValue &input);
60 
61  /// Fetches the named output from the execution environment.
62  /// returns false if the output is not present.
63  HD_API
64  bool GetOutputValue(const TfToken &name, VtValue *output) const;
65 
66  /// returns true is an error occur in processing, such that the
67  /// outputs are invalid.
68  HD_API
69  bool HasComputationError();
70 
71  ///
72  /// Called to indicate an error occurred while executing a computation
73  /// so that it's output are invalid.
74  ///
75  HD_API
76  virtual void RaiseComputationError() override;
77 
78 private:
79  typedef std::map<TfToken, VtValue> ValueMap;
80 
81  ValueMap m_inputs;
82  ValueMap m_outputs;
83  bool m_compuationError;
84 
85 
86  HdExtComputationContextInternal(const HdExtComputationContextInternal &)
87  = delete;
88  HdExtComputationContextInternal &operator = (
89  const HdExtComputationContextInternal &) = delete;
90 
91 };
92 
94 
95 #endif // PXR_IMAGING_HD_EXT_COMPUTATION_CONTEXT_INTERNAL_H
HD_API bool GetOutputValue(const TfToken &name, VtValue *output) const
HD_API void SetInputValue(const TfToken &name, const VtValue &input)
#define HD_API
Definition: api.h:23
virtual HD_API ~HdExtComputationContextInternal()
Definition: token.h:70
virtual HD_API const VtValue * GetOptionalInputValuePtr(const TfToken &name) const override
GLuint const GLchar * name
Definition: glcorearb.h:786
virtual HD_API void SetOutputValue(const TfToken &name, const VtValue &output) override
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
virtual HD_API const VtValue & GetInputValue(const TfToken &name) const override
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
virtual HD_API void RaiseComputationError() override
Definition: value.h:146