Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members  

event_handler.hh

00001 /*
00002 *  Name:      event_handler.hh
00003 *  Authors:   Carlos Jimenez Moreno
00004 *             Rafael Jesus Alcantara Perez
00005 *  Summary:   Base Event Handler
00006 *  Date:      $Date: 2003/04/14 00:18:31 $
00007 *  Revision:  $Revision: 1.1 $
00008 *
00009 *  Copyright (C) 1999       Carlos Jimenez Moreno <carlosj@dedalo-ing.com>
00010 *  Copyright (C) 2000-2002  Rafael Jesus Alcantara Perez <rafa@dedalo-ing.com>
00011 *
00012 *  This program is free software; you can redistribute it and/or modify
00013 *  it under the terms of the GNU General Public License as published by
00014 *  the Free Software Foundation; either version 2 of the License, or
00015 *  (at your option) any later version.
00016 *
00017 *  This program is distributed in the hope that it will be useful,
00018 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00019 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020 *  GNU General Public License for more details.
00021 *
00022 *  You should have received a copy of the GNU General Public License
00023 *  along with this program; if not, write to the Free Software
00024 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
00025 *  MA 02111-1307, USA.
00026 */
00027 
00028 
00029 #ifndef _MPCL_EVENT_EVENT_HANDLER__
00030 #define _MPCL_EVENT_EVENT_HANDLER__
00031 
00032 #include <queue>
00033 
00034 
00036 namespace mpcl
00037 {
00038 
00040   namespace event
00041   {
00042 
00048     template <typename TEvent>
00049     class TEventHandler
00050     {
00051 
00052       protected:
00053 
00055         typedef std::priority_queue<TEvent>   TPriorityQueue;
00056 
00058         TPriorityQueue                        tPriorityQueue;
00059 
00060 
00061       public:
00062 
00063         //
00064         // C O N S T R U C T O R S
00065         //
00066 
00068         virtual ~TEventHandler (void) {}
00069 
00074         virtual TEvent pop (void)
00075         {
00076           TEvent   tEvent = tPriorityQueue.top();
00077 
00078           tPriorityQueue.pop();
00079           return tEvent;
00080         }
00081 
00086         virtual void push (const TEvent& rktSOURCE_EVENT)
00087         {
00088           tPriorityQueue.push (rktSOURCE_EVENT);
00089         }
00090 
00091 
00092       public:
00093 
00094         //
00095         //  S E L E C T O R S
00096         //
00097 
00102         virtual bool isEmpty (void) const
00103         {
00104           return tPriorityQueue.empty();
00105         }
00106 
00107     };  // TEventHandler
00108 
00109   }  // namespace event
00110 
00111 }  // namespace mpcl
00112 
00113 
00114 #endif // not _MPCL_EVENT_EVENT_HANDLER__

Generated on Mon Oct 13 02:35:23 2003 for MPCL by doxygen1.2.18