HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
BRAY_ProceduralFactory.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: BRAY_ProceduralFactory.h (BRAY Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __BRAY_ProceduralFactory__
12 #define __BRAY_ProceduralFactory__
13 
14 #include "BRAY_API.h"
15 #include <GT/GT_Handles.h>
16 #include <UT/UT_Map.h>
17 #include <UT/UT_NonCopyable.h>
18 #include <UT/UT_StringHolder.h>
19 #include <UT/UT_StringMap.h>
20 
21 class UT_JSONWriter;
22 class BRAY_AttribList;
23 class BRAY_Procedural;
24 
25 /// Provides an interface to bind Hydra USD primitives to Karma primitives.
26 ///
27 /// The constructor/destructor typically look like this: @code
28 /// Subclass::Subclass()
29 /// {
30 /// bind("tokenname");
31 /// }
32 /// Subclass::~Subclass()
33 /// {
34 /// unbind("tokenname");
35 /// }
36 /// @endcode
39 {
40 public:
41  /// When the factory is instantiated, it will be registered with the name
42  /// given.
44  virtual ~BRAY_ProceduralFactory();
45 
46  /// Return the name of the factory
47  const UT_StringHolder &name() const { return myName; }
48 
49  /// Create a procedural
50  BRAY_Procedural *createProcedural() const;
51 
52  /// @{
53  /// Get the static of supported parameters by the procedural
54  /// Procedurals are also given an opportunity to construct
55  /// on the fly tables after going through the list of attributes
56  /// defined on points.
57  virtual const BRAY_AttribList *paramList() const = 0;
58  /// @}
59 
60  /// A flag to determine whether or not this procedural accepts
61  /// parameters from outside it's parameter list.
62  /// If this is enabled, not only will the parameters from
63  /// @c paramList() be added, but also any parameters that
64  /// match the @c matchExtraParam() method
65  virtual bool acceptsExtraParameters() const { return false; };
66 
67  /// Determine whether this attribute should be added as an extra
68  /// parameter.
69  /// This will only be called if @c acceptsExtraParameters() returns true
70  virtual bool matchExtraParameter(const UT_StringHolder &attrib_name) const
71  {
72  return false;
73  };
74 
75 
76  /// The list of procedurals is stored in a map of {name, ProceduralFactory}
79 
80  /// @{
81  /// Access the list of all the registered procedurals
82  static const MapType &procedurals();
83  static iterator begin() { return procedurals().begin(); }
84  static iterator end() { return procedurals().end(); }
85  /// @}
86 
87  /// @{
88  /// Print list of procedural factory types
89  static void print();
90  static void print(UT_JSONWriter &w);
91  /// @}
92 
93 protected:
94  /// Create a procedural
95  virtual BRAY_Procedural *create() const = 0;
96 
97  /// Provide some extra info for this procedural used when printing help
98  virtual const UT_StringHolder &extraHelp() const
99  {
101  }
102 private:
103  UT_StringHolder myName;
104 };
105 
106 extern "C" {
107  /// Register a new procedural. This method should allocate a new
108  /// sub-class of the BRAY_ProceduralFactory.
110 }
111 
112 #endif
#define SYS_VISIBILITY_EXPORT
const UT_StringHolder & name() const
Return the name of the factory.
virtual const UT_StringHolder & extraHelp() const
Provide some extra info for this procedural used when printing help.
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:37
static const UT_StringHolder theEmptyString
virtual bool matchExtraParameter(const UT_StringHolder &attrib_name) const
GLuint const GLchar * name
Definition: glcorearb.h:786
Parent::const_iterator const_iterator
Definition: UT_StringMap.h:51
MapType::const_iterator iterator
Each BRAY_Object can define a list of attributes that it can evaluate.
virtual bool acceptsExtraParameters() const
#define BRAY_API
Definition: BRAY_API.h:12
SYS_VISIBILITY_EXPORT void BRAYregisterProcedural()
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:857
FMT_INLINE void print(format_string< T...> fmt, T &&...args)
Definition: core.h:2976