4.2 Mapping Object Schemes onto PC++ Programs

 

Some rules for translating the static diagrams of the object schema are given below. Also here the inference engine refines the products of translation by using the information contained within the dynamic models of the object oriented schema.

  1. For each transient class generate a PC++ class with same name, attributes and methods. In this case, the syntax is equivalent to a that of a C++ class.
  2. For each persistent class generate a PC++ dbclass with same name, attributes and methods.
  3. For each generalization/specialization relation insert the name of the superclass in the inheritance chain of the subclass.
  4. For each binary bidirectional relation insert a macro Association(class-name, molteplicity) within the private methods of the classes involved in the relation. Class-name is the name of the other class involved in the relation, whereas molteplicity is the cardinality of the relation. The PC++ compiler will use the friend mechanism to prevent update anomalies (see case study).
  5. For each qualified bidirectional association relation insert a macro Association(class-name, molteplicity, association-name) within the private methods of the classes involved in the relation. In addition to normal relations, here there is the additional argument association-name indicating the name of the relation. Moreover, an additional macro Make-Class(relation-name, identifier1, identifier2, qualifier) is generated where relation-name is the name of the qualified relation, identifier1 and identifier2 are the instance identifiers of the two classes involved in the relation, and qualifier is the qualifier attribute. The macro Make-Class causes the PC++ compiler create the table relation-name with fields identifier1, identifier2, qualifier, and the pair (identifier1, qualifier) as the primary key. The attribute qualifier is also inserted as a data member of the qualified class.

The application of these rules to the classes Transaction and Bank of the class diagram of Figure 2 produces the following PC++ code :

Successively, the PC++ compiler will translate the PC++ code given above, producing the following C++/SQL/ODBC code for the classes above:


Next: Conclusions
Up: OMAR Programming with PC++
Previous: Persistency in PC++