Note: This statement is applicable only when used in a class definition (.cls) file. For more information, see the Notes section in this reference entry.
INTERFACE interface-type-namesuper-interface-name , super-interface-name :INHERITSinterface-body
Defines the type name for a user-defined interface type. Specify an ABL interface type name as described in the Type-name syntax reference entry. You can also specify an unqualified interface name (without a package), but only if the interface name represents the full type name for the interface (that is, the interface is not defined as part of a package).Note that you cannot specify "Progress" as the first component of the package name for any ABL user-defined interface. For example, "Progress.Inventory.IUpdateInv" is an invalid type name for a user-defined interface and results in a compiler error.The value of interface-type-name cis restricted to alphanumeric characters plus the symbols #, $, %, and _.Optionally specifies the type name of one or more other interfaces (super interfaces) from which this interface inherits member prototypes as part of its definition. Each super-interface-name you specify can be an ABL or .NET interface type name as described in the Type-name syntax reference entry. With an appropriate USING statement, you can also specify an unqualified interface name (an interface name without the ABL package or .NET namespace that completes the interface type name).Also note that if more than one occurrence of a super interface type or member prototype appears in the interface inheritance hierarchy, it is treated as a single occurrence. However, interface-type-name (the current interface definition type name) can never appear as any super-interface-name, and can never be inherited by any interface specified by a super-interface-name. In other words, there can be no cycles (recursive inheritance) in an interface inheritance hierarchy. Otherwise, ABL raises a compiler error.
temp-table datasetmethod-prototypesproperty-prototypesevent-prototypesEND INTERFACE .temp-table datasetFor information on the syntax for method-prototype, see the METHOD statement reference entry for declaring method prototypes. Note the following:For information on the syntax for property-prototype, see the DEFINE PROPERTY statement reference entry for declaring property prototypes. Note the following:For information on the syntax for event-prototype, see the DEFINE EVENT statement reference entry for declaring class event prototypes. Note the following:END INTERFACEThe following samples include two different class definitions that provide similar functionality, but in distinctly different ways. Each class implements the same interface and both classes define a ProDataSet data member (dsHighCustData) used to retrieve Customer and related Invoice table data for a single Customer record from the sports2000 database. However, each class selects the Customer record using a different and functionally distinct algorithm provided in its own implementation of the same interface method prototype.Thus, each of the following sample class files implements the r-ICustObj interface type defined in the class definition file, r-ICustObj.cls and provides the following functionality:
1. r-ICustObjImpl.cls — Defines the r-ICustObjImpl class, which retrieves data from the single Customer and related Invoice records that contain the highest balance value represented by the Customer.Balance value. This functionality is almost identical to what is provided by the r-CustObj.cls sample class file that is fully described in the Examples section of the CLASS statement reference entry. (The main differences from the r-ICustObjImpl class are that the r-CustObj class does not implement an interface type and it is defined as FINAL.)
2. r-ICustObjImpl2.cls — Defines the r-ICustObjImpl2 class, which also retrieves data from a single Customer and related Invoice records. However, this class retrieves data for the Customer whose related Invoice records contain the highest Invoice balance represented by the sum of their Invoice.Amount values.Following is the interface definition provided by the sample r-ICustObj.cls file.The implementations of the SetHighCustomerData( ) method populate the ProDataSet with selected fields from Customer and Invoice records, where the selected Customer also has related invoices. Each implementation of SetHighCustomerData( ) also sets the two implemented properties (HighCustBalance and HighCustNum) to appropriate values for the selected Customer, and publishes the implemented class event (CustHasInvoices) for each Customer record it encounters with related Invoice records. Each class defines additional data members to support its instance of the ProDataSet, and also must implement the GetHighCustomerData( ) method (according to the interface) to pass the ProDataSet as a by-reference output parameter.Following is the interface implementation provided by the r-ICustObjImpl sample class. Note that the property implementations add initial values, but rely on default behavior for the accessors. The class also fully defines the ProDataSet to be passed as a by-reference method output parameter.The bold code inside the SetHighCustomerData( ) method shows the difference in implementation from the same method implemented by the following r-ICustObjImpl2 sample class. Here, it relies on the stored value of the Customer.Balance field to determine each Customer balance and assigns the HighCustBalance and HighCustNum property values accordingly.The following r-ICustObjProc.p sample procedure shows an application of the r-ICustObjImpl class, which responds to the CustHasInvoices class event and displays the contents of the dsHighCustCata ProDataSet. Note that it defines a reference-only instance of the ProDataSet as required by the class and its interface. (This application is identical to the r-CustObjProc.p sample procedure described in the Examples section of the CLASS statement, but which instantiates the r-CustObj sample class instead.)Following is the interface implementation provided by the r-ICustObjImpl2 sample class. This implementation is identical to r-ICustObjImpl except for the SetHighCustomerData( ) method.The bold code inside the SetHighCustomerData( ) method shows the difference in implementation from the same method implemented by the previous r-ICustObjImpl sample class. Here, it calculates the Customer balance from the total of Invoice.Amount values in its related Invoice records and assigns the HighCustBalance and HighCustNum property values accordingly.The following r-ICustObjProc2.p sample procedure shows an application of the r-ICustObjImpl2 class, which is very similar to the previous procedure, r-ICustObjProc.p. The differences include displaying both the stored Customer.Balance value and the Invoice.Amount total for the selected Customer record, as well as some cosmetic changes to the display. Otherwise, the application is identical.
A class definition (.cls) file can contain only one interface definition that is optionally preceded by one or more USING statements. The complete interface definition must begin with the INTERFACE statement and end with the END statement, and the INTERFACE statement must be the first compileable statement after any USING statements in the file. A class definition file containing an interface definition cannot also contain a class definition.
The compiled version of an interface definition file is an r-code (.r) file. For more information, see the COMPILE statement reference entry.
You can define an object reference variable for an interface, which lets you reference a class that implements the interface, but you cannot create an instance of an interface with the NEW function (classes). For more information on object references, see the AS CLASS option in the DEFINE VARIABLE statement reference entry and see the Class-based object reference reference entry.
You can store class definition r-code files in ABL procedure libraries. If ABL encounters a procedure library on PROPATH, it will search the library for the specified r-code. However, you cannot execute r-code files stored in a procedure library that is not on PROPATH using the procedure-library-path<<member-name>> syntax.
© 2013 Progress Software Corporation and/or its subsidiaries or affiliates. |