Main Page   Packages   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Search  

C:/temp/src/j2k/QNX4/Group5/Resource.hpp

Go to the documentation of this file.
00001 #ifndef __J2K__Train__Resource_HPP__
00002 #define __J2K__Train__Resource_HPP__
00003 
00004 #define NUM_OF_SWITCHES
00005 #include "Train.h"
00006 #include "constants.h"
00007 #include <iostream.h> //for NULL REMOVE LATER
00008 
00009 class Resource{
00010 public:
00011   Resource();
00012   virtual ~Resource();
00013   BOOL setOwner(Train* train);
00014   BOOL removeOwner(Train* train);
00015   int  numberOfOwners(); 
00016   int  numberOfWaiters();
00017   BOOL addToWaiting(Train* t);
00018   BOOL removeFromWaiting(Train* t);
00019   BOOL moveToOwner();
00020   BOOL isActive(); 
00021   void activate(BOOL resourceActive = TRUE);
00022   virtual BOOL isAvailable();
00023 
00024 protected:
00025   Train* ownerTrains[2];
00026   Direction ownersDirection; 
00027   int numOfOwners;
00028   Train* waitingTrains[2];
00029   int numOfWaiters;
00030   BOOL resourceActive;
00031 };
00032 
00033 class Sector : public Resource {
00034 public:
00035   Sector(BOOL shareAble = FALSE);
00036   virtual ~Sector(); 
00037   BOOL setOwner(Train* train);
00038   void makeShareAble(BOOL shareAble = TRUE);  
00039   virtual BOOL isAvailable();
00040 
00041 private:
00042   BOOL shareAble;
00043   Direction ownersDirection; 
00044 };
00045 
00046 class SwitchPoint:public Resource{
00047 public:
00048   SwitchPoint();
00049   virtual ~SwitchPoint(); 
00050   virtual BOOL isAvailable();
00051   void curve();
00052   void straight();
00053   BOOL isCurved();
00054   BOOL isStraight();
00055 
00056 private:
00057   int switchStatus;
00058 };
00059 
00060 class TrackManager{ 
00061  public:
00062   TrackManager();
00063   virtual ~TrackManager();
00064 
00065   BOOL isSwitchStraight(int s); 
00066   BOOL isSwitchCurve(int s);
00067 
00068   BOOL reserveSwitch(Train* t, int sector); 
00069   void activateSwitch(int sectornumber, BOOL active = TRUE);
00070   BOOL realeaseSwitch(Train* t, int sector);
00071 
00072   BOOL reserveSector(Train* t, int sector);
00073   void activateSector(int sectornumber, BOOL active = TRUE);
00074   BOOL realeaseSector(Train* t, int sector);
00075 
00076   int getSuitation();
00077   void changeSuitation(int currentSuitation);
00078 
00079 private:
00080   SwitchPoint* switchPoint[NUM_OF_SWITCHES];
00081   Sector *sector[SIZE_OF_SECTOR];  
00082   int currentSuitation;
00083 };
00084 
00085 #endif

Generated on Sun Oct 14 18:46:42 2001 for Standard J2K Library by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001