HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PI_Manager.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: PI_Manager.h.h ( PI Library, C++)
7  *
8  * COMMENTS:
9  *
10  * Manager to update/remove/add PIs and bindings.
11  */
12 
13 #ifndef __PI_Manager__
14 #define __PI_Manager__
15 
16 #include "PI_API.h"
17 #include "PI_OHLGroup.h"
18 #include <OP/OP_Error.h>
19 #include <OP/OP_Node.h> // OP_Node cannot be forward declared in this file
20 #include <UT/UT_Array.h>
21 #include <UT/UT_String.h>
22 #include <iosfwd>
23 #include <utility>
24 
25 
26 class PI_OHLPersistent;
27 class PI_OpHandleLink;
28 class PI_Manager;
29 
30 typedef enum {
43 
45  PI_ChangeType ctype,
46  void *data);
47 typedef void (*PI_GroupCallback)(PI_OHLGroup *group,
48  PI_ChangeType ctype,
49  void *data);
50 
52 
54 {
55 public:
56  UT_String getFreePIName(const char *name) const;
57  int addPI(const char *name, const PI_OpHandleLink *refpi);
58  int addPI(const char *name, const char *pitype);
59  void removePI(PI_OHLPersistent *pi);
60  void removeAllPIs();
61  int getPIIndex(const char *name) const;
62  int getPIIndex(const PI_OpHandleLink &pi) const;
63  int getNumPIs() const;
64  PI_OHLPersistent *getPI(int index) const;
65  void swapPIs(int idx1, int idx2);
66 
67  UT_String getFreeGroupName(const char *name) const;
68  int addGroup(const char *name);
69  void removeGroup(PI_OHLGroup *group);
70  int getGroupIndex(const char *name) const;
71  int getNumGroups() const;
72  PI_OHLGroup *getGroup(int index) const;
73  void swapGroups(int idx1, int idx2);
74 
75  void addPItoGroup(int pi, int group);
76  void removePIfromGroup(int pi, int group);
77  void clearGroup(int group);
78 
79  void addPICallback(PI_PICallback cb, void *data);
80  void removePICallback(PI_PICallback cb, void *data);
81  void piChanged(PI_OHLPersistent *pi,
82  PI_ChangeType ctype) const;
83  void addGroupCallback(PI_GroupCallback cb, void *data);
84  void removeGroupCallback(PI_GroupCallback cb, void *data);
85  void groupChanged(PI_OHLGroup *group,
86  PI_ChangeType ctype) const;
87 
88  OP_ERROR save(std::ostream &os) const;
89  OP_ERROR savePersistentPIs(std::ostream &os, int i = -1) const;
90  OP_ERROR savePersistentGroups(std::ostream &os, int i = -1) const;
91 
92  // This function is used when collapsing or extracting subnets.
93  // It takes all references to the "from" ops and changes them to
94  // refer to the corresponding "to" op.
95  void getRefreshPICommands(std::ostream &commands,
96  UT_Array<OP_Node *> &fromOps,
97  UT_Array<OP_Node *> &toOps);
98  void getRefreshPICommands(std::ostream &commands, OP_Node *op);
99 
100 private:
101  PI_Manager();
102  virtual ~PI_Manager();
103 
104  void installCommands() const;
105  void deinstallCommands() const;
106  void addPIsWithOp(OP_Node &node, UT_Array<int> &pis) const;
107 
108  typedef std::pair<PI_PICallback, void *> PI_PICallbackInfo;
109  typedef std::pair<PI_GroupCallback, void *> PI_GroupCallbackInfo;
110 
111  PI_OHLGroup myAllGroup;
112  UT_Array<PI_OHLGroup *> myOHLGroups;
113  UT_Array<PI_PICallbackInfo> myPICallbacks;
114  UT_Array<PI_GroupCallbackInfo> myGroupCallbacks;
115 
116  friend PI_API PI_Manager *PIgetManager();
117 };
118 
119 #endif
120 
PI_API PI_Manager * PIgetManager()
PI_ChangeType
Definition: PI_Manager.h:30
void
Definition: png.h:1083
GLboolean * data
Definition: glcorearb.h:131
UT_ErrorSeverity
Definition: UT_Error.h:25
#define PI_API
Definition: PI_API.h:10
void(* PI_PICallback)(PI_OHLPersistent *pi, PI_ChangeType ctype, void *data)
Definition: PI_Manager.h:44
GLuint const GLchar * name
Definition: glcorearb.h:786
void(* PI_GroupCallback)(PI_OHLGroup *group, PI_ChangeType ctype, void *data)
Definition: PI_Manager.h:47
__hostdev__ constexpr T pi()
Pi constant taken from Boost to match old behaviour.
Definition: NanoVDB.h:976
GLuint index
Definition: glcorearb.h:786
Definition: format.h:895