ToolTalk User's Guide

Creating Object Specs

To instruct the ToolTalk service to deliver messages to your objects, you create a spec that identifies the object and its otype. Table 12–1 lists the ToolTalk functions you use to create and write object spec.

Table 12–1 Functions to Create

ToolTalk Function 

Description 

tt_spec_create(const char *filepath)

Creates spec. Return type is char*.

tt_spec_prop_set(const char *objid, const char *propname, const char *value)

Sets property to specified string value. Return type is Tt_status.

tt_spec_prop_add(const char *objid, const char *propname, const char *value)

Adds string property. Return type is Tt_status.

tt_spec_bprop_add(const char *objid, const char *propname, const unsigned char *value, int length)

Adds byte array property. Return type is Tt_status.

tt_spec_bprop_set(const char *objid, const char *propname, const unsigned char *value, int length)

Sets property to specified byte array value. Return type is Tt_status.

tt_spec_type_set(const char *objid, const char *otid)

Sets object type of spec. Return type is Tt_status.

tt_spec_write(const char *objid)

Writes spec to database. Return type is Tt_status.

To create an object spec in memory and obtain an objid for the object, use tt_spec_create.

Assigning Otypes

To assign an otype for the object spec, use tt_spec_type_set. You must set the type before the spec is written for the first time. It cannot be changed.


Note –

If you create an object spec without assigning an otype or with an otype that is unknown to the ToolTalk Types Database, messages addressed to the object cannot be delivered. (The ToolTalk service does not verify that the otype you specified is known to the ToolTalk Types Database.)


Determining Object Specification Properties

You can determine what properties you want associated with an object; you add these properties to a spec. The ToolTalk service recognizes that it is not always possible to store information in your own internal data; for example, the objid for objects in plain ASCII text files. You can store the location of the objid in a spec property and then use this location to identify where the object is in your tool's internal data structures.

The spec properties are also a convenience for the user. A user may want to associate properties (such as a comment or object name) with the object that they can view later. Your application or another ToolTalk-based tool can search for and display these properties for the user.

Storing Spec Properties

To store properties in a spec, use tt_spec_prop_set.

Adding Values to Properties

To add to the list of values associated with the property, use tt_spec_prop_add.