HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OP_NodeVerb.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: OP_NodeVerb.h ( OP Library, C++)
7  *
8  * COMMENTS:
9  * Verb-based API for OP cooking mechanisms. OPs can return
10  * one of these objects to describe how they cook, allowing the
11  * cook engine to perform additional optimizations.
12  *
13  * Because how to actually cook is rather bespoke, this is mostly
14  * a category specific registration class.
15  */
16 
17 #ifndef __OP_NodeVerb_h__
18 #define __OP_NodeVerb_h__
19 
20 #include "OP_API.h"
21 #include "OP_NodeParms.h"
22 #include "OP_OpTypeId.h"
23 #include <UT/UT_StringHolder.h>
24 
25 class UT_StringArray;
26 
27 ///
28 /// OP_NodeVerb
29 ///
30 /// This should be a singleton class. Build it with the Register
31 /// template to allow it to be discoverable by name.
32 ///
34 {
35 public:
37  virtual ~OP_NodeVerb() {}
38 
39  OP_NodeVerb(const OP_NodeVerb &) = delete;
40  OP_NodeVerb &operator=(const OP_NodeVerb &) = delete;
41 
42  template <typename T>
43  class Register
44  {
45  public:
47  {
48  myVerb = new T();
50  }
52  {
54  delete myVerb;
55  }
56 
57  const T *get() const { return myVerb; }
58 
59  private:
60  T *myVerb;
61 
62  };
63 
64  /// When working with a specific category one will use allocCache
65  /// and allocParms, which these should chain to in the category baseclass.
66  virtual OP_NodeCache *baseAllocCache() const
67  { return new OP_NodeCache; }
68 
69  virtual OP_NodeParms *baseAllocParms() const = 0;
70 
71  virtual UT_StringHolder name() const = 0;
72  virtual OP_OpTypeId category() const = 0;
73 
74  /// Finds a verb which matches the given name
75  static const OP_NodeVerb *lookupCategoryVerb(OP_OpTypeId cat, const UT_StringRef &name);
76  static void listCategoryVerbs(OP_OpTypeId cat, UT_StringArray &verbnames);
77 
78  // Note: The category is present in the verb so not required.
79  static void registerVerb(OP_NodeVerb *verb);
80  static void unregisterVerb(OP_NodeVerb *verb);
81 
82 protected:
83 };
84 
85 #endif
virtual ~OP_NodeVerb()
Definition: OP_NodeVerb.h:37
static void unregisterVerb(OP_NodeVerb *verb)
virtual OP_NodeCache * baseAllocCache() const
Definition: OP_NodeVerb.h:66
OP_OpTypeId
Definition: OP_OpTypeId.h:18
GLuint const GLchar * name
Definition: glcorearb.h:786
#define OP_API
Definition: OP_API.h:10
static void registerVerb(OP_NodeVerb *verb)