gtpd1m2c | Database Reference |
Object classes are defined in the TPFCS source code with the internally used CLASSC macro. A DSECT following each CLASSC statement defines the attributes inherited by all objects belonging to a particular class. Each field in the DSECT describes an attribute.
To understand how TPFCS defines class attributes and inheritance, consider the following example, which describes a subset of our original vehicle database.
Figure 15. Defining TPF Collection Support Source Code Instance Attributes
OBJECT CLASSC , ATTRIBUTES TYPE=INSTANCE ObjectHeader DS 0CL16 ObjectId DS F class ID of object ObjectSeqCtr DS F update sequence counter ObjectLength DS F length of this object DS F reserved ENDATTRIBUTES TYPE=INSTANCE
·
·
·
ENDCLASS Vehicle CLASSC SUPERCLASS=OBJECT ATTRIBUTES TYPE=INSTANCE Owner DS CL16 name of the Vehicle Owner OwnerAddress DS CL16 address of Vehicle Owner RegisterRequired DS CL1 'Y' == reg. required by law * 'N' == reg. is optional RegisterSatus DS CL1 'Y' == Yes, registered * 'N' == No, not registered VehicleIdNumber DS CL32 Vehicle Identification Number * or blanks if not registered BrandName DS CL16 Brand Name or Manufacturer ModelName DS CL16 Model Name or blanks Year DS CL4 Year of manufacture or zero if * unknown * ENDATTRIBUTES TYPE=INSTANCE
·
·
·
ENDCLASS
MotorVehicle CLASSC SUPERCLASS=Vehicle ATTRIBUTES TYPE=INSTANCE PowerSource DS CL16 Main Power Source * e.g. (UN)LEADEDGAS, GASOHOL, DIESEL NumberOfWheels DS H Number of Wheels LicensePlate DS CL10 License Plate Number or blanks ENDATTRIBUTES TYPE=INSTANCE
·
·
·
ENDCLASS Automobile CLASSC SUPERCLASS=MotorVehicle ATTRIBUTES TYPE=INSTANCE NumberOfDoors DS H Number of Doors NumberOfSeats DS H Number of Seats Radio DS C 'Y' if radio, 'N' if none AirConditioner DS C 'Y' if a/c, 'N' if none ExteriorColor DS CL10 Color of Exterior ENDATTRIBUTES TYPE=INSTANCE
·
·
·
ENDCLASS Limousine CLASSC SUPERCLASS=Automobile ATTRIBUTES TYPE=INSTANCE Bar DS C 'Y' if bar, 'N' if none Refrigerator DS C 'Y' if fridge,'N' if none TelevisionBrand DS CL10 Brand of TV or blanks if none ENDATTRIBUTES TYPE=INSTANCE
·
·
·
ENDCLASS
The example of source code we have just cited describes the attributes of all objects of the Limousine, Automobile, MotorVehicle, Vehicle, and OBJECT classes. The SUPERCLASS parameter on each CLASSC macro establishes the inheritance relationship among these classes by dictating that a Limousine is an Automobile, which, in turn, is a MotorVehicle, and so on. Because of this inheritance relationship, any Limousine object would not only inherit the attributes defined for the Limousine class, but would inherit the attributes defined for the other classes as well.
It is important to realize that the inheritance relationship among the classes would still exist even if the CLASSC macro defining each class was located in a separate source module.