Generated Documentation
All classes
A
C
E
F
I
M
N
P
R
S
Cluster Local Cluster
Cluster abilities
Cluster automaton
Cluster backtracking
Cluster cli
Cluster design_patterns
Cluster edc-new
Cluster exec
Cluster foreign_interface
Cluster get_text
Subcluster get_text/filter_get_text
Subcluster get_text/terminal_get_text
Cluster html
Cluster i18n
Classes
Cluster io
Cluster iterator
Cluster json
Cluster kernel
Cluster language
Classes
Cluster log
Cluster message_formatter
Cluster misc
Subcluster misc/internal
Cluster mmi
Subcluster mmi/impl/curses/core
Classes
Subcluster mmi/impl/readline/core
Subcluster mmi/impl/web/core
Subcluster mmi/impl/web/parser
Cluster ncurses
Cluster net
Description
Networking: client-side and server-side sockets.

How to use the "net" cluster

This page is divided into the following sections:

Vocabulary

Access A word used by this cluster to design a server access on a host.
Address A word used by this cluster to design a host.
Host A machine connected to a network. Such a machine has an address and, usually, a name.
Server A program that runs on a host. Such a programs listens on a "port number".

Be a Client

To be client means trying to reach some server and getting some data from it.

There are two concepts to grasp before making a connection:

  • Address: that's the network address of a machine (a "host"), given either by its name or its IP number. The net cluster knows of three kinds of addresses: the host name, the IP address and the local address which represents the local machine.
  • Access: it allows to connect to some server that runs on a machine and listens on a port. The net cluster knows of three kinds of accesses: TCP and UDP access, and the special Local access that reaches the local machine.

To be a client, you have to do three things, in that order:

  • create an address object
  • create an access object, using the address object
  • query a stream from the access object

In Liberty Eiffel, you would write it this way:

   connect_to_funet: TERMINAL_INPUT_OUTPUT_STREAM is
      local
         funet: HOST
         tcp: TCP_ACCESS
      do
         create funet.make(once "ftp.funet.fi")
         create tcp.make(funet, 21)
         Result := tcp.stream
      end

(See also the tutorial: class SOCKETS)

Be a Server

To be a server, things are a bit more complex but not tremendously so.

First note that you must know something of the lib/sequencer cluster. You must also be familiar with agents.

To create a server, start by creating an address and an access. The address will filter which connections are allowed1, and the access port will determine which port the server will listen to.

