Next Previous Up Top

5 Examples

5.5 Attaching Properties to Member Functions

5.5 Attaching Properties to Member Functions

In some cases, the user of a library (reified) class would like to be able to attach properties to member functions. For instance, carrying on with the supermarket example, one might want to specify that some services are called asynchronously, while others synchronously.

Again, a routine defined on the Sim_Process as a non reified routine to be executed by the proxy allows this. With such a routine called set_mb_semantics, the scheme is the following:

void main()
	Sim_Supermarket* sim_obj;
	sim_obj = ec_new ((), Sim_Supermarket, ());
	// Initialization
	sim_obj->set_mb_semantics (mid2(Sim_Supermarket,enter), ASYNC);
	sim_obj->set_mb_semantics (mid2(Sim_Supermarket,leave), SYNC);
	// Use
	sim_obj->enter(blond,woman,thin);           // Asynchronous call
	time_used=sim_obj->leave(blond,woman,thin); // Synchronous call

Of course, since the set up of the properties is achieved dynamically, the user might also change it during the execution if needed.

Copyright 1997 EUROPA WG

Last updated: 26 Nov 1997