module Thing: sig end
This module provides things with a type
, name
and description
. The type and name combination on a thing is unique. There is a exception to this rule for things with empty names, but those can only be found back through their relations with other things.
Things can be related to each other with 2 types of relations, the parent/child relation and normal relations.
The parent/child relations form a tree with all the things in them. There is a root thing named ('system', 'root') that will become the parent of all the other things. The tree can have extra lines between the nodes (relations with a type
and with a numeric parameter
and extra_parameter
). When a node doesn't have a specific parameter type the parent are searched for that data.
Example:
'system'['root']
with childs:
'system'['wheels']
'system'['colour']
'colour'['red']
'colour'['green']
'system'['vehicle']
'vehicle'['truck']
relations: ('wheels', 6, with 'system'['wheels']
) ('colour' with 'colour'['red']
)'vehicle'['cycle']
relations: ('wheels', 2, with 'system'['wheels']
) ('colour' with 'colour'['green']
)'verhicle'['cycle']
is 'vehicle'['my_cycle']
relation: ('colour' with 'colour'['red']
)type t
val init : unit -> unit
val create : string -> string -> t -> string -> bool -> t
thing_type
and name
.
With a thing as parent
and a description
and possibly
with inheritance
of relations of parent things.
This also creates a child relation between the parent thing
and the child. A special type of thing is the one where the
name
parameter is the empty string. Normally there can only
be one thing with the same type and name but there can be
multiple nameless things. To change the description of a named
thing you have to define the same thing again.val relation : t -> string -> t -> int -> int -> unit
thing
with relation_type
to related_thing
.
There are two numbers parameter
and extra_parameter
associated with a relation. There can only be one relation of
a specific type between 2 things. Create the same relation twice
to change the parameter and the extra parameter.val remove_relation : t -> string -> t -> unit
val remove : t -> unit
val execute : unit -> unit
val output : Pervasives.out_channel -> t -> unit
stream
val input : Pervasives.in_channel -> t -> unit
stream
as a child of the given
thing
. The file should be the xml-like file written by List.output.val compare_file : Pervasives.in_channel -> t -> string -> t -> bool
compare_file stream parent changed_type changed_thing
.
Read the given stream
and compare it to the child things under parent
.
The things that are changed in the file receive a relation to the given
changed_thing
with the relation type changed_type
val get : string -> string -> t
type
and name
val name : t -> string
val string_type : t -> string
val related : t -> string -> t
val parm : t -> string -> int
val extra : t -> string -> int
val no : t -> string -> int
val parent : t -> t
val descr : t -> string
val parm_related : t -> string -> int -> t
thing
with the relation_type
and the parameter
.val rel : t -> string -> (t * int * int) list
thing
with the relation_type
. The result gives the
list of (thing, parameter, extra-parameter)