ack, code review only/Regards HansN
On 06/04/14 12:19, praveen.malv...@oracle.com wrote:
>   osaf/services/saf/amf/amfd/compcstype.cc  |   4 +-
>   osaf/services/saf/amf/amfd/ctcstype.cc    |  37 
> +++++++-----------------------
>   osaf/services/saf/amf/amfd/include/comp.h |   5 ++-
>   osaf/services/saf/amf/amfd/util.cc        |   2 +-
>   4 files changed, 15 insertions(+), 33 deletions(-)
>
>
> diff --git a/osaf/services/saf/amf/amfd/compcstype.cc 
> b/osaf/services/saf/amf/amfd/compcstype.cc
> --- a/osaf/services/saf/amf/amfd/compcstype.cc
> +++ b/osaf/services/saf/amf/amfd/compcstype.cc
> @@ -206,7 +206,7 @@ static int is_config_valid(const SaNameT
>   
>       ctcstype_name.length = sprintf((char*)ctcstype_name.value, "%s,%s", 
> cstype_name, comptype_name->value);
>   
> -     if (avd_ctcstype_get(&ctcstype_name) == NULL) {
> +     if (ctcstype_db->find(Amf::to_string(&ctcstype_name)) == NULL) {
>               if (opdata == NULL) {
>                       report_ccb_validation_error(opdata, "'%s' does not 
> exist in model", ctcstype_name.value);
>                       goto free_cstype_name;
> @@ -258,7 +258,7 @@ static AVD_COMPCS_TYPE *compcstype_creat
>       ctcstype_name.length = sprintf((char*)ctcstype_name.value,
>               "%s,%s", cstype_name, comp->comp_type->name.value);
>   
> -     ctcstype = avd_ctcstype_get(&ctcstype_name);
> +     ctcstype = ctcstype_db->find(Amf::to_string(&ctcstype_name));
>   
>       if 
> (immutil_getAttr(const_cast<SaImmAttrNameT>("saAmfCompNumMaxActiveCSIs"), 
> attributes, 0,
>                               &num_max_act_csi) != SA_AIS_OK) {
> diff --git a/osaf/services/saf/amf/amfd/ctcstype.cc 
> b/osaf/services/saf/amf/amfd/ctcstype.cc
> --- a/osaf/services/saf/amf/amfd/ctcstype.cc
> +++ b/osaf/services/saf/amf/amfd/ctcstype.cc
> @@ -23,11 +23,11 @@
>   #include <comp.h>
>   #include <imm.h>
>   
> -static NCS_PATRICIA_TREE ctcstype_db;
> +AmfDb<std::string, AVD_CTCS_TYPE> *ctcstype_db = NULL;
>   
>   static void ctcstype_db_add(AVD_CTCS_TYPE *ctcstype)
>   {
> -     unsigned int rc = ncs_patricia_tree_add(&ctcstype_db, 
> &ctcstype->tree_node);
> +     unsigned int rc = 
> ctcstype_db->insert(Amf::to_string(&ctcstype->name),ctcstype);
>       osafassert(rc == NCSCC_RC_SUCCESS);
>   }
>   
> @@ -74,7 +74,6 @@ static AVD_CTCS_TYPE *ctcstype_create(co
>   
>       memcpy(ctcstype->name.value, dn->value, dn->length);
>       ctcstype->name.length = dn->length;
> -     ctcstype->tree_node.key_info = (uint8_t *)&(ctcstype->name);
>   
>       error = 
> immutil_getAttr(const_cast<SaImmAttrNameT>("saAmfCtCompCapability"), 
> attributes, 0, &ctcstype->saAmfCtCompCapability);
>       osafassert(error == SA_AIS_OK);
> @@ -96,25 +95,6 @@ static AVD_CTCS_TYPE *ctcstype_create(co
>       return ctcstype;
>   }
>   
> -static void ctcstype_delete(AVD_CTCS_TYPE *ctcstype)
> -{
> -     unsigned int rc;
> -
> -     rc = ncs_patricia_tree_del(&ctcstype_db, &ctcstype->tree_node);
> -     osafassert(rc == NCSCC_RC_SUCCESS);
> -     delete ctcstype;
> -}
> -
> -AVD_CTCS_TYPE *avd_ctcstype_get(const SaNameT *dn)
> -{
> -     SaNameT tmp = {0};
> -
> -     tmp.length = dn->length;
> -     memcpy(tmp.value, dn->value, tmp.length);
> -
> -     return (AVD_CTCS_TYPE *)ncs_patricia_tree_get(&ctcstype_db, (uint8_t 
> *)&tmp);
> -}
> -
>   SaAisErrorT avd_ctcstype_config_get(const SaNameT *comp_type_dn, 
> AVD_COMP_TYPE *comp_type)
>   {
>       SaAisErrorT error = SA_AIS_ERR_FAILED_OPERATION;
> @@ -143,7 +123,7 @@ SaAisErrorT avd_ctcstype_config_get(cons
>               if (!is_config_valid(&dn, attributes, NULL))
>                       goto done2;
>   
> -             if ((ctcstype = avd_ctcstype_get(&dn)) == NULL ) {
> +             if ((ctcstype = ctcstype_db->find(Amf::to_string(&dn))) == NULL 
> ) {
>                       if ((ctcstype = ctcstype_create(&dn, attributes)) == 
> NULL)
>                               goto done2;
>   
> @@ -199,8 +179,11 @@ static void ctcstype_ccb_apply_cb(CcbUti
>               ctcstype_db_add(ctcstype);
>               break;
>       case CCBUTIL_DELETE:
> -             ctcstype = avd_ctcstype_get(&opdata->objectName);
> -             ctcstype_delete(ctcstype);
> +             ctcstype = 
> ctcstype_db->find(Amf::to_string(&opdata->objectName));
> +             if (ctcstype != NULL) {
> +                     ctcstype_db->erase(Amf::to_string(&ctcstype->name));
> +                     delete ctcstype;
> +             }
>               break;
>       default:
>               osafassert(0);
> @@ -212,10 +195,8 @@ static void ctcstype_ccb_apply_cb(CcbUti
>   
>   void avd_ctcstype_constructor(void)
>   {
> -     NCS_PATRICIA_PARAMS patricia_params;
> +     ctcstype_db = new AmfDb<std::string, AVD_CTCS_TYPE>;
>   
> -     patricia_params.key_size = sizeof(SaNameT);
> -     osafassert(ncs_patricia_tree_init(&ctcstype_db, &patricia_params) == 
> NCSCC_RC_SUCCESS);
>       avd_class_impl_set("SaAmfCtCsType", NULL, NULL,
>               ctcstype_ccb_completed_cb, ctcstype_ccb_apply_cb);
>   }
> diff --git a/osaf/services/saf/amf/amfd/include/comp.h 
> b/osaf/services/saf/amf/amfd/include/comp.h
> --- a/osaf/services/saf/amf/amfd/include/comp.h
> +++ b/osaf/services/saf/amf/amfd/include/comp.h
> @@ -39,6 +39,7 @@
>   #include <ncspatricia.h>
>   #include <amf_d2nmsg.h>
>   #include <cb.h>
> +#include "db_template.h"
>   
>   class AVD_SU;
>   
> @@ -165,7 +166,6 @@ typedef struct avd_comp_cs_type_tag {
>   
>   /* AMF Class SaAmfCtCsType */
>   typedef struct {
> -     NCS_PATRICIA_NODE tree_node;    /* name is key */
>       SaNameT name;
>       SaAmfCompCapabilityModelT saAmfCtCompCapability;
>       SaUint32T saAmfCtDefNumMaxActiveCSIs;
> @@ -173,6 +173,8 @@ typedef struct {
>       AVD_COMP_TYPE *comptype;
>   } AVD_CTCS_TYPE;
>   
> +extern AmfDb<std::string, AVD_CTCS_TYPE> *ctcstype_db;
> +
>   extern AVD_COMP_GLOBALATTR avd_comp_global_attrs;
>   
>   /**
> @@ -224,7 +226,6 @@ extern SaAisErrorT avd_compglobalattrs_c
>   extern void avd_compglobalattrs_constructor(void);
>   
>   extern SaAisErrorT avd_ctcstype_config_get(const SaNameT *comp_type_dn, 
> AVD_COMP_TYPE *comp_type);
> -extern AVD_CTCS_TYPE *avd_ctcstype_get(const SaNameT *dn);
>   extern void avd_ctcstype_constructor(void);
>   
>   extern AVD_COMPCS_TYPE *avd_compcstype_new(const SaNameT *dn);
> diff --git a/osaf/services/saf/amf/amfd/util.cc 
> b/osaf/services/saf/amf/amfd/util.cc
> --- a/osaf/services/saf/amf/amfd/util.cc
> +++ b/osaf/services/saf/amf/amfd/util.cc
> @@ -666,7 +666,7 @@ static SaAmfCompCapabilityModelT get_com
>       SaNameT dn;
>       avsv_create_association_class_dn(&csi->cstype->name,
>               &comp->comp_type->name, "safSupportedCsType", &dn);
> -     AVD_CTCS_TYPE *ctcs_type = avd_ctcstype_get(&dn);
> +     AVD_CTCS_TYPE *ctcs_type = ctcstype_db->find(Amf::to_string(&dn));
>       osafassert(ctcs_type);
>       return ctcs_type->saAmfCtCompCapability;
>   }


------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their 
applications. Written by three acclaimed leaders in the field, 
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
_______________________________________________
Opensaf-devel mailing list
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel

Reply via email to