Now you must create a SOCKET_SERVER, give it one or more agents using the `when_connect' feature. Those agents are called whenever a new client connects; each agent is given the same stream that represents the connection to the client.

Note that having multiple agents is potentially dangerous. Either all the agents cooperate, either having one registered is enough. Remember that all agents share the same stream.

Subcluster net/access
Subcluster net/address
Subcluster net/servers
Cluster description:

This cluster contains two very intersting classes since they provide a framework to build multiplexing servers.

  • SERVER is a multiplexing server. IT can either start its own stand-alone stack or use an existing stack. You give it an access and it listens onto it and starts connections when a new client connects.
  • CONNECTION is a connection started by the server whenever a client connects. A stream connected to that client is provided.
Cluster numeric
Cluster parse
Cluster random
Cluster regular_expression
Cluster sequencer
Cluster signal
Cluster sorting
Cluster storage
Description
Storage: object collections

How to use the "storage" cluster

This cluster provides the main collection abstractions and their implementations. This document provides a few hints that may help choosing the most relevant data structure.

Collections

Collections are linear sequences of objects. They are traversable by either using an index (an INTEGER between lower and upper) or an iterator.

The standard library implementations are:

  • FAST_ARRAY: a random accessible array of object; lower is zero.
  • ARRAY: a random accessible array of object with a variable lower bound (hence just a little bit slower than FAST_ARRAY)
  • RING_ARRAY: a random accesisble array with variable bounds and optimized for additions and removals at both ends (used for QUEUE implementation)
  • LINKED_LIST: a collection of objects linked together; random access is slower but insertion in the middle is faster.
  • TWO_WAY_LINKED_LIST: the same but objects are linked both forward and backward thus allowing efficient iteration in both directions.

Multi-dimentsion collections

COLLECTION2 and COLLECTION3 provide similar facilities for two- and three-dimension object collections.

Maps

Maps provide indexed collections: access to object values using object keys.

The standard library implementations are:

  • HASHED_DICTIONARY: the classical hash table. The keys must be HASHABLE. The capacity of those dictionaries is always a prime number; collisions are resolved by linking together the objects with the same hash code (module the table capacity). Therefore a hashed dictionary may contain more elements than its capacity! EST_HASHED_DICTIONARY provides the same data structure but requires an external agent to provide the hash code of a key (therefore alleviating the need for the key to be HASHABLE).
  • PYTHON_DICTIONARY: another implementation of hash tables, using Python's algorithm. The keys must be HASHABLE. The capacity is exactly what it says: the number of elements may not exceed the capacity. Collisions are resolved by spreading the elements in the table's array. There are no linked lists, no reference nodes, therefore this implementation is a bit less memory hungry. The capacity is always a power of 2. EXT_PYTHON_DICTIONARY provides the same data structure but requires an external agent to provide the hash code of a key (therefore alleviating the need for the key to be HASHABLE).
  • AVL_DICTIONARY: the objects are distributed in an AVL tree using COMPARABLE keys. Because the elements are linked in a tree, there is no capacity (it is meaningless). EXT_AVL_DICTIONARY provides the same data structure but requires an external agent to compare two keys (therefore alleviating the need for the key to be COMPARABLE).
  • ZIP is just a pair of collections with the same count. One collection is the list of keys, the other is the list of values.
  • ENUMERATE is just a collection with the object indices as key.

Sets

Sets of objects have unique occurrences of each object. Mathematical set operators are available.

The standard library implementations are:

Repositories

A repository is a collection of STORABLE objects. The aim of this structure is to make objects persistent.

The standard library implementations are:

See also: REPOSITORY_TRANSIENT to register objects that must not be persisted.

Subcluster storage/bijective_dictionary
Subcluster storage/collection2
Subcluster storage/collection3
Cluster string
Cluster tests
Cluster time
Cluster unicode
Cluster variant
Cluster xml
Cluster common/library
Cluster database/library
Cluster database/library/postgresql
Subcluster database/library/postgresql/externals
Subcluster database/library/postgresql/externals/generated
Cluster database/library/sqlite
Cluster database/library/sqlite/externals
Cluster database/library/sqlite/values
Cluster ffi/library
Classes
Cluster ffi/library/externals
Cluster posix/dynamic-linking/library
Cluster posix/dynamic-linking/library/externals
Classes
Subcluster posix/dynamic-linking/library/externals/generated
Cluster posix/library
Cluster posix/library/externals
Subcluster posix/library/externals/generated
Classes
Cluster readline/library
Cluster zmq/library
Cluster zmq/library/externals
Subcluster zmq/library/externals/generated
Cluster ecurl
Root cluster
Description

This cluster provides deferred classes that abstract out component behaviour:

  • CODE is the interfave of the tools/code component. It represents a code element (either an expression or an instruction). Note that each code is either an instruction or an expression (see below). The classes in the tools/code component are intended to be inserted rather than inherited (they add specific behaviour to some instructions and expressions).
  • EXPRESSION is the interface of the tools/expression component. It represents an Eiffel expression, i.e. a syntactic construction having a result type.
  • INSTRUCTION is the interface of the tools/instruction component. It represents an Eiffel instruction.
  • PARSER is the interface of the tools/parser component. It parses a file (an Eiffel file, an ACE file or a configuration file) and extracts syntactic information.
  • RUN_FEATURE is the interface of the tools/run_feature component. It represents a live feature, i.e. a callable feature tailored for some particular LIVE_TYPE.
  • TYPE_MARK is the interface of the tools/type_mark component. It represents an Eiffel type.

Moreover, the class SMART_EIFFEL drives the compilation process. It stays in this cluster because it is so important.

Subcluster ace
Cluster description:

Provides ACE handling and class loading algorithms, including the (in)famous "distance class loader". Let's explain how this algorithm works.

Classes are stored in clusters which are physical directories. Those clusters are organized:

  • either explicitly via an ACE file,
  • or implicitly via configuration files.

In both cases, clusters are organized in a tree. The interface of this tree is CLASSES. The root instance of the tree is a direct instance of UNIVERSE, which is a singleton. Node instances of the tree are direct instances of LOADPATH. Leaf instances, i.e. the ones holding a reference to an actual cluster, are direct instances of CLASSES_TREE. Note that both inherit from CLUSTERS, and technically a CLASSES_TREE is a node that may contain other cluster nodes. In fact that's not the case but that could change of course ;-)

How do we load classes now that the tree is built?

A class is searched starting from who searches it. A "provider" class is always looked for in conjunction to its "client". We compute the distance between the client and one or more would-be provider classes having the same name, and the closest class is selected.

The distance is calculated thus:

  • The class loader tries to look for the provider class in the same cluster as the client class' and below (in the clusters tree). If it find one or more below, it will select the closest in priority and stop its lookup.
  • Otherwise, it tries again starting from the parent of the client class' cluster... Until reaching the Universe. If at that stage no class is found, no class is returned (usually leading to a "class not found" error...)

Subcluster cecil
Subcluster commands
Cluster description:

This cluster contains all the main classes used to implement the SmartEiffel tools.

Subcluster expression
Cluster description:

Provides all types of EXPRESSIONs.

Subcluster generation
Subcluster generation/c
Subcluster generation/fake_generator
Subcluster generation/pretty
Subcluster generation/sedb
Subcluster install
Subcluster kernel
Cluster description:

Maybe one of the most important clusters. This cluster contains all the classes one should first get used to in order to understand how the compiler and the other tools work. These classes contain the core algorithms and structures used by the SmartEiffel suite.

Subcluster type_mark
Cluster description:

Provides for all kinds of Eiffel types of entities. For example, MY_OBJECT and like my_object type markers lead to different TYPE_MARKs. Among the most frequent are:

Subcluster visitor
Cluster description:

Provides the Acyclic Visitor Design Pattern.

Most data classes are visitable; but a lot are not, when it has no sense to make them so. In this category go all the algorithm classes (tools/kernel cluster), pools, singletons, and framework classes (such as GLOBALS).

Classes
Root cluster
Root cluster
Root cluster
Subcluster ace
Classes
Subcluster ace/aux_example_debug
Subcluster agent
Subcluster agent/auxiliary
Classes
Subcluster backtracking
Subcluster backtracking/expand_expression
Subcluster backtracking/expand_expression/abstract
Subcluster backtracking/expand_expression/abstract/auxiliary
Subcluster backtracking/expand_expression/tree
Subcluster backtracking/expand_expression/tree/auxiliary
Classes
Subcluster backtracking/logigram
Classes
Subcluster basic_directory
Subcluster exec
Classes
Subcluster external
Subcluster external_tool
Subcluster hanoi
Classes
Subcluster hanoi/auxiliary
Classes
Subcluster iterator
Subcluster iterator/auxiliary
Subcluster language
Subcluster ncurses
Subcluster number
Subcluster parking
Subcluster parking/auxiliary