Accessor: utilities/MutableBase

utilities/MutableBase

Base class for mutable accessors. A mutable accessor is an accessor that does nothing until it is 'reified' by another accessor. Once reified, the reifying accessor will react to inputs to this mutable and produce outputs. No particular combatibility rules are imposed to the reifying accessor. reify() will look for matching input and outputs between the reifying accessor and the instance of mutable

This base class defines an accessor input that accepts an accessor instance, an accessor code (as string) or a fully qulified accessor class. The mutable reifies itself with the instance of the accessor, even no matching is found. This base class defines also a state output. The mutable will be sending on this output a boolean value, that indicates if the reification succeeded or not. For example, if the received accessor cannot be resolved to an accessor instance, then false value will be sent on 'state' output. To use this, extend it as follows:

 exports.setup = function() {
     this.extend('utilities/MutableBase');
     ... add your inputs, outputs, and parameters here ...
 };

A good way to add your inputs, outputs, and parameters is to define an interface and then implement it as follows:

 exports.setup = function() {
     this.extend('utilities/MutableBase');
     this.implement('MyInterfaceDefinition');
 };

Your interface definition should look something like this:

 exports.setup = function() {
     this.input('in');
     this.output('out');
  };

This should be put into a file named MyInterfaceDefinition.js. If that file is in the same directory as the swarmlet that uses this Mutable, then the host will be able to find the file.

If a null or empty string input is provided on accessor and this mutable has been reified, then it will be unreified.

Version:
  • $$Id$$
Author:
  • Chadlia Jerad and Edward A. Lee
Source:
Inputs:
Name Type Description
accessor Accessor instance, code or class to reify.