Re: [devel] [PATCH 1 of 1] amfd: use db_template for the apptype db V2 [#713]

2014-04-22 Thread Nagendra Kumar
Ack

Thanks
-Nagu

> -Original Message-
> From: Hans Nordeback [mailto:hans.nordeb...@ericsson.com]
> Sent: 22 April 2014 16:32
> To: Praveen Malviya; Nagendra Kumar
> Cc: opensaf-devel@lists.sourceforge.net
> Subject: [PATCH 1 of 1] amfd: use db_template for the apptype db V2 [#713]
> 
>  osaf/services/saf/amf/amfd/apptype.cc|  27 +--
>  osaf/services/saf/amf/amfd/include/app.h |   4 
>  2 files changed, 9 insertions(+), 22 deletions(-)
> 
> 
> diff --git a/osaf/services/saf/amf/amfd/apptype.cc
> b/osaf/services/saf/amf/amfd/apptype.cc
> --- a/osaf/services/saf/amf/amfd/apptype.cc
> +++ b/osaf/services/saf/amf/amfd/apptype.cc
> @@ -23,22 +23,17 @@
>  #include 
>  #include 
> 
> -static NCS_PATRICIA_TREE apptype_db;
> +AmfDb *app_type_db = 0;
> 
>  AVD_APP_TYPE *avd_apptype_get(const SaNameT *dn)
>  {
> - SaNameT tmp = {0};
> -
> - tmp.length = dn->length;
> - memcpy(tmp.value, dn->value, tmp.length);
> -
> - return (AVD_APP_TYPE *)ncs_patricia_tree_get(&apptype_db,
> (uint8_t *)&tmp);
> + return app_type_db->find(dn);
>  }
> 
>  static void apptype_delete(AVD_APP_TYPE **apptype)
>  {
> - unsigned int rc = ncs_patricia_tree_del(&apptype_db, &(*apptype)-
> >tree_node);
> - osafassert(rc == NCSCC_RC_SUCCESS);
> + app_type_db->erase(*apptype);
> +
>   delete [] (*apptype)->sgAmfApptSGTypes;
>   delete *apptype;
>   *apptype = NULL;
> @@ -47,10 +42,10 @@ static void apptype_delete(AVD_APP_TYPE
>  static void apptype_add_to_model(AVD_APP_TYPE *app_type)
>  {
>   unsigned int rc;
> -
>   osafassert(app_type != NULL);
>   TRACE("'%s'", app_type->name.value);
> - rc = ncs_patricia_tree_add(&apptype_db, &app_type->tree_node);
> +
> + rc = app_type_db->insert(app_type);
>   osafassert(rc == NCSCC_RC_SUCCESS);
>  }
> 
> @@ -113,11 +108,10 @@ static AVD_APP_TYPE *apptype_create(SaNa
>   TRACE_ENTER2("'%s'", dn->value);
> 
>   app_type = new AVD_APP_TYPE();
> -
> +
>   memcpy(app_type->name.value, dn->value, dn->length);
>   app_type->name.length = dn->length;
> - app_type->tree_node.key_info = (uint8_t *)&(app_type->name);
> -
> +
>   while ((attr = attributes[i++]) != NULL)
>   if (!strcmp(attr->attrName, "saAmfApptSGTypes"))
>   break;
> @@ -291,10 +285,7 @@ void avd_apptype_remove_app(AVD_APP *app
> 
>  void avd_apptype_constructor(void)
>  {
> - NCS_PATRICIA_PARAMS patricia_params;
> -
> - patricia_params.key_size = sizeof(SaNameT);
> - osafassert(ncs_patricia_tree_init(&apptype_db, &patricia_params) ==
> NCSCC_RC_SUCCESS);
> + app_type_db = new AmfDb;
> 
>   avd_class_impl_set("SaAmfAppBaseType", NULL, NULL,
>   avd_imm_default_OK_completed_cb, NULL);
> diff --git a/osaf/services/saf/amf/amfd/include/app.h
> b/osaf/services/saf/amf/amfd/include/app.h
> --- a/osaf/services/saf/amf/amfd/include/app.h
> +++ b/osaf/services/saf/amf/amfd/include/app.h
> @@ -27,8 +27,6 @@
>  #include 
>  #include 
> 
> -// TODO(hafe) remove include below when apptype is using map
> -#include 
>  #include 
>  #include 
>  #include "db_template.h"
> @@ -37,8 +35,6 @@ struct avd_sg_tag;
>  struct avd_si_tag;
> 
>  typedef struct avd_app_type_tag {
> -
> - NCS_PATRICIA_NODE tree_node;/* key is name */
>   SaNameT name;
>   SaNameT *sgAmfApptSGTypes;
>   uint32_t no_sg_types;

--
Start Your Social Network Today - Download eXo Platform
Build your Enterprise Intranet with eXo Platform Software
Java Based Open Source Intranet - Social, Extensible, Cloud Ready
Get Started Now And Turn Your Intranet Into A Collaboration Platform
http://p.sf.net/sfu/ExoPlatform
___
Opensaf-devel mailing list
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel


[devel] [PATCH 1 of 1] amfd: use db_template for the apptype db V2 [#713]

2014-04-22 Thread Hans Nordeback
 osaf/services/saf/amf/amfd/apptype.cc|  27 +--
 osaf/services/saf/amf/amfd/include/app.h |   4 
 2 files changed, 9 insertions(+), 22 deletions(-)


diff --git a/osaf/services/saf/amf/amfd/apptype.cc 
b/osaf/services/saf/amf/amfd/apptype.cc
--- a/osaf/services/saf/amf/amfd/apptype.cc
+++ b/osaf/services/saf/amf/amfd/apptype.cc
@@ -23,22 +23,17 @@
 #include 
 #include 
 
-static NCS_PATRICIA_TREE apptype_db;
+AmfDb *app_type_db = 0;
 
 AVD_APP_TYPE *avd_apptype_get(const SaNameT *dn)
 {
-   SaNameT tmp = {0};
-
-   tmp.length = dn->length;
-   memcpy(tmp.value, dn->value, tmp.length);
-
-   return (AVD_APP_TYPE *)ncs_patricia_tree_get(&apptype_db, (uint8_t 
*)&tmp);
+   return app_type_db->find(dn);
 }
 
 static void apptype_delete(AVD_APP_TYPE **apptype)
 {
-   unsigned int rc = ncs_patricia_tree_del(&apptype_db, 
&(*apptype)->tree_node);
-   osafassert(rc == NCSCC_RC_SUCCESS);
+   app_type_db->erase(*apptype);
+   
delete [] (*apptype)->sgAmfApptSGTypes;
delete *apptype;
*apptype = NULL;
@@ -47,10 +42,10 @@ static void apptype_delete(AVD_APP_TYPE 
 static void apptype_add_to_model(AVD_APP_TYPE *app_type)
 {
unsigned int rc;
-
osafassert(app_type != NULL);
TRACE("'%s'", app_type->name.value);
-   rc = ncs_patricia_tree_add(&apptype_db, &app_type->tree_node);
+   
+   rc = app_type_db->insert(app_type);
osafassert(rc == NCSCC_RC_SUCCESS);
 }
 
@@ -113,11 +108,10 @@ static AVD_APP_TYPE *apptype_create(SaNa
TRACE_ENTER2("'%s'", dn->value);
 
app_type = new AVD_APP_TYPE();
-
+   
memcpy(app_type->name.value, dn->value, dn->length);
app_type->name.length = dn->length;
-   app_type->tree_node.key_info = (uint8_t *)&(app_type->name);
-
+   
while ((attr = attributes[i++]) != NULL)
if (!strcmp(attr->attrName, "saAmfApptSGTypes"))
break;
@@ -291,10 +285,7 @@ void avd_apptype_remove_app(AVD_APP *app
 
 void avd_apptype_constructor(void)
 {
-   NCS_PATRICIA_PARAMS patricia_params;
-
-   patricia_params.key_size = sizeof(SaNameT);
-   osafassert(ncs_patricia_tree_init(&apptype_db, &patricia_params) == 
NCSCC_RC_SUCCESS);
+   app_type_db = new AmfDb;
 
avd_class_impl_set("SaAmfAppBaseType", NULL, NULL,
avd_imm_default_OK_completed_cb, NULL);
diff --git a/osaf/services/saf/amf/amfd/include/app.h 
b/osaf/services/saf/amf/amfd/include/app.h
--- a/osaf/services/saf/amf/amfd/include/app.h
+++ b/osaf/services/saf/amf/amfd/include/app.h
@@ -27,8 +27,6 @@
 #include 
 #include 
 
-// TODO(hafe) remove include below when apptype is using map
-#include 
 #include 
 #include 
 #include "db_template.h"
@@ -37,8 +35,6 @@ struct avd_sg_tag;
 struct avd_si_tag;
 
 typedef struct avd_app_type_tag {
-
-   NCS_PATRICIA_NODE tree_node;/* key is name */
SaNameT name;
SaNameT *sgAmfApptSGTypes;
uint32_t no_sg_types;

--
Start Your Social Network Today - Download eXo Platform
Build your Enterprise Intranet with eXo Platform Software
Java Based Open Source Intranet - Social, Extensible, Cloud Ready
Get Started Now And Turn Your Intranet Into A Collaboration Platform
http://p.sf.net/sfu/ExoPlatform
___
Opensaf-devel mailing list
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel