next up previous contents
Next: Fundamental Types Up: SIDL Files Previous: Comments and Doc-Comments   Contents

Packages and Versions

WARNING:This section needs to be brought up-to-date now that we have revised versioning (which includes import and require statements) and introduced re-entrant package support.

SIDL has both a packaging and versioning mechanism built in. Packages are essentially named scopes, serving a similar function as Java packages or C++ namespaces. Versions are decimal separated integer values where it is assumed larger numbers imply more recent versions.

The outtermost SIDL package has a version number assigned to it. By default that version is 0. All classes and interfaces in that package get that same version number. If subpackages are specified, they can have their own version number assigned. If a package is declared without a version, it can only contain other packages. That is, it cannot declare interfaces or classes.


package mypkg { 

}
This SIDL file represents the minimum needed for each and every SIDL file. The package statement defines a scope where all classes within the package must reside. Since no version clause is included, the version number defaults to 0.

Packages can be nested. This is shown in the example below. The version numbers assigned to all the types is determined by the package, or subpackage, in which it resides. In the design of the SIDL file, remember that some languages get very long function names from excessively nested packages or excessively long package names.

package mypkg version 1.0 { 

  package thisIsAReallyLongPackageName { 
  }
  
  package this version 0.6 { 
    package is {
      package a { 
        package really { 
          package deeply version 0.4 {
            package nested {
              package packageName version 0.1 {
              }
            }
          }
        }
      }
    }
  }
}

Advanced:There is a bug/feature in Babel which allows sub-packages to be broken into separate files, but you'd still have to run Babel on all the files at the same time. Here's how it works.

First define the outtermost package in a file.

package mypkg version 2.0 { 

}

Then define a sub-package in a second file.

package mypkg.subpkg version 2.0 { 

}

Note that both files begin with the identical version statement. Now as long as you run Babel on both SIDL files at the same time (with the outtermost one first on the commandline), all is fine.

This works because the package statement takes a scoped identifier as an argument. As long as Babel knows that a package mypkg exists, it can handle a new package called subpkg. Version statements require an identifier for the outtermost package. Since packages cannot have dots ``.'' in their names, the only dots in version statements should appear at the numbers, not the package names.

Running the second file without the first will (and should) generate an error since the enclosing package was not declared. Use of this bug/feature should be used judiciously.

External types can be expressed in one of two ways. The fully scoped external type can be used anywhere in the class description. Alternatively, an import statement can be used to put the type in the local package-space. Below is a sample SIDL file, that should help bring all of these concepts together.


require pkgA version 1.0; // restrict pkgA to 1.0

import pkgB;      // import pkgB.B to my space

require pkgC version 2.0; // restrict pkgC to version 2.0

package mypkg version 2.0 { 
  class foo { 
    setA( A ); // imported from pkgA, must be pkgA.A-v1.0
    setB( B ); // imported from pkgB, must be pkgB.B, no version restriction
    setC( pkgC.C ); // must be pkgC.C-v2.0
    setD( pkgD.D ); // no version restriction
  }
}


next up previous contents
Next: Fundamental Types Up: SIDL Files Previous: Comments and Doc-Comments   Contents


babel-0.8.6
users_guide Last Modified 2003-07-09

http://www.llnl.gov/CASC/components
components@llnl.gov