Microsimulation API: ssim::Process Class Reference

Microsimulation API

Public Member Functions | List of all members
ssim::Process Class Reference

Virtual class (interface) representing processes running within the simulator. More...

`#include <ssim.h>`

Inheritance diagram for ssim::Process:
[legend]

## Public Member Functions
virtual | ~Process ()
virtual void | initialize (void)
| action executed when the process is initialized. More...
virtual void | process_event (const Event *msg)
| action executed in response to an event signaled to this process. More...
virtual void | stop (void)
| executed when the process is explicitly stopped. More...

## Detailed Description

Virtual class (interface) representing processes running within the simulator.

A simulated process must implement this basic interface.

Definition at line 125 of file ssim.h.

## Constructor & Destructor Documentation

## ◆ ~Process()

virtual ssim::Process::~Process | ( |  | ) |
| inlinevirtual

Definition at line 127 of file ssim.h.

## Member Function Documentation

## ◆ initialize()

virtual void ssim::Process::initialize | ( | void |  | ) |
| inlinevirtual

action executed when the process is initialized.

This method is not a constructor. It is rather an initialization step that is executed during the simulation when the process is created within the simulation through Sim::create_process. This initialization is guaranteed to be executed before any event is signaled to the process. BREAKING CHANGE: this method was called init().

Reimplemented in ssim::cProcess.

Definition at line 138 of file ssim.h.

## ◆ process_event()

virtual void ssim::Process::process_event | ( | const Event * | msg | ) |
| inlinevirtual

action executed in response to an event signaled to this process.

The Event object signaled through this method should not be used outside this method, other than by signaling it to other processes through Sim::signal_event(). In fact, the Event pointer passed to this method should be considered invalid outside this method, as the simulator proceeds to de-allocate every event object that is not signaled to any other process.

The implementation of this method may specify the duration of the actions associated with this response using the advance_delay method. By default, the duration of an action is 0.

The implementation of this method may use the C++ dynamic_cast feature to select an action on the basis of the actual type of the Event object. Here's an example that illustrates this feature:

class Payment : public Event {
public:
int dollars;
//...
};
class Delivery : public Event {
public:
int count;
string model;
//...
};
class GuitarShop : public Process {
//...
virtual void process_event(const Event * e) {
const Payment * p;
const Delivery * d;
if ((p = dynamic_cast<const Payment *>(e)) != 0) {
cout << "I got a payment for $" << p->dollars << endl;
} else if ((d = dynamic_cast<const Delivery *>(e)) != 0) {
cout << "I got a delivery of " << d->count
<< " " << d->model << " guitars" << endl;
} else {
cerr << "GuitarShop: error: unknown event." << endl;
}
}
};

See also
  Sim::advance_delay(Time).

Reimplemented in ssim::cProcess.

Definition at line 194 of file ssim.h.

## ◆ stop()

virtual void ssim::Process::stop | ( | void |  | ) |
| inlinevirtual

executed when the process is explicitly stopped.

A process is stopped by a call to Sim::stop_process(ProcessId). This method is executed immediately after the process has processed all the events scheduled before the call to Sim::stop_process.

Definition at line 203 of file ssim.h.

The documentation for this class was generated from the following file:

- /home/marcle/src/R/microsimulation/inst/include/siena/ssim.h

ssim::Process::process_event
virtual void process_event(const Event *msg)
action executed in response to an event signaled to this process.
Definition: ssim.h:194