HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CE_SnippetCache.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: CE_SnippetCach.h ( CE Library, C++)
7  *
8  * COMMENTS: Proivdes a way to create caches for snippet -> code
9  */
10 
11 #ifndef __CE_SnippetCache__
12 #define __CE_SnippetCache__
13 
14 #include "CE_API.h"
15 #include "CE_Precision.h"
16 #include "CE_Snippet.h"
17 
18 #include <UT/UT_String.h>
19 #include <UT/UT_StringHolder.h>
20 #include <UT/UT_Vector3.h>
21 #include <UT/UT_Vector4.h>
22 #include <UT/UT_Array.h>
23 #include <UT/UT_SharedPtr.h>
24 #include <UT/UT_StringMap.h>
25 #include <UT/UT_Ramp.h>
26 #include <UT/UT_Error.h>
27 #include <UT/UT_Lock.h>
28 
29 class UT_ErrorManager;
30 class UT_Options;
31 
33 {
34 public:
35  struct SnippetParms
36  {
39  bool myImportPrequel = false;
40  bool myAlign = false;
41  bool myVDBTiles = false;
42  bool myTimeInc = false;
43  bool myTime = false;
44  bool mySimFrame = false;
45  bool myIteration = false;
46  bool myXNoise = false;
47  bool operator==(const SnippetParms &a) const
48  {
49  if (myWritebackName != a.myWritebackName) return false;
50  if (myKernelName != a.myKernelName) return false;
51  if (myRunOver != a.myRunOver) return false;
52  if (myImportPrequel != a.myImportPrequel) return false;
53  if (myAlign != a.myAlign) return false;
54  if (myVDBTiles != a.myVDBTiles) return false;
55  if (myTimeInc != a.myTimeInc) return false;
56  if (myTime != a.myTime) return false;
57  if (mySimFrame != a.mySimFrame) return false;
58  if (myIteration != a.myIteration) return false;
59  if (myXNoise != a.myXNoise) return false;
60  return true;
61  }
62  bool operator!=(const SnippetParms &a) const
63  {
64  return !(*this == a);
65  }
66  };
67  cl::Program lookupCode(UT_StringRef attriboption) const;
68  void stashCode(UT_StringRef attriboption, cl::Program prog);
69  bool validate(const UT_Array<CE_Snippet::Binding> &bindings,
70  SnippetParms parms) const;
71 
72  UT_StringHolder expandedCode() const { return myExpandedCode; }
73  CE_Snippet::RunOver runover() const { return myFinalRunOver; }
74  const UT_Array<CE_Snippet::Binding> &overlayBindings() const { return myOverlayBindings; }
75 
76 protected:
78 
79  // Initial values
82 
85 
86  // We have a separate program per attribute option.
89  friend class CE_SnippetCache;
90 };
91 
93 
95 {
96 public:
97  CE_SnippetCacheEntrySPtr findSnippet(UT_StringRef code) const;
98  void purgeSnippet(UT_StringRef code);
99 
100  CE_SnippetCacheEntrySPtr cacheSnippet(
101  const UT_StringHolder &code,
102  const UT_StringHolder &expandedcode,
103  CE_Snippet::RunOver finalrunover,
104  const UT_Array<CE_Snippet::Binding> &overlaybindings,
105  const UT_Array<CE_Snippet::Binding> &initialbindings,
107 
108 protected:
109  mutable UT_Lock myLock;
111 };
112 
113 #endif
UT_StringHolder myKernelName
#define CE_API
Definition: CE_API.h:13
UT_StringMap< cl::Program > myProgs
CE_Snippet::RunOver myFinalRunOver
UT_StringHolder expandedCode() const
bool myIteration
bool myImportPrequel
GLboolean GLboolean GLboolean GLboolean a
Definition: glcorearb.h:1222
const UT_Array< CE_Snippet::Binding > & overlayBindings() const
UT_StringHolder myExpandedCode
SnippetParms myInitialParms
bool myTime
std::shared_ptr< T > UT_SharedPtr
Wrapper around std::shared_ptr.
Definition: UT_SharedPtr.h:36
UT_Array< CE_Snippet::Binding > myOverlayBindings
UT_SharedPtr< CE_SnippetCacheEntry > CE_SnippetCacheEntrySPtr
bool myXNoise
UT_StringHolder myWritebackName
CE_Snippet::RunOver myRunOver
bool myTimeInc
bool mySimFrame
A map of string to various well defined value types.
Definition: UT_Options.h:84
GA_API const UT_StringHolder parms
UT_Array< CE_Snippet::Binding > myInitialBindings
bool myAlign
A global error manager scope.
bool myVDBTiles
bool operator!=(const SnippetParms &a) const
CE_Snippet::RunOver runover() const
bool operator==(const SnippetParms &a) const
UT_StringMap< CE_SnippetCacheEntrySPtr > myCache
Program interface that implements cl_program.
Definition: cl.hpp:2649
UT_Lock myProgLock