Next Previous Up Top Contents Index

A.6.3 Defining methods

A.6.3.1 Examples

A Named Grid Example

The first example shows how one might encapsulate a named grid, which is a grid of strings.

This is the IDL of the interface to a named grid of strings:

module example{
  interface named_grid{
    readonly attribute string name;
    string get_value ( in unsigned short row,
        in unsigned short column);
    void set_value ( in unsigned short row,
        in unsigned short column,
        in string value);
  }
}

The IDL compiler might generate a class corresponding to theexample::named_grid interface using code something like this:

(defpackage :example)
(defclass example:named_grid(corba:object)())

Servant Class Examples

In order to implement the IDL interface, the user would extend the classexample:named_grid-servant.

;;Sample implementation of named_grid
(defclass grid-implementation (example:named_grid-servant)
  ((grid :initarg :grid
        :initform (make-array '(2 3) :initial-element "Init")))

The attribute in the IDL will cause the class to have a slotop:name with the appropriate accessors specializing on the class.


Developing Component Software with CORBA - 22 Jan 1999

Next Previous Up Top Contents Index

Generated with Harlequin WebMaker