op_ima_obj_state_get()
Abstract
Obtains a structure or value that has been set on an object using the KP op_ima_obj_state_set().
Syntax
op_ima_obj_state_get (objid)
| Argument | Type | Description |
|---|---|---|
objid |
Objid |
object ID of the object-of-interest |
Return Type
void*
Returns a pointer to the structure or value set using the KP op_ima_obj_state_set(). If no state has been set, the return value is OPC_NIL.
Example
Excerpt from oms_bgutil.ex.c in models/std/utilities/oms.
/* Our client is not assuming responsibility for storing our routed */
/* state information. We must do it ourselves. */
/* Get the current routed bgutil state off this channel object. If the object */
/* state pointer is OPC_NIL, we need to set up the routed utilization. */
/* The link object state ptr (accessed via op_ima_obj_state_get) by */
/* convention should be a pointer to a pointer to */
/* OmsT_Bgutil_Routed_State. */
bgutil_routed_state_pptr = (OmsT_Bgutil_Routed_State **)
op_ima_obj_state_get (tx_ch_objid);
if (bgutil_routed_state_pptr == OPC_NIL)
{...}
Details
Objects can contain state information in the form of pointers to values or structures. The KP op_ima_obj_state_set() attaches these values or structures to the object, and the KP op_ima_obj_state_get() retrieves a copy of them. The state information remains set on the object and may be gotten again.
Purpose
Provides a mechanism to retrieve state information associated with simulation objects.
Errors
- Recoverable Error: Object ID (
<objid>) is out-of-range. - Recoverable Error: Object ID (
<objid>) refers to a restricted object.
Reference
- Use the KP op_ima_obj_state_set()) to attach a value or structure to an object