The class operation represents the work done in a process. It needs an employee to perform the work. The interface looks as follows:
interface operation : public datahandler { public: operation(employee* e); // constructor int accept(data* d); // try to handle data void pass(data* d); // pass the data to the next handler virtual int acquire(); // try to acquire resources virtual void release(); // release acquired resources virtual void next(datahandler* dh1, datahandler* dh2 = NULL, data* d = NULL); // pass data to dh1 and to dh2 };
The constructor takes the employee that will perform the operation. The member accept overrides datahandler::accept to take care of the acquiring of the employee. It uses the member acquire to try to aqcuire the employee. If acquire fails to get the employee it will return FALSE, and accept will return FALSE too, thus informing the previous datahandler that the operation could not be executed at that time. The member pass will be called when the operation finishes. It will use release to free the employee and will pass the data object to the next handler.
In some cases an operation will produce extra information, for instance when an operation will request extra information from another department. See also section 5. In that case the member function next should be used to specify both the successor datahandlers. If the parameter data is not provided, operation will simply make a copy of the received data and pass the copy on to the second datahandler ( dh2). If another data object is provided by means of the next member, copies of that object will be passed to the second datahandler, with its source set to the original data.