HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CH_EventManager.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: CH_EventManager.h ( Channel Library, C++)
7  *
8  * COMMENTS:
9  * CH_EventManager
10  * . this is the class that manages channel event handlers
11  * . there is one global channel manager
12  * CH_EventHandler
13  * . objects of this type handle events and do things such as:
14  * . keeping track of added channels
15  * . sending out events on destruction
16  * CH_AutoEventHandler
17  * . this class is provided for convenience
18  * . if constructed with a CH_EventHandler, it will register
19  * it with the event manager; when the AutoEventHandler object
20  * goes out of scope, it will unregerister and destroy the
21  * event handler.
22  */
23 
24 #ifndef __CH_EventManager__
25 #define __CH_EventManager__
26 
27 #include "CH_API.h"
28 #include <UT/UT_Map.h>
29 #include <UT/UT_StringHolder.h>
30 
31 class CH_Channel;
32 
33 /*
34  * the difference between CH_CHANNELS_MAJOR_CHANGE and CH_CHANNEL_CHANGED is that
35  * the former indicates a major change to the segments and will lead to an
36  * OP_PARM_ANIMATED event being sent out in OP_Channels, whereas the latter is
37  * not so major.
38  *
39  * order matters with these events
40  */
41 typedef enum {
42  CH_UNCHANGED, // used to dirty caches without sending extra
43  // events (see PRM_Parm::indirectChange())
44  CH_CHANNELS_DELETED, // one or more fewer channels (data: NULL)
45  CH_CHANNELS_ADDED, // new channel (singular?)
46  CH_CHANNELS_MAJOR_CHANGE, // segment pointers changed/added/removed, etc.
47  CH_CHANNEL_CHANGED, // key values changed, etc.
48  CH_CHANNEL_UICHANGED, // eg. expression mode
49  CH_PARM_ENABLE_CHANGED, // parm enable state changed
50  CH_PARM_VISIBLE_CHANGED, // parm visible state changed
51  CH_CHANNELS_MOVED, // time value(s) changed
52  CH_PERMISSION_CHANGED, // permission to this channel changed
53 
54  // These CH_GROUP* events are used by the CH_Manager only
55  CH_GROUP_CREATED, // must be first CH_GROUP item!
61  CH_GROUP_CHANGED, // must be last CH_GROUP item!
62 
68 
71 
72 CH_API extern const char * CHeventNames[CH_CHANGE_TYPE_COUNT];
73 
74 // UTformat support.
75 static inline size_t
76 format(char *buffer, size_t buffer_size, const CH_CHANGE_TYPE &v)
77 {
79  if (!buffer)
80  return s.length();
81  else
82  {
83  size_t len = std::min(size_t(s.length()), buffer_size);
84  ::memcpy(buffer, s.c_str(), len);
85  return len;
86  }
87 }
88 
89 
91 {
92 public:
94  virtual ~CH_EventHandler() {}
95  virtual void event( CH_CHANGE_TYPE, void * );
96 
98  {
99  return new CH_EventHandler;
100  }
101 };
102 
103 typedef CH_EventHandler *(*CH_EventHandlerCreator)();
104 
105 
106 class CH_Collection;
107 
109 {
110 public:
112  virtual ~CH_EventHandlerHash();
113  virtual void event( CH_CHANGE_TYPE, void * );
114 
116  {
117  return new CH_EventHandlerHash;
118  }
119 protected:
120  void removeReferencingEvents(void *data);
121 private:
123  bool myScopeChanged;
124  CH_Collection *myRootCollection;
125 };
126 
128 {
129 public:
130  CH_EventManager();
131  virtual ~CH_EventManager();
132 
133  void beginHandlingEvents( CH_EventHandlerCreator creator );
134  void endHandlingEvents();
135 
136  CH_EventHandler *getHandler();
137 
138  bool enabled() const;
139  void setEnabled(bool e);
140 
141 private:
142  CH_EventHandler *myDefaultHandler;
143  CH_EventHandler *myCurrentHandler;
144  int myLevels;
145  bool myEnabled;
146 };
147 
149 
150 // The following functions are provided for convenience:
151 CH_API void CHevent( CH_CHANGE_TYPE, void * );
152 
154 {
155 public:
157  {
159  }
160 
162  {
164  }
165 };
166 
168 {
169 public:
171  : myEnabled(enable)
172  {
173  if( myEnabled )
175  }
176 
178  {
179  if( myEnabled )
181  }
182 private:
183  bool myEnabled;
184 };
185 
186 #endif
GLdouble s
Definition: glew.h:1390
static CH_EventHandler * newHandler()
CH_EventHandler *(* CH_EventHandlerCreator)()
CH_AutoEventHandler(CH_EventHandlerCreator creator)
const GLdouble * v
Definition: glew.h:1391
CH_AutoEventHandlerEx(CH_EventHandlerCreator creator, bool enable)
CH_API const char * CHeventNames[CH_CHANGE_TYPE_COUNT]
CH_CHANGE_TYPE
exint length() const
virtual ~CH_EventHandler()
static CH_EventHandler * newHandler()
GLuint buffer
Definition: glew.h:1680
GLint GLenum GLsizei GLint GLsizei const void * data
Definition: glew.h:1379
void endHandlingEvents()
CH_API void CHevent(CH_CHANGE_TYPE, void *)
CH_API CH_EventManager * CHgetEventManager()
SYS_FORCE_INLINE const char * c_str() const
cl_event event
Definition: glew.h:3695
GLenum GLsizei const GLuint GLboolean enabled
Definition: glew.h:2579
#define CH_API
Definition: CH_API.h:10
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: glew.h:1254
vint4 min(const vint4 &a, const vint4 &b)
Definition: simd.h:4694
virtual void event(CH_CHANGE_TYPE, void *)
GLboolean enable
Definition: glew.h:2745
void beginHandlingEvents(CH_EventHandlerCreator creator)
GLenum GLsizei len
Definition: glew.h:7752