Overview

Utility Components are similar to Process Components in implementation (they are modules in the Namespace), but rather than responding to requests by the framework to move through time, they respond to function calls from Processes to do some computation.

It is not recommended that you develop your own utilities, currently, since it is poorly supported. However, if you do want to have a go, you can look at the source code for std/util/rng to get started. Using a Utility from your Process is, however, fully supported.

Using Utility Components

A Utility component can be obtained from the framework by sending ENGINE_EVENT_CREATE_UTILITY (native) or calling createUtility (1199). Each Utility exports a number of Utility functions, through its Events interface. The utility will provide a header file utility.h which will provide details of the functions it exports, and will generally offer a C++ interface for using it more succinctly. See the header for std/util/rng at SYSTEMML_INSTALL_PATH/Namespace/std/2009/util/rng/brahms/0/utility.h for an example. See the source code for std/random/numeric for a full example of how to use a utility (std/util/rng).

Notes
  • Note that some Utility objects will be stateful (std/util/rng is, for instance) so more than one copy of a particular Utility may be required by your Process. For non-stateful utilities, one instance will be sufficient.
  • You do not have to destroy Utility objects - they are deleted by the framework when the execution completes.

Example

Here, we use the C++ interface provided by std/util/rng to create and initialise a Random Number Generator.

C++ Source Code (against 1199)
// utility std_2009_util_rng_0::Utility random; ... // create the utility random.create(hComponent); // select the generator random.select("MT2000.normal"); // seed the generator VUINT32 seed = getRandomSeed(1); random.seed(seed);