Incubator/DataBundleHelper

From TrainzOnline
< Incubator
Revision as of 23:59, 3 February 2010 by Windwalkr (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

The Incubator/DataBundleHelper is an Incubator project to create a script helper library for managing abstract "data bundles" which can be passed around in a generic format, but which may be capable of performing specific operations in combination with other rules. An example of a useful data bundle is a Train Consist descriptor, which provides the data necessary to place a Train into the World.

Summary

The Incubator/DataBundleHelper is a script library which allows "data bundles", stored as soups, to be tagged with type information. Rules may register as "data handlers" for a given data type, which means that they will perform certain functions on behalf of the DataBundleHelper when dealing with that data type.

Scripts may pass around data bundles without understanding the contents. The DataBundleHelper provides an abstract interface which allows scripts to query a human-readable name, a type token, and an icon for a given data bundle. The DataBundleHelper also allows the script to run an "action" against the data bundle, which is passed to the appropriate data handler.

Some useful examples of a data bundle are a consist and a URL.

Data bundles may be sent across the network, so should contain minimal overhead. In addition to the raw data, the DataBundleHelper should include a single "__type" tag which contains a string specifying the data type.

Several priority levels are available when registering a "data handler". Any requests for a given data type are sent to the appropriate handler with the lowest-numbered positive priority. Requests may be issued at a specific priority, in which case the lowest-numbered priority greater than the request priority is used (this allows helpers to be chained.)

Library interface specification

The DataBundleHelper library is called through standard LibraryCall(function,string[] sParm,GSObject[] oParm) interface. Here are the detailed specifications for all the calls supported.

Data bundle reference

Data bundle operations are based on its "__type" tag which contains a user string specifying the data type.
In order to guarantee the unicity of this "__type" tag, the section Incubator/DataBundleHelper type reference lists the current use of the "__type" tag. New databundle users should check this section before naming their type tag and should add a line in this wiki section to declare their type tag usage, so that everybody knows which type tag has been used and which one is available.

Personal tools