Difference between revisions of "ConfigurationParserLibrary"

(CONF_OVERRIDE)
Line 36: Line 36:
 
=== CONF_OVERRIDE ===
 
=== CONF_OVERRIDE ===
 
An override cluster is a normal cluster with the special thing, that classes in here with the same name than other classes override classes in the other cluster.
 
An override cluster is a normal cluster with the special thing, that classes in here with the same name than other classes override classes in the other cluster.
 +
 +
=== CONF_ACCESS ===
 +
For a class to be able to modify a configuration it needs to inherit from CONF_ACCESS.
  
 
== Retrieval and Storage ==
 
== Retrieval and Storage ==

Revision as of 12:18, 9 November 2006

General

The basic layout of a configuration system is a system that has multiple targets (which may inherit from each other), every target can have some libraries, assemblies override clusters and normal clusters. Clusters can have sub clusters.

Config basic layout.png

CONF_SYSTEM

Every configuration file describes one CONF_SYSTEM and has one or more CONF_TARGET associated. Normally a CONF_SYSTEM object is generated by parsing a configuration file with CONF_LOAD.

Implementation

Every CONF_SYSTEM has an associated UUID. If there is no UUID specified in the configuration file a random one will be generated when the file is loaded. If a system is used as a library the UUID has to be specified in the configuration file as this is used to detect multiple usage of the same library.

CONF_TARGET

The target is the basic block that an application or a library is built of. A target can extend another target. If a system can be used as a library, one target has to be specified as the library target.

Implementation

In a fully parsed system, every CONF_SYSTEM has the application_target set. This is the back link in libraries to the target that represents the application.

One thing to take into account when extending another target is, that only classes in clusters/libraries in a target can be reached. e.g.

  • target common
    • cluster a
  • target special extends common
    • cluster b

If we compile target special, classes in b can use classes in a but classes in a can not use classes in b as this is not in the scope of a.

CONF_LIBRARY

A CONF_LIBRARY node describes the use of a library in an application or another library. Once the configuration has been fully parsed it has a library target. All CONF_LIBRARY nodes for one library point to the same library_target.

CONF_ASSEMBLY

A CONF_ASSEMBLY is very similar to a CONF_LIBRARY. Instead of a library_target there is a CONF_PHYSICAL_ASSEMBLY that all references to the same assembly share.

CONF_CLUSTER

A CONF_CLUSTER represents a cluster that has actual classes in it.

CONF_OVERRIDE

An override cluster is a normal cluster with the special thing, that classes in here with the same name than other classes override classes in the other cluster.

CONF_ACCESS

For a class to be able to modify a configuration it needs to inherit from CONF_ACCESS.

Retrieval and Storage

Loading a configuration from a file.

load_configuration (a_file: STRING) is
			-- Load configuration file `a_file'.
		require
			a_file_ok: a_file /= Void and then not a_file.is_empty
		local
			l_loader: CONF_LOAD
		do
			create l_loader.make (create {CONF_PARSE_FACTORY})
			l_loader.retrieve_configuration (a_file)
			if l_loader.is_error then
				display_error (l_loader.last_error)
			else
				system := l_loader.last_system
			end
		end

Storing a configuration to a file.

store_configuration (a_system: CONF_SYSTEM) is
			-- Store `a_system' to its configuration file.
		require
			a_system_ok: a_system /= Void
		do
			a_system.store
			if not a_system.store_successful then
				display_error ("Could not store system in " + a_system.file_name)
			end
		end