HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
BRAY_FilterBase.h
Go to the documentation of this file.
1 
2 /*
3  * PROPRIETARY INFORMATION. This software is proprietary to
4  * Side Effects Software Inc., and is not to be reproduced,
5  * transmitted, or disclosed in any way without written permission.
6  *
7  * NAME: BRAY_FilterBase.h (RAY Library, C++)
8  *
9  * COMMENTS:
10  */
11 
12 #ifndef __BRAY_FilterBase__
13 #define __BRAY_FilterBase__
14 
15 #include "BRAY_API.h"
16 #include <SYS/SYS_Hash.h>
17 #include <UT/UT_UniquePtr.h>
18 #include <UT/UT_StringHolder.h>
19 #include <UT/UT_StringArray.h>
20 
21 class UT_Options;
22 class BRAY_FilterInit;
23 
24 /// Base class for image filters. These are any filters which process AOV data
26 {
27 public:
28  BRAY_FilterBase(const UT_Options *o);
29  virtual ~BRAY_FilterBase();
30 
31  /// Return an identifier for this plugin
32  virtual const char *className() const = 0;
33 
34  /// @{
35  /// Return the rasters written and read by this plugin (as computed during
36  /// initialization)
37  const UT_StringArray &writePlanes() const { return myWriteNames; }
38  const UT_StringArray &readPlanes() const { return myReadNames; }
39  /// @}
40  void initialize(BRAY_FilterInit &init,
41  const UT_StringArray &all_aovs)
42  {
43  myWriteNames.clear();
44  myReadNames.clear();
45  if (!getAOVs(init, all_aovs, myWriteNames, myReadNames))
46  {
47  myWriteNames.clear();
48  myReadNames.clear();
49  }
50  }
51 
52  /// Hash of the options passed to the constructor
53  SYS_HashType optionsHash() const { return myOptionsHash; }
54 
55  /// The list of @c available AOV planes in the render is passed in. This is
56  /// the list the renderer has been told to create. The plugin should fill
57  /// the string array of planes which it will @c write into, but also planes
58  /// which it will @c read from. For example, if you want to apply color
59  /// correction to an image plane, you would need to add the plane to the @c
60  /// write array but also to the @c read array.
61  ///
62  /// The method should return @c true if the plugin is valid (false if
63  /// invalid).
64  virtual bool getAOVs(BRAY_FilterInit &init,
65  const UT_StringArray &available,
67  UT_StringArray &read) = 0;
68 
69  /// Return the error if processImage() fails. By default, this returns an
70  /// empty string.
71  virtual const UT_StringHolder &errorMessage() const
72  {
74  }
75 
76  /// Convenience method to add an error using printf style formatting
77  UT_StringHolder makeError(const char *fmt, ...)
79 
80 private:
81  UT_StringArray myWriteNames;
82  UT_StringArray myReadNames;
83  SYS_HashType myOptionsHash;
84 };
85 
86 #endif
const UT_StringArray & readPlanes() const
SYS_HashType optionsHash() const
Hash of the options passed to the constructor.
std::size_t SYS_HashType
Define the type for hash values.
Definition: SYS_Hash.h:19
void read(T &in, bool &v)
Definition: ImfXdr.h:611
Base class for image filters. These are any filters which process AOV data.
static const UT_StringHolder theEmptyString
#define SYS_PRINTF_CHECK_ATTRIBUTE(string_index, first_to_check)
Definition: SYS_Types.h:433
virtual const UT_StringHolder & errorMessage() const
A map of string to various well defined value types.
Definition: UT_Options.h:84
void initialize(BRAY_FilterInit &init, const UT_StringArray &all_aovs)
const UT_StringArray & writePlanes() const
#define BRAY_API
Definition: BRAY_API.h:12
void write(T &out, bool v)
Definition: ImfXdr.h:332