The class data can be used to model the information that flows through the process being modelled. The class is derived from event to make it possible to gather information about it with the SIM class histogram. So, although strictly spoken data is an event, it will not be activated. Or so to speak, `it will never happen.'
interface data : public event { public: data(int kf = FALSE); // constructor virtual data* new_data(int kf = FALSE); // virtual constructor void currenthandler(datahandler* dh); // set current datahandler datahandler* currenthandler(); // get current datahandler data* source(); // belongs to? void source(data* d); // set source int killflag(); // get killflag; };
The contructor takes a boolean to set the killflag (see also [1]). If the killflag is OK the number of terminated data objects will be counted. This is useful when one wants to run the simulation for a fixed number of data objects. The procedure new_data is a virtual constructor , meaning that when called, it will return a pointer to a new object of the same class as the object whose virtual constructor was called. This is mainly important when one wants to derive a new class from data. Every class, derived from data, should implement its virtual constructor as follows:
derived_from_data::new_data(int kf = FALSE) { return new derived_from_data(kf); }This way, when the generating agent creates a new object, that object will be of the type derived_from_data and not of the class data. If the class derived_class would not implement the virtual constructor, the agent would create objects of the type data, which is clearly not what was meant to happen.
The currenthandler members are used by datahandlers to set and get the
location of the data object. The source members are used to specify
that some data object belongs to some other data object. Take, for example,
the process from figure 4 on page .
The process needs some
information from the other department and so the first operation requests that
information. The second operation cannot continue unless the information is
received. To accomplish this the first operation creates a new data object
which gets passed on to the other department (an external agent).
The first operation sets the source of this new data object to be the original
data to ensure that the waitqueue can recognize when both the original data
and the new data object have arrived at the wait queue.
The member function killflag is used to create multiple data objects
with the same killflag as the first one.