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 
30 class CH_Channel;
31 
32 /*
33  * the difference between CH_CHANNELS_MAJOR_CHANGE and CH_CHANNEL_CHANGED is that
34  * the former indicates a major change to the segments and will lead to an
35  * OP_PARM_ANIMATED event being sent out in OP_Channels, whereas the latter is
36  * not so major.
37  *
38  * order matters with these events
39  */
40 typedef enum {
41  CH_UNCHANGED, // used to dirty caches without sending extra
42  // events (see PRM_Parm::indirectChange())
43  CH_CHANNELS_DELETED, // one or more fewer channels (data: NULL)
44  CH_CHANNELS_ADDED, // new channel (singular?)
45  CH_CHANNELS_MAJOR_CHANGE, // segment pointers changed/added/removed, etc.
46  CH_CHANNEL_CHANGED, // key values changed, etc.
47  CH_CHANNEL_UICHANGED, // eg. expression mode
48  CH_PARM_ENABLE_CHANGED, // parm enable state changed
49  CH_PARM_VISIBLE_CHANGED, // parm visible state changed
50  CH_CHANNELS_MOVED, // time value(s) changed
51  CH_PERMISSION_CHANGED, // permission to this channel changed
52 
53  // These CH_GROUP* events are used by the CH_Manager only
54  CH_GROUP_CREATED, // must be first CH_GROUP item!
60  CH_GROUP_CHANGED, // must be last CH_GROUP item!
61 
67 
70 
71 CH_API extern const char * CHeventNames[CH_CHANGE_TYPE_COUNT];
72 
74 {
75 public:
77  virtual ~CH_EventHandler() {}
78  virtual void event( CH_CHANGE_TYPE, void * );
79 
81  {
82  return new CH_EventHandler;
83  }
84 };
85 
86 typedef CH_EventHandler *(*CH_EventHandlerCreator)();
87 
88 
89 class CH_Collection;
90 
92 {
93 public:
95  virtual ~CH_EventHandlerHash();
96  virtual void event( CH_CHANGE_TYPE, void * );
97 
99  {
100  return new CH_EventHandlerHash;
101  }
102 protected:
103  void removeReferencingEvents(void *data);
104 private:
106  bool myScopeChanged;
107  CH_Collection *myRootCollection;
108 };
109 
111 {
112 public:
113  CH_EventManager();
114  virtual ~CH_EventManager();
115 
116  void beginHandlingEvents( CH_EventHandlerCreator creator );
117  void endHandlingEvents();
118 
119  CH_EventHandler *getHandler();
120 
121  bool enabled() const;
122  void setEnabled(bool e);
123 
124 private:
125  CH_EventHandler *myDefaultHandler;
126  CH_EventHandler *myCurrentHandler;
127  int myLevels;
128  bool myEnabled;
129 };
130 
132 
133 // The following functions are provided for convenience:
134 CH_API void CHevent( CH_CHANGE_TYPE, void * );
135 
137 {
138 public:
140  {
142  }
143 
145  {
147  }
148 };
149 
150 #endif
static CH_EventHandler * newHandler()
CH_EventHandler *(* CH_EventHandlerCreator)()
CH_AutoEventHandler(CH_EventHandlerCreator creator)
GLenum GLenum GLsizei const GLuint GLboolean enabled
Definition: glcorearb.h:2538
struct _cl_event * event
Definition: glcorearb.h:2960
CH_API const char * CHeventNames[CH_CHANGE_TYPE_COUNT]
CH_CHANGE_TYPE
virtual ~CH_EventHandler()
static CH_EventHandler * newHandler()
void endHandlingEvents()
CH_API void CHevent(CH_CHANGE_TYPE, void *)
CH_API CH_EventManager * CHgetEventManager()
GLboolean * data
Definition: glcorearb.h:130
#define CH_API
Definition: CH_API.h:10
virtual void event(CH_CHANGE_TYPE, void *)
void beginHandlingEvents(CH_EventHandlerCreator creator)