Classes and types You could also use the OPORT macro, which is equivalent to OUT_PORT . Communicating with ports with multiplicity The following table shows the calls to use if the multiplicity of the ports is 10 and you want to communicate with the ports using index 5. You could also use the OPORT_AT macro, which is equivalent to OUT_PORT_AT . Intermediate-level tasks This section describes the intermediate-level APIs used when programming with ports. You use these APIs whenever the code generator cannot create the links on its own, including the following cases: Љ An external source file is used to initialize the system and you must write the code to create the links between the objects.
Љ The port multiplicities are not definite (for example, * ). Љ The port multiplicities do not match across the links. This could happen when ranges of multiplicities are used (for example, 1..10 ). Connecting objects via ports If you are using an external application (such as the MFC GUI) where the links are created at run time, you can link objects with ports specified by Rational Rhapsody using calls similar to the following examples: a.getSrc()->setItsJ(b.getMon()->getItsJ()); To link the objects: b.getMon()->setItsI(a.getSrc()->getItsI()); 1. Create a temporary package that creates the links for you. 2. Copy the . cpp file for the new package to the correct class. 3.
Modify the code as needed. 102 User Guide Task Call Call an operation. OUT PORT AT(src, 5)->f(); _ _ Send an event from a to b using the ports. OUT PORT AT(src, 5)->GEN(evt); _ _ Listen for an event from port src to port mon. evt[IS PORT AT(mon, 5)]/ _ _ doYourStuff();