/[adonthell]/adonthell/src/event/manager.h
ViewVC logotype

Diff of /adonthell/src/event/manager.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by ksterker, Tue Dec 7 16:46:27 2004 UTC revision 1.3 by ksterker, Tue Mar 8 09:41:47 2005 UTC
# Line 1  Line 1 
1  /*  /*
2     $Id$     $Id$
3    
4     Copyright (C) 2000/2001/2002/2003/2004 Kai Sterker <kaisterker@linuxgames.com>     Copyright (C) 2000/2001/2002/2003/2004 Kai Sterker <kaisterker@linuxgames.com>
5     Part of the Adonthell Project http://adonthell.linuxgames.com     Part of the Adonthell Project http://adonthell.linuxgames.com
6    
7     Adonthell is free software; you can redistribute it and/or modify     Adonthell is free software; you can redistribute it and/or modify
8     it under the terms of the GNU General Public License as published by     it under the terms of the GNU General Public License as published by
9     the Free Software Foundation; either version 2 of the License, or     the Free Software Foundation; either version 2 of the License, or
10     (at your option) any later version.     (at your option) any later version.
11    
12     Adonthell is distributed in the hope that it will be useful,     Adonthell is distributed in the hope that it will be useful,
13     but WITHOUT ANY WARRANTY; without even the implied warranty of     but WITHOUT ANY WARRANTY; without even the implied warranty of
14     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15     GNU General Public License for more details.     GNU General Public License for more details.
16    
17     You should have received a copy of the GNU General Public License     You should have received a copy of the GNU General Public License
18     along with Adonthell; if not, write to the Free Software     along with Adonthell; if not, write to the Free Software
19     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20  */  */
21    
22    
23  /**  /**
24   * @file   event/manager.h   * @file   event/manager.h
25   * @author Kai Sterker <kaisterker@linuxgames.com>   * @author Kai Sterker <kaisterker@linuxgames.com>
26   *   *
27   * @brief  Declares the %event %manager class   * @brief  Declares the %event %manager class
28   *   *
29   */   */
30    
31  #ifndef EVENT_MANAGER_H  #ifndef EVENT_MANAGER_H
32  #define EVENT_MANAGER_H  #define EVENT_MANAGER_H
33    
34  #include "event/factory.h"  #include "event/types.h"
35  #include "event/manager_base.h"  #include "event/factory.h"
36    #include "event/manager_base.h"
37  namespace events  
38  {  namespace events
39      /**  {
40       * It ensures global access to the individual %event managers.      /**
41       */       * It ensures global access to the individual %event managers.
42      class manager       */
43      {      class manager
44      public:      {
45          /**      public:
46           * Instanciate the actual event managers. Event managers          /**
47           * can be specific to a certain event, or take care of           * Unregister an %event %listener.
48           * different events.           *
49           */           * @param li pointer to the %listener to unregister.
50          static void init ();           */
51                static void remove (listener* li)
52          /**          {
53           * Delete the %event managers.              manager_base *manager = event_type::get_manager (li->type ());
54           */              if (manager != NULL)
55          static void cleanup ();              {
56                        li->set_registered (false);
57          /**                  manager->remove (li);
58           * Unregister an %event.              }
59           *          }
60           * @param ev pointer to the %event to unregister.      
61           */          /**
62          static void remove (listener* li)           * Check if an %event corresponding to ev exists, and execute it.
63          {           *
64              li->set_registered (false);           * @param ev %event to raise.
65              Manager[li->type ()]->remove (li);           */
66          }          static void raise_event (const event* ev)
67                {
68          /**              manager_base *manager = event_type::get_manager (((event *) ev)->type ());
69           * Check if an %event corresponding to ev exists, and execute it.              if (manager != NULL)
70           *              {
71           * @param ev %event to raise.                  manager->raise_event (ev);
72           */              }
73          static void raise_event (const event* ev)          }
74          {      
75              Manager[ev->type ()]->raise_event (ev);      protected:
76          }          /**
77                 * Registers an %event %listener.
78      protected:           *
79          /**           * @param li pointer to the %listener to register.
80           * Registers an %event %listener.           */
81           *          static void add (listener* li)
82           * @param li pointer to the %listener to register.          {
83           */              manager_base *manager = event_type::get_manager (li->type ());
84          static void add (listener* li)              if (manager != NULL)
85          {              {
86              li->set_registered (true);                  li->set_registered (true);
87              Manager[li->type ()]->add (li);                  manager->add (li);
88          }              }
89                }
90          /**      
91           * Only %event %factory is allowed to register events with the          /**
92           * %event %manager.           * Only %event %factory is allowed to register events with the
93           */           * %event %manager.
94          friend class factory;           */
95                    friend class factory;
96          /**          
97           * As is %listener::resume          /**
98           */           * As is %listener::resume
99          friend void listener::resume ();           */
100                    friend void listener::resume ();
101      private:      };
102          /**  }
103           * A list of the actual %event handlers  #endif // EVENT_MANAGER_H
          */  
         static manager_base* Manager[MAX_EVENTS];  
     };  
 }  
 #endif // EVENT_MANAGER_H  

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26