class XML_REPOSITORY [O_ -> STORABLE]

Features exported to ANY

A repository able to store and retrieve objects with an XML representation.

Schema:

  <!DOCTYPE repository [

  <!ELEMENT repository (layout | reference | embedded | basic)* >
  <!ATTLIST repository version CDATA #REQUIRED >

  <!ELEMENT layout (reference | embedded | basic | array)* >
  <!ATTLIST layout type CDATA #REQUIRED >
  <!ATTLIST layout ref ID #REQUIRED >

  <!ELEMENT reference (EMPTY) >
  <!ATTLIST reference name CDARA #REQUIRED >
  <!ATTLIST reference ref IDREF #REQUIRED >

  <!ELEMENT embedded (reference | embedded | basic | array)* >
  <!ATTLIST embedded name CDATA #REQUIRED >
  <!ATTLIST embedded type CDATA #REQUIRED >

  <!ELEMENT basic (EMPTY) >
  <!ATTLIST basic name #REQUIRED >
  <!ATTLIST basic type #REQUIRED >
  <!ATTLIST basic value #REQUIRED >

  <!ELEMENT array (reference | embedded | basic)* >
  <!ATTLIST array name CDATA #REQUIRED >
  <!ATTLIST array type CDATA #REQUIRED >

  ] >
Vocabulary:
  • layout: the description of the contents of an object (its layout). This object is referenced by a reference (see below).
  • reference: a reference to an object. Note that the layout of the object MUST have been defined before any reference links to it. A special 'Void' ref indicates a Void object.
  • embedded: a user-defined expanded object (i.e. not one of the basic objects)
  • basic: a special expanded object, with a simple value, specially treated by the compiler and by this class. Basic types are INTEGER and co., READ and co., CHARACTER and BOOLEAN.
  • array: a NATIVE_ARRAY of objects. The type is, in that particular case, the type of the items.

Direct parents

conformant parents

REPOSITORY, XML_CALLBACKS

Summary

creation features

exported features

Updating and committing

Error handling on repository update

Getting and setting objects in the repository:

Counting:

Iterating facilities:

Details

connect_to (in_stream: INPUT_STREAM, out_stream: OUTPUT_STREAM)

Connect to a repository with streams as physical store.

from_file (path: STRING)

Create a not-connected repository with initial data from the given path. One must use update_from_file and commit_to_file.

make

Create a not-connected empty repository. One must use update_from_file and commit_to_file.

commit_to_file (path: STRING)

Overwrite or create path with the contents of Current.

update_from_file (path: STRING)

Get all objects from the file designed by path. Previous objects are not discarded except if new objects use the same key.

read_from_file (path: STRING)

Get all objects from the file designed by path. Previous objects are discarded first.

commit

Commit all the repository objects to the physical store.

require

  • is_commitable

is_commitable: BOOLEAN

True if the repository can be committed to the underlying physical store.

update

Update the repository objects. Get all objects from the physical store.

require

  • is_updateable

is_updateable: BOOLEAN

True if the repository can be updated from data in the physical store.

is_connected: BOOLEAN

True if the repository is connected to a physical store.

register_update_error_handler (a_error_handler: PROCEDURE [O_ -> TUPLE][TUPLE])
update_error_handlers: FAST_ARRAY [E_][PROCEDURE [O_ -> TUPLE][TUPLE]]
fire_update_error
frozen has (object_name: STRING): BOOLEAN

Is object_name the name of some stored object.

require

  • not object_name.is_empty

frozen at (object_name: STRING): O_

Return the object currently associated to object_name.

require

  • has(object_name)

ensure

  • Result /= Void

frozen add (object: O_, object_name: STRING)

Update or add a new object in the Current repository.

require

  • object /= Void
  • new_reference: not has(object_name)

ensure

  • reference_stored: object = at(object_name)

frozen put (object: O_, object_name: STRING)

Update or add a new object in the Current repository.

require

  • object /= Void

ensure

  • reference_stored: object = at(object_name)

remove (object_name: STRING)

Remove entry object_name from the Current repository.

require

  • has(object_name)

ensure

  • not has(object_name)

count: INTEGER

Actual count of stored elements.

is_empty: BOOLEAN

Is it empty ?

ensure

  • Result = (count = 0)

lower: INTEGER
upper: INTEGER

ensure

  • Result = count

valid_index (index: INTEGER): BOOLEAN

ensure

  • Result = index.in_range(lower, upper)

item (index: INTEGER): O_

require

  • valid_index(index)

ensure

  • Result = at(key(index))

key (index: INTEGER): STRING

require

  • valid_index(index)

ensure

  • at(Result) = item(index)

get_new_iterator_on_items: ITERATOR[O_]

ensure

  • Result /= Void

get_new_iterator_on_keys: ITERATOR [E_][STRING]

ensure

  • Result /= Void

key_map_in (buffer: COLLECTION [E_][STRING])

Append in buffer, all available keys (this may be useful to speed up the traversal).

require

  • buffer /= Void

ensure

  • buffer.count = count + old buffer.count

item_map_in (buffer: COLLECTION[O_])

Append in buffer, all available items (this may be useful to speed up the traversal).

require

  • buffer /= Void

ensure

  • buffer.count = count + old buffer.count

Class invariant