The ToolTalk service provides the functions to examine, compare, query, and move object specs. Table 12-2 lists the ToolTalk functions you use to maintain object specs.
Table 12-2 Functions to Maintain Object Specifications
Return Type |
ToolTalk Function |
Description |
---|---|---|
char * |
tt_spec_file(const char *objid) |
The name of the file on which the spec is located. |
char * |
tt_spec_type(const char *objid) |
The object type of the spec. |
char * |
tt_spec_prop(const char *objid, const char *propname, int i) |
Retrieves the ith (zero-based) property value as a string. |
int |
tt_spec_prop_count(const char *objid, const char *propname) |
The number of values under this property name. |
Tt_status |
tt_spec_bprop(const char *objid, const char *propname, int i, unsigned char **value, int *length) |
The number of byte array values under this property name. |
char * |
tt_spec_propname(const char *objid, int i) |
The name of the ith property. |
int |
tt_spec_propnames_count(const char *objid) |
The number of properties located on this spec. |
char * |
tt_objid_objkey(const char *objid) |
The unique key of the spec id. |
Tt_status |
tt_file_objects_query(const char *filepath, Tt_filter_function filter, void *context, void *accumulator) |
Queries the database for object specs |
int |
tt_objid_equal(const char *objid1, const char *objid2) |
Checks whether two spec ids are the same. |
char * |
tt_spec_move(const char *objid, const char *newfilepath) |
Moves object spec to a new file. |
You can examine the following spec information with the specified ToolTalk functions:
Path name of the file that contains the object: tt_spec_file
Properties stored on the spec: tt_spec_prop or tt_spec_bprop
To compare two objids, use tt_objid_equal. tt_objid_equal returns a value of 1 even in the case where one objid is a forwarding pointer for the other.
Create a filter function to query for specific specs in a file and obtain the specs in which you are interested.
Use tt_file_objects_query to find all the objects in the named file. As the ToolTalk service finds each object, it calls your filter function, and passes it the objid of the object and the two application-supplied pointers. Your filter function does some computation and returns a Tt_filter_action value (TT_FILTER_CONTINUE
or TT_FILTER_STOP
) to either continue the query, or to quit the search and return immediately.
Example 12-1 illustrates how to obtain a list of specs.
Within the tt_file_objects_query function, the application calls cntl_gather_specs, a filter function that inserts objects into a scrolling list. Example 12-2 illustrates how to insert the objid.
The objid contains a pointer to a particular file system where the spec information is stored. To keep spec information as available as the object described by the spec, the ToolTalk service stores the spec information on the same file system as the object. Therefore, if the object moves, the spec must move, too.
Use tt_spec_move to notify the ToolTalk service when an object moves from one file to another (for example, through a cut and paste operation).
If a new objid is not required (because both the new and old files are in the same file system), the ToolTalk service returns TT_WRN_SAME_OBJID
.
If the object moved to another file system, the ToolTalk service returns a new objid for the object and leaves a forwarding pointer in the ToolTalk database from the old objid to the new one.
When your process sends a message to an out-of-date objid (that is, one with a forwarding pointer), tt_message_send returns a special status code, TT_WRN_STALE_OBJID
, and replaces the object attribute in the message with a new objid that points to the same object in the new location.
Update any internal data structures that reference the object with the new objid.