HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PI_ClassManager.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: Base Direct manipulation library (C++)
7  *
8  * COMMENTS:
9  * Manages the registration and linking of PI classes to PI names.
10  *
11  */
12 #ifndef __PI_ClassManager_H__
13 #define __PI_ClassManager_H__
14 
15 #include "PI_API.h"
16 #include <UT/UT_ValArray.h>
17 
19 {
20 public:
23 
24  void addPI(const char *name, void *cs);
25  void addSelector(const char *name, void *data, void *cs);
26 
27  int getNumPIs() const
28  { return myPINames.entries(); }
29  const char *getPIName(int i) const
30  { return myPINames(i); }
31  void *getPIConstructor(int i) const
32  { return myPIConstructors(i); }
33 
34  int getNumSelectors() const
35  { return mySelectorNames.entries(); }
36  const char *getSelectorName(int i) const
37  { return mySelectorNames(i); }
38  void *getSelectorData(int i) const
39  { return mySelectorData(i); }
40  void *getSelectorConstructor(int i) const
41  { return mySelectorConstructors(i); }
42 
43 protected:
49 };
50 
52 
53 #define PI_SETUP() \
54 class init { public: init(); int dummy; }; \
55 static init initializer;
56 
57 #define PI_REGISTER(name, classname) \
58 classname::init classname::initializer; \
59 classname::init::init() \
60 { PIgetClassManager()->addPI(name, (void *)classname::ourConstructor); }
61 
63 {
64  public:
65  PI_SelectorTable(const char *name, void *data, void *constructor)
66  : myName(name), myData(data), myConstructor(constructor) { }
67  const char *myName;
68  void *myData;
70 };
71 
72 #define SELECTOR_SETUP() \
73 class init { public: init(); int dummy; }; \
74 static init initializer;
75 
76 #define SELECTOR_REGISTER(name, data, classname)\
77 classname::init classname::initializer; \
78 classname::init::init() \
79 { PIgetClassManager()->addSelector(name, data, \
80  (void *)classname::ourConstructor); }
81 
82 #define SELECTOR_SETUP_TABLE() \
83 class init { public: init(); int dummy; }; \
84 static init initializer;
85 
86 #define SELECTOR_REGISTER_TABLE_BEGIN(classname) \
87 classname::init classname::initializer; \
88 classname::init::init() \
89 { PI_SelectorTable table[] = {
90 
91 #define SELECTOR_REGISTER_TABLE_ENTRY(name, data, constructor) \
92  PI_SelectorTable(name, (void *)data, (void *)constructor),
93 
94 #define SELECTOR_REGISTER_TABLE_END() \
95  PI_SelectorTable(0, 0, 0) }; \
96  for( int i = 0; table[i].myName; i++ ) \
97  PIgetClassManager()->addSelector(table[i].myName, \
98  table[i].myData, \
99  table[i].myConstructor); }
100 
101 // This enum must be kept in sync with the geometry_type.val radio strip
102 // in $FUSE/ViewExtra.ui!
104 {
111  PI_NUM_GEOTYPES // sentinel
112 };
113 
115 
117 {
118 public:
120  : myGeometryType(PI_GEOTYPE_INVALID),
121  myMenuEntryIndex(0),
122  myListTerminatorFlag(1) {}
124  int menu_entry_index = -1)
125  : myGeometryType(geo_type),
126  myMenuEntryIndex(menu_entry_index),
127  myListTerminatorFlag(0) {}
128 
129  PI_GeometryType myGeometryType; // what type of selection?
130  int myMenuEntryIndex; // value to set menu to
131  int myListTerminatorFlag; // used to mark end of list?
132 };
133 
134 #endif
void * getPIConstructor(int i) const
const char * getPIName(int i) const
PI_GeometryType
#define PI_API
Definition: PI_API.h:10
PI_API PI_ClassManager * PIgetClassManager()
UT_Array< PI_GeometryType > PI_GeometryTypeArray
UT_ValArray< void * > mySelectorData
int getNumPIs() const
UT_ValArray< const char * > myPINames
const char * myName
GLuint const GLchar * name
Definition: glcorearb.h:786
PI_SelectorTable(const char *name, void *data, void *constructor)
PI_GeometryType myGeometryType
const char * getSelectorName(int i) const
int myListTerminatorFlag
int myMenuEntryIndex
PI_SelectionEntry()
UT_ValArray< const char * > mySelectorNames
UT_ValArray< void * > myPIConstructors
PI_SelectionEntry(PI_GeometryType geo_type, int menu_entry_index=-1)
void * getSelectorConstructor(int i) const
void * getSelectorData(int i) const
int getNumSelectors() const
Definition: format.h:895
UT_ValArray< void * > mySelectorConstructors