osaf/services/saf/amf/amfd/csi.cc | 8 +++--- osaf/services/saf/amf/amfd/cstype.cc | 35 +++++-------------------------- osaf/services/saf/amf/amfd/include/csi.h | 3 +- 3 files changed, 12 insertions(+), 34 deletions(-)
diff --git a/osaf/services/saf/amf/amfd/csi.cc b/osaf/services/saf/amf/amfd/csi.cc --- a/osaf/services/saf/amf/amfd/csi.cc +++ b/osaf/services/saf/amf/amfd/csi.cc @@ -117,7 +117,7 @@ static int is_config_valid(const SaNameT rc = immutil_getAttr(const_cast<SaImmAttrNameT>("saAmfCSType"), attributes, 0, &aname); osafassert(rc == SA_AIS_OK); - if (avd_cstype_get(&aname) == NULL) { + if (cstype_db->find(&aname) == NULL) { /* CS type does not exist in current model, check CCB if passed as param */ if (opdata == NULL) { report_ccb_validation_error(opdata, "'%s' does not exist in model", aname.value); @@ -331,7 +331,7 @@ static void csi_get_attr_and_add_to_mode TRACE_ENTER2("DEP not configured, marking rank 1. Csi'%s', Rank'%u'",csi->name.value,csi->rank); } - csi->cstype = avd_cstype_get(&csi->saAmfCSType); + csi->cstype = cstype_db->find(&csi->saAmfCSType); csi->si = avd_si_get(si_name); avd_cstype_add_csi(csi); @@ -546,7 +546,7 @@ static SaAisErrorT csi_ccb_completed_mod rc = SA_AIS_ERR_BAD_OPERATION; goto done; } - if (avd_cstype_get(&cstype_name) == NULL) { + if (cstype_db->find(&cstype_name) == NULL) { report_ccb_validation_error(opdata, "CS Type not found '%s'", cstype_name.value); rc = SA_AIS_ERR_BAD_OPERATION; goto done; @@ -778,7 +778,7 @@ static void csi_ccb_apply_modify_hdlr(st SaNameT cstype_name = *(SaNameT*) attr_mod->modAttr.attrValues[0]; TRACE("saAmfCSType modified from '%s' to '%s' for Csi'%s'", csi->saAmfCSType.value, cstype_name.value, csi->name.value); - csi_type = avd_cstype_get(&cstype_name); + csi_type = cstype_db->find(&cstype_name); avd_cstype_remove_csi(csi); csi->saAmfCSType = cstype_name; csi->cstype = csi_type; diff --git a/osaf/services/saf/amf/amfd/cstype.cc b/osaf/services/saf/amf/amfd/cstype.cc --- a/osaf/services/saf/amf/amfd/cstype.cc +++ b/osaf/services/saf/amf/amfd/cstype.cc @@ -22,7 +22,7 @@ #include <csi.h> #include <imm.h> -static NCS_PATRICIA_TREE cstype_db; +AmfDb<avd_cstype_t> *cstype_db = NULL; // // TODO(HANO) Temporary use this function instead of strdup which uses malloc. @@ -37,7 +37,7 @@ static char *StrDup(const char *s) static void cstype_add_to_model(avd_cstype_t *cst) { - unsigned int rc = ncs_patricia_tree_add(&cstype_db, &cst->tree_node); + uint32_t rc = cstype_db->insert(cst); osafassert(rc == NCSCC_RC_SUCCESS); } @@ -52,7 +52,6 @@ static avd_cstype_t *cstype_create(const memcpy(cst->name.value, dn->value, dn->length); cst->name.length = dn->length; - cst->tree_node.key_info = (uint8_t *)&cst->name; if ((immutil_getAttrValuesNumber(const_cast<SaImmAttrNameT>("saAmfCSAttrName"), attributes, &values_number) == SA_AIS_OK) && (values_number > 0)) { @@ -72,39 +71,20 @@ static avd_cstype_t *cstype_create(const */ static void cstype_delete(avd_cstype_t *cst) { - unsigned int rc; char *p; int i = 0; - rc = ncs_patricia_tree_del(&cstype_db, &cst->tree_node); - osafassert(rc == NCSCC_RC_SUCCESS); + cstype_db->erase(cst); if (cst->saAmfCSAttrName != NULL) { while ((p = cst->saAmfCSAttrName[i++]) != NULL) { delete [] p; } } - delete [] cst->saAmfCSAttrName; delete cst; } -/** - * Lookup object using name in DB - * @param dn - * - * @return avd_cstype_t* - */ -avd_cstype_t *avd_cstype_get(const SaNameT *dn) -{ - SaNameT tmp = {0}; - - tmp.length = dn->length; - memcpy(tmp.value, dn->value, tmp.length); - - return (avd_cstype_t *)ncs_patricia_tree_get(&cstype_db, (uint8_t *)&tmp); -} - void avd_cstype_add_csi(AVD_CSI *csi) { csi->csi_list_cs_type_next = csi->cstype->list_of_csi; @@ -190,7 +170,7 @@ SaAisErrorT avd_cstype_config_get(void) if (!is_config_valid(&dn, NULL)) goto done2; - if ((cst = avd_cstype_get(&dn)) == NULL){ + if ((cst = cstype_db->find(&dn)) == NULL){ if ((cst = cstype_create(&dn, attributes)) == NULL) goto done2; @@ -232,7 +212,7 @@ static SaAisErrorT cstype_ccb_completed_ report_ccb_validation_error(opdata, "Modification of SaAmfCSType not supported"); break; case CCBUTIL_DELETE: - cst = avd_cstype_get(&opdata->objectName); + cst = cstype_db->find(&opdata->objectName); if (cst->list_of_csi != NULL) { /* check whether there exists a delete operation for * each of the CSI in the cs_type list in the current CCB @@ -286,10 +266,7 @@ static void cstype_ccb_apply_cb(CcbUtilO void avd_cstype_constructor(void) { - NCS_PATRICIA_PARAMS patricia_params; - - patricia_params.key_size = sizeof(SaNameT); - osafassert(ncs_patricia_tree_init(&cstype_db, &patricia_params) == NCSCC_RC_SUCCESS); + cstype_db= new AmfDb<avd_cstype_t>; avd_class_impl_set("SaAmfCSType", NULL, NULL, cstype_ccb_completed_hdlr, cstype_ccb_apply_cb); diff --git a/osaf/services/saf/amf/amfd/include/csi.h b/osaf/services/saf/amf/amfd/include/csi.h --- a/osaf/services/saf/amf/amfd/include/csi.h +++ b/osaf/services/saf/amf/amfd/include/csi.h @@ -84,12 +84,13 @@ typedef struct avd_csi_tag { } AVD_CSI; typedef struct avd_cstype { - NCS_PATRICIA_NODE tree_node; /* key is name */ SaNameT name; /* name of the CSType */ SaStringT *saAmfCSAttrName; AVD_CSI *list_of_csi; } avd_cstype_t; +extern AmfDb<avd_cstype_t> *cstype_db; + /* This data structure lives in the AvD and reflects relationship * between the component and CSI on the AvD. */ ------------------------------------------------------------------------------ "Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE Instantly run your Selenium tests across 300+ browser/OS combos. Get unparalleled scalability from the best Selenium testing platform available Simple to use. Nothing to install. Get started now for free." http://p.sf.net/sfu/SauceLabs _______________________________________________ Opensaf-devel mailing list Opensaf-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensaf-devel