In order to use objects which are not visible in a module, ConceptBase offers the export/import facility. The Module-object has two further attributes, namely to objects exported from a module and to modules imported by a module.
Module with
attribute
contains : Proposition;
exports : Proposition;
imports : Module
end
In order to allow other modules to import objects from a module, we need to define an export attribute from the module object to those objects. We call the set of objects exported by a module the export interface of a module. In order to include the export interface of another module to a module, we need to define an imports-attribute from the module object to the module to be imported.
In our running example we would like to define a specialization of the Class Employee within the Managers module. It is desirable to reuse Employee from the Employees module instead of redefining it in the Managers module.
In order to import the class Employee to the Managers module, we have to define all objects belonging to the Employee class as exported objects. First change the module-context to Employees. Now TELL the following Frame:
Employees with
exports
e1 : Employee;
e2 : Employee!name
end
Now you have defined the objects Employee and Employee!name as exported objects of the Employees module. Any module in your application file which defines an imports-attribute to the Employees module can now reference these objects. Now change the module-context to Managers and TELL the following Frame:
Managers with
imports
i1 : Employees
end
Now the objects mentioned above are visible in the context of the Managers module. Check this by loading the Employee object with the Load frame function from the CBworkbench. You can now define the specialization Manager of Employee in the context of the Managers module.
Manager isA Employee end
When untelling exports-attributes from a module, ConceptBase checks for integrity violation in all concerned modules. Try untelling the exports-attributes from the Employees module and you should get an error message saying that referential integrity is violated in the Managers module. The reason for this violation is natural: as the class Employee is no longer exported from Employees, it is no longer visible inside the Managers module and therefore referential integrity is violated for the Manager specialization of Employee.