[odb-users] Specialization of persist (database&, T&)
Myoungkyu Song
mksong at vt.edu
Sun Dec 19 23:27:14 EST 2010
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/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dbtrax.cc
Type: text/x-c++src
Size: 891 bytes
Desc: not available
Url : http://codesynthesis.com/pipermail/odb-users/attachments/20101219/ebdd8602/dbtrax.cc
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dbtrax.h
Type: text/x-chdr
Size: 208 bytes
Desc: not available
Url : http://codesynthesis.com/pipermail/odb-users/attachments/20101219/ebdd8602/dbtrax.h
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Driver.cc
Type: text/x-c++src
Size: 4767 bytes
Desc: not available
Url : http://codesynthesis.com/pipermail/odb-users/attachments/20101219/ebdd8602/Driver.cc
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Driver.h
Type: text/x-chdr
Size: 2210 bytes
Desc: not available
Url : http://codesynthesis.com/pipermail/odb-users/attachments/20101219/ebdd8602/Driver.h
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Makefile
Type: application/octet-stream
Size: 3067 bytes
Desc: not available
Url : http://codesynthesis.com/pipermail/odb-users/attachments/20101219/ebdd8602/Makefile.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: traits.hxx
Type: text/x-c++hdr
Size: 1587 bytes
Desc: not available
Url : http://codesynthesis.com/pipermail/odb-users/attachments/20101219/ebdd8602/traits.hxx
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Driver.x10
Type: application/octet-stream
Size: 1263 bytes
Desc: not available
Url : http://codesynthesis.com/pipermail/odb-users/attachments/20101219/ebdd8602/Driver.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: SequenceModel.h.org
Type: application/octet-stream
Size: 2586 bytes
Desc: not available
Url : http://codesynthesis.com/pipermail/odb-users/attachments/20101219/ebdd8602/SequenceModel.h.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: SequenceModel.x10
Type: application/octet-stream
Size: 762 bytes
Desc: not available
Url : http://codesynthesis.com/pipermail/odb-users/attachments/20101219/ebdd8602/SequenceModel.obj
More information about the odb-users
mailing list