Page principale | Liste des namespaces | Hiérarchie des classes | Liste par ordre alphabétique | Liste des composants | Liste des fichiers | Composants | Déclarations

Timer.h

Aller à la documentation de ce fichier.
00001 /*=========================================================================
00002 UberSim Source Code Release
00003 -------------------------------------------------------------------------
00004 Copyright (C) 2002 Manuela Veloso, Brett Browning, Mike Bowling,
00005                    James Bruce; {mmv, brettb, mhb, jbruce}@cs.cmu.edu
00006                    Erick Tryzelaar {erickt}@andrew.cmu.edu
00007 School of Computer Science, Carnegie Mellon University
00008 -------------------------------------------------------------------------
00009 This software is distributed under the GNU General Public License,
00010 version 2.  If you do not have a copy of this licence, visit
00011 www.gnu.org, or write: Free Software Foundation, 59 Temple Place,
00012 Suite 330 Boston, MA 02111-1307 USA.  This program is distributed
00013 in the hope that it will be useful, but WITHOUT ANY WARRANTY,
00014 including MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00015 -------------------------------------------------------------------------*/
00016 
00017 #ifndef __SIM_TIMER_H__
00018 #define __SIM_TIMER_H__
00019 
00020 #include "nommgr.h"
00021 #include <queue>
00022 #include "mmgr.h"
00029 class Entity;
00030 class Event;
00031 
00032 class Timer
00033 {
00034     public:
00035         static Timer* getInstance ();
00036 
00037     public:
00038         ~Timer ();
00039 
00040     public:
00041         void initialize ();
00042         void shutdown   ();
00043 
00044     public:
00045     void clearEvents (Entity* entity);    // clearEvents(entity)
00046         void addEvent    (Entity* entity, Event* event, Real deltaTime, int ID=-1, unsigned int syncIndex=0);
00047         void clearEvents ();     // clearAllEvents()
00048   
00049     public:
00050         void beginFrame ();
00051         void frame      ();
00052         void endFrame   ();
00053 
00054   public:
00055     int queueSize();
00056     void print();
00057     bool isEmpty(unsigned int syncIndex);
00058         
00059     protected:
00060         Timer ();
00061         
00062     protected:
00063         struct Node
00064         {
00065             Entity* entity;
00066             Event*  event;
00067             Real    endTime;
00068 
00069             Node (Entity* entity, Event* event, Real endTime);
00070       void print ();
00071     #ifndef TIMERDYN
00072       bool operator > (const Node& node) const;
00073     #else
00074       bool operator > (const Node * node) const;
00075     #endif    
00076         };
00077         
00078     protected:
00079         bool isInitialized;
00080         bool isShutdown;
00081     int qs;
00082     #ifndef TIMERDYN    
00083         std::priority_queue<Node, std::vector<Node>, std::greater<Node> > queue;
00084   #else
00085         std::priority_queue<Node *, std::vector<Node *>, std::greater<Node *> > queue;
00086   #endif
00087 };
00088 
00089 #endif

Généré le Mon Mar 1 01:29:41 2004 par doxygen 1.3.3