Hi Hans N,

No. If could be helpful, if you could push it along with broken code fixed.

Thanks
-Nagu

> -----Original Message-----
> From: Hans Nordebäck [mailto:hans.nordeb...@ericsson.com]
> Sent: 28 May 2014 16:37
> To: Nagendra Kumar; Praveen Malviya
> Cc: Hans Feldt; opensaf-devel@lists.sourceforge.net
> Subject: RE: [PATCH 1 of 1] amfd: add support for different key types in
> db_template, app_db updated [#713]
> 
> Hi Nagu, do you mean I should push this patch without updating
> dependent/broken code?  /Regrads HansN
> 
> -----Original Message-----
> From: Nagendra Kumar [mailto:nagendr...@oracle.com]
> Sent: den 28 maj 2014 13:09
> To: Hans Nordebäck; Praveen Malviya
> Cc: Hans Feldt; opensaf-devel@lists.sourceforge.net
> Subject: RE: [PATCH 1 of 1] amfd: add support for different key types in
> db_template, app_db updated [#713]
> 
> Can you please push it asap as we need to rebase our patches on yours. It 
> blocks
> us.
> 
> Thanks
> -Nagu
> > -----Original Message-----
> > From: Hans Nordebäck [mailto:hans.nordeb...@ericsson.com]
> > Sent: 28 May 2014 16:01
> > To: praveen malviya
> > Cc: hans.fe...@ericsson.com; Nagendra Kumar; opensaf-
> > de...@lists.sourceforge.net
> > Subject: Re: [PATCH 1 of 1] amfd: add support for different key types
> > in db_template, app_db updated [#713]
> >
> > Yes I can do that, it will be done next week.
> > /Regards HansN
> > On 05/28/14 12:21, praveen malviya wrote:
> > > Patch looks fine, but it cannot be pushed without making the
> > > compatible changes in already changed and committed databases like
> > > AVD_SU, AVD_SI etc.
> > > Are you going to float the patches for  them.
> > >
> > > Thanks
> > > Praveen
> > > On 26-May-14 6:40 PM, Hans Nordeback wrote:
> > >> osaf/libs/saf/include/saAis.h                    |   4 ++
> > >>   osaf/services/saf/amf/amfd/app.cc                |  18 +++++-----
> > >>   osaf/services/saf/amf/amfd/include/app.h         |   2 +-
> > >>   osaf/services/saf/amf/amfd/include/db_template.h |  40
> > >> ++++++++++-------------
> > >>   4 files changed, 32 insertions(+), 32 deletions(-)
> > >>
> > >>
> > >> diff --git a/osaf/libs/saf/include/saAis.h
> > >> b/osaf/libs/saf/include/saAis.h
> > >> --- a/osaf/libs/saf/include/saAis.h
> > >> +++ b/osaf/libs/saf/include/saAis.h
> > >> @@ -35,6 +35,7 @@
> > >>   #define _SA_AIS_H
> > >>     #ifdef  __cplusplus
> > >> +#include <string>
> > >>   extern "C" {
> > >>   #endif
> > >>   @@ -159,6 +160,9 @@ typedef struct {
> > >>   typedef struct {
> > >>       SaUint16T length;
> > >>       SaUint8T value[SA_MAX_NAME_LENGTH];
> > >> +#ifdef  __cplusplus
> > >> +     operator std::string() const {return
> > >> +std::string((char*)value,
> > >> length);}
> > >> +#endif
> > >>   } SaNameT;
> > >>     typedef struct {
> > >> diff --git a/osaf/services/saf/amf/amfd/app.cc
> > >> b/osaf/services/saf/amf/amfd/app.cc
> > >> --- a/osaf/services/saf/amf/amfd/app.cc
> > >> +++ b/osaf/services/saf/amf/amfd/app.cc
> > >> @@ -24,7 +24,7 @@
> > >>   #include <imm.h>
> > >>   #include <si.h>
> > >>   -AmfDb<AVD_APP> *app_db = 0;
> > >> +AmfDb<std::string, AVD_APP> *app_db = 0;
> > >>     // TODO(hafe) change this to a constructor
> > >>   static AVD_APP *avd_app_new(const SaNameT *dn) @@ -38,7 +38,7
> @@
> > >> static AVD_APP *avd_app_new(const SaName
> > >>   // TODO(hafe) change this to a destructor
> > >>   static void avd_app_delete(AVD_APP *app)
> > >>   {
> > >> -    app_db->erase(app);
> > >> +    app_db->erase(app->name);
> > >>       m_AVSV_SEND_CKPT_UPDT_ASYNC_RMV(avd_cb, app,
> > >> AVSV_CKPT_AVD_APP_CONFIG);
> > >>       avd_apptype_remove_app(app);
> > >>       delete app;
> > >> @@ -54,7 +54,7 @@ static void app_add_to_model(AVD_APP *ap
> > >>           goto done;
> > >>       }
> > >>   -    app_db->insert(app);
> > >> +    app_db->insert(app->name, app);
> > >>         /* Find application type and make a link with app type */
> > >>       app->app_type = avd_apptype_get(&app->saAmfAppType);
> > >> @@ -196,7 +196,7 @@ AVD_APP *avd_app_create(const SaNameT *d
> > >>       ** If called at new active at failover, the object is found
> > >> in the DB
> > >>       ** but needs to get configuration attributes initialized.
> > >>       */
> > >> -    app = app_db->find(dn);
> > >> +    app = app_db->find(*dn);
> > >>       if (app == NULL) {
> > >>           if ((app = avd_app_new(dn)) == NULL)
> > >>               goto done;
> > >> @@ -282,7 +282,7 @@ static void app_ccb_apply_cb(CcbUtilOper
> > >>           break;
> > >>       case CCBUTIL_MODIFY: {
> > >>           const SaImmAttrModificationT_2 *attr_mod;
> > >> -        app = app_db->find(&opdata->objectName);
> > >> +        app = app_db->find(*(&opdata->objectName));
> > >>             while ((attr_mod = opdata->param.modify.attrMods[i++])
> > >> !=
> > >> NULL) {
> > >>               const SaImmAttrValuesT_2 *attribute =
> > >> &attr_mod->modAttr; @@ -302,7 +302,7 @@ static void
> > app_ccb_apply_cb(CcbUtilOper
> > >>           break;
> > >>       }
> > >>       case CCBUTIL_DELETE:
> > >> -        app = app_db->find(&opdata->objectName);
> > >> +        app = app_db->find(*(&opdata->objectName));
> > >>           /* by this time all the SGs and SIs under this
> > >>            * app object should have been *DELETED* just
> > >>            * do a sanity check here @@ -327,7 +327,7 @@ static void
> > >> app_admin_op_cb(SaImmOiHandl
> > >>       TRACE_ENTER2("%s", object_name->value);
> > >>         /* Find the app name. */
> > >> -    app = app_db->find(object_name);
> > >> +    app = app_db->find(*object_name);
> > >>       osafassert(app != NULL);
> > >>         if (op_id == SA_AMF_ADMIN_UNLOCK) { @@ -384,7 +384,7 @@
> done:
> > >>   static SaAisErrorT app_rt_attr_cb(SaImmOiHandleT immOiHandle,
> > >>       const SaNameT *objectName, const SaImmAttrNameT
> *attributeNames)
> > >>   {
> > >> -    AVD_APP *app = app_db->find(objectName);
> > >> +    AVD_APP *app = app_db->find(*objectName);
> > >>       SaImmAttrNameT attributeName;
> > >>       int i = 0;
> > >>   @@ -461,7 +461,7 @@ SaAisErrorT avd_app_config_get(void)
> > >>     void avd_app_constructor(void)
> > >>   {
> > >> -    app_db = new AmfDb<AVD_APP>;
> > >> +    app_db = new AmfDb<std::string, AVD_APP>;
> > >> avd_class_impl_set(const_cast<SaImmClassNameT>("SaAmfApplication"),
> > >>                  app_rt_attr_cb,
> > >> 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
> > >> @@ -53,7 +53,7 @@ typedef struct avd_app_tag {
> > >>       struct avd_app_type_tag *app_type;
> > >>   } AVD_APP;
> > >>   -extern AmfDb<AVD_APP> *app_db;
> > >> +extern AmfDb<std::string, AVD_APP> *app_db;
> > >>     extern void avd_app_add_si(AVD_APP *app, struct avd_si_tag *si);
> > >>   extern void avd_app_remove_si(AVD_APP *app, struct avd_si_tag
> > >> *si); diff --git a/osaf/services/saf/amf/amfd/include/db_template.h
> > >> b/osaf/services/saf/amf/amfd/include/db_template.h
> > >> --- a/osaf/services/saf/amf/amfd/include/db_template.h
> > >> +++ b/osaf/services/saf/amf/amfd/include/db_template.h
> > >> @@ -21,14 +21,14 @@
> > >>   #include <string>
> > >>   #include "ncsgl_defs.h"
> > >>   -template <typename T>
> > >> +template <typename Key, typename T>
> > >>   class AmfDb {
> > >>     public:
> > >> -   unsigned int insert(T *obj);
> > >> -   void erase(T *obj);
> > >> -   T *find(const SaNameT *name);
> > >> +   unsigned int insert(const Key &key, T *obj);
> > >> +   void erase(const Key &obj);
> > >> +   T *find(const Key &name);
> > >>      -   typedef std::map<std::string, T*> AmfDbMap;
> > >> +   typedef std::map<Key, T*> AmfDbMap;
> > >>      typedef typename AmfDbMap::const_iterator const_iterator;
> > >>        const_iterator begin() const {return db.begin();} @@ -38,32
> > >> +38,28 @@ class AmfDb {
> > >>      AmfDbMap db;
> > >>   };
> > >>   -template <typename T>
> > >> -unsigned int AmfDb<T>::insert(T *obj) {
> > >> +template <typename Key, typename T> unsigned int AmfDb<Key,
> > >> +T>::insert(const Key &key, T *obj) {
> > >>     osafassert(obj);
> > >> -  std::string name((const char*)obj->name.value,
> > >> obj->name.length);
> > >> -  if (db.insert(std::make_pair(name, obj)).second) {
> > >> -    return NCSCC_RC_SUCCESS;
> > >> +
> > >> +  if (db.insert(std::make_pair(key, obj)).second) {
> > >> +    return 0;
> > >>     }
> > >>      else {
> > >> -      return NCSCC_RC_FAILURE; // Duplicate
> > >> +      return -1; // Duplicate
> > >>       }
> > >>    }
> > >>   -template <typename T>
> > >> -void AmfDb<T>::erase(T *obj) {
> > >> -  osafassert(obj);
> > >> -  std::string name((const char*)obj->name.value,
> > >> obj->name.length);
> > >> -  db.erase(name);
> > >> +template <typename Key, typename T> void AmfDb<Key,
> > >> +T>::erase(const Key &key) {
> > >> +  db.erase(key);
> > >>   }
> > >>   -template <typename T>
> > >> -T *AmfDb<T>::find(const SaNameT *dn) {
> > >> -  osafassert(dn);
> > >> -  std::string name((const char*)dn->value, dn->length);
> > >> -  typename AmfDbMap::iterator it = db.find(name);
> > >> +template <typename Key, typename T> T *AmfDb<Key, T>::find(const
> > >> +Key &dn) {
> > >> +  typename AmfDbMap::iterator it = db.find(dn);
> > >>     if (it == db.end())
> > >> -    return NULL;
> > >> +    return 0;
> > >>     else
> > >>       return it->second;
> > >>   }
> > >
> >

------------------------------------------------------------------------------
Time is money. Stop wasting it! Get your web API in 5 minutes.
www.restlet.com/download
http://p.sf.net/sfu/restlet
_______________________________________________
Opensaf-devel mailing list
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel

Reply via email to