Ok but it would not be wrong even if your focus is on conversion to c++ here, if the new c++ code just "happened" not to use SaNameT at that inner level. Just saves time long term without causing any problem.
/AndersBj Hans Feldt wrote: > Yes we are aware of that, just trying to do one logical thing at a > time. First item was to remove use of patricia trees. > /HansF > > On 17 January 2014 11:42, Anders Björnerstedt > <[email protected]> wrote: > >> Just use std:string directly instead of SaNameT. >> >> /AndersBj >> >> -----Original Message----- >> From: Anders Björnerstedt [mailto:[email protected]] >> Sent: den 17 januari 2014 11:10 >> To: Hans Nordebäck; Hans Feldt; [email protected]; >> [email protected] >> Cc: [email protected] >> Subject: Re: [devel] [PATCH 1 of 2] amfd: use template class db to replace >> patricia tree db [#713] >> >> Since you are rewriting the internal database for AMFD, could you try to >> avoid using the SaNameT type in this new representation ? >> I mean these are internal structures so you dont need to use SaNameT here. >> We are trying to find a way to move away from the troublesome SaNameT type, >> in general. >> >> /AndersBj >> >> -----Original Message----- >> From: Hans Nordeback [mailto:[email protected]] >> Sent: den 17 januari 2014 11:03 >> To: Hans Feldt; [email protected]; [email protected] >> Cc: [email protected] >> Subject: [devel] [PATCH 1 of 2] amfd: use template class db to replace >> patricia tree db [#713] >> >> osaf/services/saf/amf/amfd/include/db_template.h | 63 >> ++++++++++++++++++++++++ >> 1 files changed, 63 insertions(+), 0 deletions(-) >> >> >> diff --git a/osaf/services/saf/amf/amfd/include/db_template.h >> b/osaf/services/saf/amf/amfd/include/db_template.h >> new file mode 100644 >> --- /dev/null >> +++ b/osaf/services/saf/amf/amfd/include/db_template.h >> @@ -0,0 +1,63 @@ >> +/* -*- OpenSAF -*- >> + * >> + * (C) Copyright 2014 The OpenSAF Foundation >> + * >> + * This program is distributed in the hope that it will be useful, but >> + * WITHOUT ANY WARRANTY; without even the implied warranty of >> +MERCHANTABILITY >> + * or FITNESS FOR A PARTICULAR PURPOSE. This file and program are >> +licensed >> + * under the GNU Lesser General Public License Version 2.1, February 1999. >> + * The complete license can be accessed from the following location: >> + * http://opensource.org/licenses/lgpl-license.php >> + * See the Copying file included with the OpenSAF distribution for full >> + * licensing terms. >> + * >> + * Author(s): Ericsson AB >> + * >> + */ >> +#ifndef DB_TEMPLATE_H >> +#define DB_TEMPLATE_H >> + >> +#include <map> >> +#include <string> >> + >> +template <typename T> >> +class AmfDb { >> + public: >> + void insert(T *obj); >> + void erase(T *obj); >> + T *find(const SaNameT *name); >> + >> + typedef std::map<std::string, T*> AmfDbMap; >> + typedef typename AmfDbMap::const_iterator const_iterator; >> + >> + const_iterator begin() const {return db.begin();} >> + const_iterator end() const {return db.end();} >> + >> + private: >> + AmfDbMap db; >> +}; >> + >> +template <typename T> >> +void AmfDb<T>::insert(T *obj) { >> + std::string name((const char*)obj->name.value, obj->name.length); >> + db[name] = obj; >> +} >> + >> +template <typename T> >> +void AmfDb<T>::erase(T *obj) { >> + std::string name((const char*)obj->name.value, obj->name.length); >> + typename AmfDbMap::iterator it = db.find(name); >> + db.erase(it); >> +} >> + >> +template <typename T> >> +T *AmfDb<T>::find(const SaNameT *dn) { >> + std::string name((const char*)dn->value, dn->length); >> + typename AmfDbMap::iterator it = db.find(name); >> + if (it == db.end()) >> + return NULL; >> + else >> + return it->second; >> +} >> + >> +#endif /* DB_TEMPLATE_H */ >> >> ------------------------------------------------------------------------------ >> CenturyLink Cloud: The Leader in Enterprise Cloud Services. >> Learn Why More Businesses Are Choosing CenturyLink Cloud For Critical >> Workloads, Development Environments & Everything In Between. >> Get a Quote or Start a Free Trial Today. >> http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk >> _______________________________________________ >> Opensaf-devel mailing list >> [email protected] >> https://lists.sourceforge.net/lists/listinfo/opensaf-devel >> >> ------------------------------------------------------------------------------ >> CenturyLink Cloud: The Leader in Enterprise Cloud Services. >> Learn Why More Businesses Are Choosing CenturyLink Cloud For Critical >> Workloads, Development Environments & Everything In Between. >> Get a Quote or Start a Free Trial Today. >> http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk >> _______________________________________________ >> Opensaf-devel mailing list >> [email protected] >> https://lists.sourceforge.net/lists/listinfo/opensaf-devel >> >> ------------------------------------------------------------------------------ >> CenturyLink Cloud: The Leader in Enterprise Cloud Services. >> Learn Why More Businesses Are Choosing CenturyLink Cloud For >> Critical Workloads, Development Environments & Everything In Between. >> Get a Quote or Start a Free Trial Today. >> http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk >> _______________________________________________ >> Opensaf-devel mailing list >> [email protected] >> https://lists.sourceforge.net/lists/listinfo/opensaf-devel >> ------------------------------------------------------------------------------ CenturyLink Cloud: The Leader in Enterprise Cloud Services. Learn Why More Businesses Are Choosing CenturyLink Cloud For Critical Workloads, Development Environments & Everything In Between. Get a Quote or Start a Free Trial Today. http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk _______________________________________________ Opensaf-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/opensaf-devel
