op_stat_obj_dim_size_get()
Abstract
Reads the size of a local dimensioned statistic from a specified object.
Syntax
op_stat_obj_dim_size_get (stat_name, obj_id, dim_size_ptr)
| Argument | Type | Description |
|---|---|---|
stat_name |
const char* |
name of statistic for which a handle is to be obtained. |
obj_id |
Objid |
ID of the object containing the statistic of interest. |
dim_size_ptr |
int * |
address of the variable to store the dimension size |
Return Type
Compcode
Completion code that indicates whether the operation completed successfully. OPC_COMPCODE_FAILURE if the statistic name or size pointer are not valid; OPC_COMPCODE_SUCCESS otherwise.
Example
Excerpt from: models/std/utilities/oms/oms_dim_stat_support.ex.c
if ((dim_stat_desc_handle_ptr = (OmsT_Dim_Stat_Desc *)
prg_string_hash_table_item_get (dim_stat_desc_hash_table_ptr [stat_type],
stat_desc_key_str)) == OPC_NIL)
/* Create a new record to store dimensioned statistics for this */
/* group/stat name from the supplied module. */
dim_stat_desc_handle_ptr = (OmsT_Dim_Stat_Desc *) oms_dim_stat_desc_alloc ();
/* The dimensioned statistics have a finite dimension index using */
/* which stats can be registered/recorded. Determine this limit for */
/* the current statistic. */
sprintf (stat_reg_name_str, "%s.%s", group_name, stat_name);
/* If the statistic is a local statistic, use op_stat_obj_dim_size_get */
/* Else if the statistic is a global statistic, use op_stat_dim_size_get */
/* This is because op_stat_obj_dim_size_get does not consider statistic */
/* type (LOCAL or GLOBAL) and returns a 0 dim size for global statistics. */
if (stat_type == OPC_STAT_LOCAL)
op_stat_obj_dim_size_get (stat_reg_name_str, module_id,
&dim_stat_desc_handle_ptr->max_dim_size);
else
op_stat_dim_size_get (stat_reg_name_str, stat_type,
&dim_stat_desc_handle_ptr->max_dim_size);
/* Initialize the elements of this newly created data structure */
/* used to maintain dimensioned statistic handle. */
dim_stat_desc_handle_ptr->next_dim_index = 0;
/* Register a new stathandle with the supplied arguments. */
dim_stathandle_ptr = oms_dim_stat_register (dim_stat_desc_handle_ptr,
module_id, group_name, stat_name, stat_type, stat_key_str);
...
Details
This KP reads the value of the dimension array of a statistic from a specified object, such as a path, link, or demand. Dimension information is stored in the Count field of the statistic.
If the statistic is undimensioned, *dim_size_ptr is set to OPC_STAT_UNDIMENSIONED; otherwise, the value is the upper limit (upper statistic index + 1).
Purpose
Provides a mechanism to calculate the dimensions of a statistic before registering the statistic.
Errors
- Program Abort: KP requires process context.
- Program Abort: Segmentation violation. (due to an invalid
dim_size_ptr) - Program Abort: Segmentation violation. (due to an invalid or malformed
stat_nameargument) - Recoverable Error: Object of unsupported type specified (
<obj_id>)
Reference
- Use the KP op_stat_obj_reg() to obtain a statistic handle
- Use the KP op_stat_dim_size_get() to read the dimension size of a local or global statistic