EiffelStore Implementation Layer

Each interface class has an implementation counterpart that implements specific DBMS handling. The class prefix indicates clearly its layer, for instance:

  • DB_SELECTION is the interface to perform a database selection query.
  • DATABASE_SELECTION [ [[ref:libraries/store/reference/database_flatshort|DATABASE]] ] is its implementation.

The abstract DATABASE class represents a DBMS, i.e. it is the Eiffel-side database call interface. It is inherited for instance by the instantiable ORACLE and ODBC classes.

EiffelStore enables to link common interface objects with database-specific implementation objects using a handle. This handle also enables to switch between different databases.

Let us see in 4 steps how EiffelStore implements this handle system:

The active database handle

The HANDLE_USE class provides access to the unique HANDLE instance. This object stores all the information about the active database, mainly:

  • Database login information:

login: LOGIN [DATABASE] -- Session login

  • Database status information:

status: DB_STATUS -- Status of active database

Association between interface and implementation

The association between an interface object and its implementation counterpart is done at the interface object creation.

Every interface class inherits from the HANDLE_USE class and can access the active database handle. This handle contains a DB [<eiffel>DATABASE</eiffel>] object that provides implementation objects corresponding to every interface objects.

The creation procedure for a DB_CHANGE object is for instance: make -- Create an interface object to change active base. do implementation := handle.database.db_change create ht.make (name_table_size) implementation.set_ht (ht) end

Access to the DBMS call interface

Every implementation class can access the active database call interface by inheriting from the HANDLE_SPEC [<eiffel>DATABASE</eiffel>] class. This class provides access to the DATABASE object, i.e. an instance of class ORACLE or ODBC.

DATABASE descendants are actually wrappers for the DBMS call interfaces written in C. More precisely, call interfaces as delivered by the DBMS companies are called in an EiffelStore C library. The C libraries are then wrapped into Eiffel classes, DATABASE descendants.

Active database selection

As seen in the interface connection part, active database selection is performed by the {DATABASE_APPL}.set_base feature: when a DATABASE_APPL object calls set_base, database represented by this object is activated.

Let us give some details about the set_base feature:

  • Database call interface global reference is updated through {HANDLE_SPEC}.update_handle.
  • All information about the database is set to the handle, mainly:
    • Login information.
    • Status information.

Note: When database is inactive, its information is stored in the DATABASE_APPL object.

The corresponding code looks like: session_status: DB_STATUS -- A session management object reference. ... set_base ... update_handle if session_status = Void then create session_status.make end handle.set_status (session_status) ...

See Also:
The interface layer