next up previous contents index
Next: The class archive Up: Datahandlers Previous: The class choice

The class agent

External agents   can have two roles in Logistics Based Business Modelling. An external agent either produces data on its own initiative -- a generating agent  -- or it only processes data it receives -- a non-generating agent . The interface for agent looks as follows:

class agent : public event, public datahandler
{
public:
  agent(int generate = FALSE, histogram* h = NULL, data * d = NULL);
                                                  // constructor
  virtual int operator()();                       // application operator
  int accept(data* d);                            // arrival of data
};

The constructor takes a flag that sets whether the agent should generate data or not. The user can also provide a histogram to gather information on the lifetime of the generated data. If the user does not provide a data object the agent will use objects of class data. If the constructor gets called with a data object, or an object derived from data -- the agent will generate copies of that object.

If the agent is set to generate data objects, the agent will be activated at the start of the simulation, it will generate a data object, pass it to its successor, and schedule itself after a time determined by datahandler::duration. If it gets activated again the same sequence of actions is taken.

The member accept has been overridden to take care of the two different roles an agent can play: if the agent is generating, it will terminate objects it receives. This way objects that are generated by the agent can be handled by a series of datahandlers and then be passed back to the agent. If the agent is a non-generating agent it will accept the data object, and behave as a normal datahandler.



A Eliëns
Mon Jun 1 11:51:50 MET DST 1998