ssim.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef _ssim_h
00030 #define _ssim_h
00031
00052 namespace ssim {
00053
00056 extern const char * Version;
00057
00060 typedef int ProcessId;
00061
00064 const ProcessId NULL_PROCESSID = -1;
00065
00080 typedef unsigned long Time;
00081
00084 const Time INIT_TIME = 0;
00085
00112 class Event {
00113 public:
00114 Event(): refcount(0) {};
00115 virtual ~Event() {};
00116
00117 private:
00118 mutable unsigned refcount;
00119 friend class SimImpl;
00120 friend class Sim;
00121 };
00122
00128 class Process {
00129 public:
00130 virtual ~Process() {};
00131
00140 virtual void init(void) {};
00141
00196 virtual void process_event(const Event * msg) {};
00197
00205 virtual void stop(void) {};
00206 };
00207
00214 class ProcessWithPId : public Process {
00215 public:
00227 ProcessId activate() throw();
00228
00235 ProcessId pid() const throw();
00236
00237 ProcessWithPId() throw();
00238
00239 private:
00240 ProcessId process_id;
00241 };
00242
00251 class SimErrorHandler {
00252 public:
00261 virtual void clear() throw() {}
00262
00272 virtual void handle_busy(ProcessId p, const Event * e) throw() {}
00273
00283 virtual void handle_terminated(ProcessId p, const Event * e) throw() {}
00284 };
00285
00308 class Sim {
00309 public:
00319 static ProcessId create_process(Process *) throw();
00320
00322 static int stop_process(ProcessId) throw();
00324 static void stop_process() throw();
00325
00336 static void clear() throw();
00337
00347 static void self_signal_event(const Event *) throw();
00348
00357 static void self_signal_event(const Event *, Time delay) throw();
00358
00368 static void signal_event(ProcessId, const Event *) throw();
00377 static void signal_event(ProcessId, const Event *, Time) throw();
00378
00453 static void advance_delay(Time) throw();
00454
00476 static ProcessId this_process() throw();
00477
00495 static Time clock() throw();
00496
00498 static void run_simulation();
00500 static void stop_simulation() throw();
00501
00514 static void set_stop_time(Time t = INIT_TIME) throw();
00515
00523 static void set_error_handler(SimErrorHandler *) throw();
00524 };
00525
00526 };
00527
00528 #endif
00529