Browse through the calculator classes.
MCO_RET mco_calc_cinfo_browse( /*IN*/ mco_calc_t * calc,
/*IN*/ mco_calc_cinfo_h handler,
/*IN*/ void * data);
| calc | A handle to the initialized calculator object |
|
handler |
A user supplied handler function to process the class information |
|
data |
A pointer to user supplied data. |
This function browses through calculator classes, one class at time, and calls the user supplied handler function to process (print or perform some calculation with) the class information. Additional application-specific data may be passed into the handler function via parameter
data.
| MCO_S_OK | The class statistics were collected successfully |
|
MCO_E_TRANSACT |
A transaction was in an error state during calculator processing |
The following code snippets demonstrate how
mco_calc_cinfo_browse()is used to browse the calculator contents. Note thatmco_calc_cinfo_browse()calls the application defined functionclass_print()to display the contents of each class.
Application snippet: const char * dbname = "calc_db"; static void class_print(mco_calc_t *calc, mco_cc_t *cls, mco_cc_info_t *info, void *unused) { printf(" -> %s%s:\n", (info->is_pers ? "[PERSISTENT] " : ""), cls->cc_name); ... } int main(int argc, char* argv[]) { MCO_RET rc; mco_calc_t calc; mco_device_t dev; mco_db_params_t db_params; mco_cc_info_t info; mco_runtime_start(); ... mco_calc_init(&calc, calc_db_get_dictionary()); ... rc = mco_db_open_dev( dbname, simple_get_dictionary(), &dev, 1, &db_params ); if ( MCO_S_OK != rc ) { rc = mco_db_connect( dbname, &calc.db ); ... rc = mco_calc_reg_schema_classes(&calc, calc_db_get_calculator()); ... rc = mco_calc_fill_db(&calc); ... rc = mco_calc_stat_collect(&calc); ... printf("\nClass info:\n"); rc = mco_calc_cinfo_browse(&calc, class_print, (void*)0); ... /* NOTE: calculator *must* be deinitialized before you disconnect from the database */ mco_calc_deinit(&calc); mco_db_disconnect(calc.db); } }
For further implementation details see SDK sample "samples/native/core/17-statistics/dbcalc".