[odb-users] Re: Specialization of persist (database&, T&)

Myoungkyu Song mksong at vt.edu
Mon Dec 20 02:56:36 EST 2010


Hi, Boris and odb-users

Sorry about the posting below. The issues I addressed was not the correct
directions. I figured it out in another way in my client code.

I am sorry about any inconvenience again.
Best regards,
Myoungkyu Song
---------
Software Innovations Lab, Department of Computer Science, Virginia Tech
Blacksburg, VA 24060
mksong at vt.edu
hiizzgi at gmail.com
http://people.cs.vt.edu/~mksong/



On Sun, Dec 19, 2010 at 11:27 PM, Myoungkyu Song <mksong at vt.edu> wrote:

> To: odb-users at codesynthesis.com
> CC: boris at codesynthesis.com, tilevich at cs.vt.edu
> Subject: [Question] Specialization of persist (database&, T&)
>
> # ODB version: 1.0.0
> # OS: Linux 2.6.32-26-generic-Ubuntu
> # Compiler: g++ (Ubuntu 4.4.3-4ubuntu5) 4.4.3
>
> Hi, Boris and odb-users
>
> In terms of specialization of traits in libodb-1.0.0, I need your help.
> The attached source files were compiled, however I need to implement the
> body of the methods in traits.hxx, such as persist, id, etc.
> Which file I should refer when I implement the methods?
>
>
> ==================================================================================
> traits.hxx
>
> #ifndef TRAITS_HXX
> #define TRAITS_HXX
>
> #include <cstring>
> #include <iostream>
> #include <string>
> #include <stdio.h>
>
> #include "SequenceModel.h"
>
> #include <odb/traits.hxx>
> #include <odb/mysql/traits.hxx>
>
> #include <x10/lang/Runtime.h>
> #include <x10aux/bootstrap.h>
>
> #include <x10/lang/Runtime.h>
> #include <x10aux/bootstrap.h>
>
> using namespace std;
>
> typedef x10aux::ref<x10::lang::String> StringRef;
> typedef x10aux::ref<SequenceModel> SequenceModelRef;
>
> namespace odb {
>
> template<>
> class access::object_traits<SequenceModelRef> {
>
> public:
> typedef x10aux::ref<x10::lang::String> id_type;
>  typedef x10aux::ref<x10::lang::String>* pointer_type;
>
>  static id_type id(SequenceModelRef& obj) {
>         // TODO
> }
>
> static void persist(database& db, SequenceModelRef& obj) {
>  cout << "[DBG] persist is called in traits." << endl;
>         // TODO
>  }
> };
>
> namespace mysql {
> template<>
> class value_traits<x10aux::ref<x10::lang::String>, details::buffer,
> id_string> {
> public:
>  typedef x10aux::ref<x10::lang::String> value_type;
> typedef x10aux::ref<x10::lang::String> query_type;
>  typedef details::buffer image_type;
>
>  static void set_value(x10aux::ref<x10::lang::String>& v, const
> details::buffer& b, std::size_t n, bool is_null) {
>  if (!is_null)
> v = x10aux::string_utils::lit(b.data());
>  else
> v = x10aux::string_utils::lit("");
>  }
>
>  static void set_image(details::buffer& b, std::size_t& n, bool& is_null,
> x10aux::ref<x10::lang::String> v) {
>  is_null = false;
> n = v->length();
>
> if (n > b.capacity())
>  b.capacity(n);
>
>  if (n != 0)
> memcpy(b.data(), x10aux::string_utils::cstr(v), n);
>  }
> };
> }
> }
> #endif // TRAITS_HXX
>
> ==================================================================================
>
>
> Best regards,
> Myoungkyu Song
>  ----------
> Software Innovations Lab, Department of Computer Science, Virginia Tech
> Blacksburg, VA 24060
> mksong at vt.edu
> http://people.cs.vt.edu/~mksong/
>
>


More information about the odb-users mailing list