HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RAY_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: RAY_ProceduralFactory.h (RAY Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __RAY_ProceduralFactory__
12 #define __RAY_ProceduralFactory__
13 
14 #include "RAY_API.h"
15 #include <UT/UT_Array.h>
16 #include <UT/UT_StringHolder.h>
17 #include <UT/UT_StringMap.h>
18 #include <UT/UT_Lock.h>
19 
20 class VPRM_Stack;
21 class RAY_Procedural;
22 class RAY_ProceduralArg;
23 
24 /// The procedural factory is used to store the definitions of all the
25 /// procedurals in mantra. The factory is passed to the registerProcedural()
26 /// method on plugins.
28 {
29 public:
32 
33  /// Class to create a procedural
35  {
36  public:
38  virtual ~ProcDefinition();
39 
40  /// Name of the procedural
41  const UT_StringHolder &name() const { return myName; }
42 
43  /// Query which DSO file was used to define this procedural
44  const UT_StringHolder &dsoname() const { return myDSOName; }
45 
46  /// Set the DSO file. This is only required for old-school procedural
47  /// definitions.
48  void setDSOName(const UT_StringHolder &dso) { myDSOName = dso; }
49 
50  /// Create a procedural, and pass ownership of the instance to mantra
51  virtual RAY_Procedural *create() const = 0;
52  /// Provide a const reference to the arguments for the procedural
53  virtual const RAY_ProceduralArg *arguments() const = 0;
54 
55  /// @{
56  /// @private
57  /// Access to internals
58  void processArguments();
59  VPRM_Stack &stack() const { return *myStack; }
60  UT_Lock &lock() const { return myLock; }
61  /// @}
62 
63  private:
64  mutable UT_Lock myLock;
65  UT_StringHolder myName;
66  UT_StringHolder myDSOName;
67  VPRM_Stack *myStack;
68  };
69 
70  /// Initialize procedurals
71  void initialize();
72 
73  /// Add a new procedural to the factory. The factory takes ownership of
74  /// the definition. Returns whether the procedural was stored.
75  ///
76  /// Setting HOUDINI_DSO_ERROR to 2 or greater will cause the procedurals to
77  /// be printed out as they get added to mantra.
78  bool insert(ProcDefinition *def, bool replace_existing=true);
79 
80  /// Look up a procedural by name
81  const ProcDefinition *find(const UT_StringRef &name) const;
82 
83  /// Extract a list of procedural definitions
84  void getList(UT_Array<const ProcDefinition *> &list) const;
85 
86  /// Return number of procedurals
87  size_t size() const { return myProcs.size(); }
88 private:
90 };
91 
92 #endif
size_t size() const
Return number of procedurals.
Procedural primitive for mantra (RAY)
void setDSOName(const UT_StringHolder &dso)
const UT_StringHolder & name() const
Name of the procedural.
OPENVDB_API void initialize()
Global registration of basic types.
Definition: logging.h:318
GLuint const GLchar * name
Definition: glcorearb.h:785
Parameter definition for arguments to RAY_Procedural.
#define RAY_API
Definition: RAY_API.h:12
const UT_StringHolder & dsoname() const
Query which DSO file was used to define this procedural.
Class to create a procedural.