# Exporting state

Author: Jeff Dalton

This is a preliminary version of an experimental mechanism that sends world-state changes from an agent to other, specified agents. Instead of sending every change, the changes are filtered so that only changes that match specified patterns will be sent.

Note: The way in which exports and filters are specified may change completely in future versions of I-X.

## Adding the feature to a panel

Use the agent extension mechanism to add state-exporting when a panel first starts up. This is done by specifying a command-line argument or props file entry

       extension-classes=ix.test.StateExportExtension

Another useful parameter is

      state-export-list=resource-name

This specifies a file that contains a list of export specifications in the form described in the next section. A "resource name" can be a file name or a URL.

## Specifying exports

To export state, you will need to define some world-state-export objects which specify what is in each "view" you wish to export and its destination.

Note: The world-state-export class is currently a subclass of world-state-view, and so the export objects will sometimes be referred to as "views". However, in future versions this relationship may change so that a world-state-export instead contains a world-state-view.

Here is the XML syntax. (Other representations correspond to this in the usual way.)

An world-state-export has the following fields:

name string
  The name used to identify the view.
destination string
  The name of the agent that will be sent state changes that are included in the view.
filter-patterns list
  A list of lists of the form pattern [= value]. The value defauts to `true`. Any state change that matches any of the filter-patterns will be sent to the specified destination. Note that "matching a filter-pattern" means matching both its pattern part and its value part. Variables are written in the usual way as symbols that begin with "`?`" and exist only for one combined pattern-value match. "`??`" is a "wildcard" and matches anything.

The string-valued fields may instead be written as attributes of the `world-state-export` element, and the filter-patterns can be written as `list-text` elements. Usually, you will need a list of world-state-exports, so an example might look like this: