ack, code review only. Minor question below. /Thanks HansN

On 01/25/2016 05:35 AM, Gary Lee wrote:
>   osaf/services/saf/amf/amfd/include/db_template.h |  39 
> +++++++++++++++++++++++-
>   1 files changed, 38 insertions(+), 1 deletions(-)
>
>
> SaNameTWrapper allows easy conversion from std::string to SaNameT required
> by many API functions
>
> 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
> @@ -17,6 +17,7 @@
>   #ifndef DB_TEMPLATE_H
>   #define     DB_TEMPLATE_H
>   
> +#include <osaf_extended_name.h>
>   #include <map>
>   #include <string>
>   #include "saAis.h"
> @@ -26,10 +27,46 @@
>   class Amf {
>   public:
>     static std::string to_string(const SaNameT *name) {
> -       return std::string((char*)name->value, name->length);
> +    return osaf_extended_name_borrow(name);
>     }
>   };
>   
> +class SaNameTWrapper {
> +public:
> +  SaNameTWrapper(const std::string& str) {
> +    osaf_extended_name_alloc(str.c_str(), &name);
> +  };
> +  ~SaNameTWrapper() {
> +    clear();
> +  };
> +
> +  // note: SaNameT* will become invalid if this SaNameTWrapper is destroyed
> +  operator const SaNameT*() const {
> +    return &name;
> +  };
> +
[HansN] is this comment correct? Isn't name returned by value, i.e copied?
> +  // note: SaNameT will become invalid if this SaNameTWrapper is destroyed
> +  operator const SaNameT() const {
> +    return name;
> +  }
> +
> +  void set(const std::string& str) {
> +    osaf_extended_name_free(&name);
> +    osaf_extended_name_alloc(str.c_str(), &name);
> +  };
> +
> +  void clear() {
> +    osaf_extended_name_free(&name);
> +  };
> +
> +  SaNameTWrapper(const SaNameTWrapper&) = delete;
> +  SaNameTWrapper& operator=(const SaNameTWrapper&) = delete;
> +  SaNameTWrapper() = delete;
> +
> +private:
> +  SaNameT name{};
> +};
> +     
>   //
>   template <typename Key, typename T>
>   class AmfDb {


------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140
_______________________________________________
Opensaf-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensaf-devel

Reply via email to