Module Thing


module Thing: sig  end
network style internal datastructure

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:

In this example my_cycle has still 2 wheels (from the parent) but has the colour red.


type t
The abstract thing type.

val init : unit -> unit
val create : string -> string -> t -> string -> bool -> t
Creates a new thing with 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
Create a normal relation between two things. Relations are one way from 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
Removes a relation again.
val remove : t -> unit
Add this thing to the removal list, this will also remove the childeren
val execute : unit -> unit
Remove the indicated things, this could take some time on big structures
val output : Pervasives.out_channel -> t -> unit
Write the thing it's childeren and it's relations to the given stream
val input : Pervasives.in_channel -> t -> unit
Read the things from the text 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
Usage: 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
Get a specific thing with given type and name
val name : t -> string
Get the name of a thing
val string_type : t -> string
Get the type of a thing
val related : t -> string -> t
Get the first thing that is related with this type
val parm : t -> string -> int
Get the parameter for the first related thing with this type
val extra : t -> string -> int
Get the extra parameter for the first related thing with this type
val no : t -> string -> int
Get the number of relations of a specific type
val parent : t -> t
Get the parent thing of the given thing
val descr : t -> string
Get the description of a thing
val parm_related : t -> string -> int -> t
Get the related thing of the thing with the relation_type and the parameter.
val rel : t -> string -> (t * int * int) list
Get the relations of this thing with the relation_type. The result gives the list of (thing, parameter, extra-parameter)