From mksong at vt.edu Sun Dec 12 20:51:28 2010 From: mksong at vt.edu (Myoungkyu Song) Date: Sun Dec 12 20:51:56 2010 Subject: [odb-users] Generating Database Support Code Message-ID: Hello Boris and ODB users, I am writing this post about a problem of generating database support code. Firstly, I was able to generate the database support code against the hello-world example code by using "person.hxx" (e.g., "person-odb.cxx", "person-odb.hxx", and "person-odb.ixx", "person.sql"). (http://www.codesynthesis.com/products/odb/doc/manual.xhtml#2) Then, my problem is that when I tried to generate DB-Codes with the attached file--"SequenceModel.h" adding the persistence code, I have gotten the following errors; $ odb -d mysql --generate-query SequenceModel.h -I../../../x10_2.1.0/include SequenceModel.h:27:1: error: unnamed type in data member declaration SequenceModel.h:27:1: info: use 'typedef' to name this SequenceModel.h:28:1: error: unnamed type in data member SequenceModel.h:28:1: info: use 'typedef' to name this type Here is my system information: Linux (Kubuntu) 2.6.32-26-generic, g++ (Ubuntu 4.4.3-4ubuntu5) 4.4.3, and gcc (Ubuntu 4.4.3-4ubuntu5) 4.4.3. Best regards, Myoungkyu Song -------------- next part -------------- A non-text attachment was scrubbed... Name: SequenceModel.h Type: text/x-chdr Size: 2426 bytes Desc: not available Url : http://codesynthesis.com/pipermail/odb-users/attachments/20101212/8dde1992/SequenceModel.h -------------- next part -------------- A non-text attachment was scrubbed... Name: SequenceModel.cc Type: text/x-c++src Size: 5359 bytes Desc: not available Url : http://codesynthesis.com/pipermail/odb-users/attachments/20101212/8dde1992/SequenceModel.cc From boris at codesynthesis.com Mon Dec 13 05:22:47 2010 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Dec 13 05:14:50 2010 Subject: [odb-users] Generating Database Support Code In-Reply-To: References: Message-ID: Hi Myoungkyu, Myoungkyu Song writes: > SequenceModel.h:27:1: error: unnamed type in data member declaration > SequenceModel.h:27:1: info: use 'typedef' to name this ODB 1.0.0 does not support template-ids like x10aux::ref in persistent data members. The next release (1.1.0, planned for the beginning of January) will fix this. In the meantime, you can use a typedef alias to work around this limitation, for example: typedef x10aux::ref StringRef; StringRef FMGL(id); I can also package you a beta distribution of ODB 1.1.0 with the template-id support, if you would like. Boris From mksong at vt.edu Mon Dec 13 10:34:36 2010 From: mksong at vt.edu (Myoungkyu Song) Date: Mon Dec 13 10:35:05 2010 Subject: [odb-users] Generating Database Support Code In-Reply-To: References: Message-ID: Hi, Boris Thanks for your reply. Actually, based on the odb-compile-message, I had already tried to fix it by using this 'typedef' way. However, I had gotten another error message like this; $ odb -I../../../x10_2.1.0/include/ -d mysql --generate-query SequenceModel.h SequenceModel.h:68:1: error: unable to map C++ type '::StringRef' used in data member 'x10__id' to a database type SequenceModel.h:68:1: info: use '#pragma db type' to specify the database type (Attached is the modified files.) Best regards, Myoungkyu Song On Mon, Dec 13, 2010 at 5:22 AM, Boris Kolpackov wrote: > Hi Myoungkyu, > > Myoungkyu Song writes: > > > SequenceModel.h:27:1: error: unnamed type in data member declaration > > SequenceModel.h:27:1: info: use 'typedef' to name this > > ODB 1.0.0 does not support template-ids like x10aux::ref > in persistent data members. The next release (1.1.0, planned for the > beginning > of January) will fix this. In the meantime, you can use a typedef alias to > work around this limitation, for example: > > typedef x10aux::ref StringRef; > StringRef FMGL(id); > > I can also package you a beta distribution of ODB 1.1.0 with the > template-id > support, if you would like. > > Boris > -------------- next part -------------- A non-text attachment was scrubbed... Name: SequenceModel.h Type: text/x-chdr Size: 2540 bytes Desc: not available Url : http://codesynthesis.com/pipermail/odb-users/attachments/20101213/d67fa240/SequenceModel.h -------------- next part -------------- A non-text attachment was scrubbed... Name: SequenceModel.cc Type: text/x-c++src Size: 5359 bytes Desc: not available Url : http://codesynthesis.com/pipermail/odb-users/attachments/20101213/d67fa240/SequenceModel.cc From boris at codesynthesis.com Mon Dec 13 11:07:04 2010 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Dec 13 10:59:09 2010 Subject: [odb-users] Generating Database Support Code In-Reply-To: References: Message-ID: Hi Myoungkyu, Myoungkyu Song writes: > However, I had gotten another error message like this; > > $ odb -I../../../x10_2.1.0/include/ -d mysql --generate-query > SequenceModel.h > SequenceModel.h:68:1: error: unable to map C++ type '::StringRef' used in > data member 'x10__id' to a database type > SequenceModel.h:68:1: info: use '#pragma db type' to specify the database > type You will need to tell the ODB compiler how to map x10aux::ref to a suitable database type (e.g., TEXT, VARCHAR, etc). You will also need to provide the value_traits specialization for this type. For more information on how to do all this, see the 'mapping' example as well as Section 5.3.1, "type" in the manual: http://www.codesynthesis.com/products/odb/doc/manual.xhtml#5.3.1 Boris From boris at codesynthesis.com Tue Dec 14 10:58:46 2010 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Dec 14 10:50:48 2010 Subject: [odb-users] Generating Database Support Code In-Reply-To: <00b601cb9af9$a67571c0$f3605540$@vt.edu> References: <05c401cb9af8$f2ee6df0$d8cb49d0$@cs.vt.edu> <00b601cb9af9$a67571c0$f3605540$@vt.edu> Message-ID: Hi Myoungkyu, I've CC'ed my reply to the odb-users mailing list since others might have similar questions. Myoungkyu Song writes: > I wanted to give you some background about my research project. Thanks, sounds very interesting. > I was wondering if pragmas is the only means of interfacing with the ODB > compiler. In our case, we need to add pragmas to the C++ files emitted by > the X10 to C++ compiler, which may require us to modify the compiler making > it aware of the persistent classes. > Is it possible to specify persistent C++ classes using a configuration file > or an XML deployment descriptor? In other words, even though pragmas are > pretty straightforward to add, this requires parsing C++ header files, so I > was wondering if this can be somehow avoided. Pragmas can be factored out to a separate file which would be more or less the "mapping" file you are looking for. For instance, the pragmas in the 'hello' example can be rewritten like this: // file : hello/person-mapping.hxx #pragma db object(person) #pragma db member(person::id_) id auto In ODB 1.0.0 you would still need to #include this file at the end of the header file that defines the persistent classes. For example: // file : hello/person.hxx ... #ifdef ODB_COMPILER # include "person-mapping.hxx" #endif In the upcoming ODB 1.1.0 the header file can be left unchanged and the mapping file added to the ODB compilation process with the --odb-prologue compiler option. For more information, see Chapter 5, "ODB Pragma Language", particularly the next on named pragmas: http://www.codesynthesis.com/products/odb/doc/manual.xhtml#5 > I was also wondering whether it is possible to persist a subset of the > fields of a persistent class. In other words, is it possible to configure > ODB in such a way that some of the fields remain transient? Yes, you can mark any member as transient with the 'transient' pragma. Again, see the documentation for details. Boris From boris at codesynthesis.com Thu Dec 16 09:08:18 2010 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Dec 16 09:00:12 2010 Subject: [odb-users] Compiling Database Support Code In-Reply-To: References: Message-ID: Hi Myoungkyu, In the future please send technical questions like these to the odb-users mailing list (which I've CC'ed) instead of to me directly. This way other developers who may have experienced a similar problem can provide you with a solution. Plus questions and answers will be archived and available to others with similar problems. Also see the posting guidelines for more information: http://www.codesynthesis.com/support/posting-guidelines.xhtml Myoungkyu Song writes: > After completing the ODB-compile, I got some errors while compiling > all source codes, which it seems to me that the odb-mysql API does not > support the type. In other words, it does not look like the added > defined type is compatible with the existing code. > > typedef x10aux::ref StringRef; // (2) ODB > #pragma db value(StringRef) type("TEXT NOT NULL") > > In summary, "/usr/local/include/odb/mysql/traits.hxx" does not have > the matched function; "set_image" and "set _value", etc. The ODB runtime cannot possibly know how to serialize the x10aux::ref type. You will need to provide a value_traits specialization for this, as I explained in my previous email. Please study the 'mapping' example and the documentation to see how to do this. Boris From mksong at vt.edu Fri Dec 17 00:26:42 2010 From: mksong at vt.edu (Myoungkyu Song) Date: Fri Dec 17 00:27:09 2010 Subject: [odb-users] [Question] persist a custom object class Message-ID: # ODB version: 1.0.0 # OS: Linux 2.6.32-26-generic-Ubuntu # Compiler: g++ (Ubuntu 4.4.3-4ubuntu5) 4.4.3 Hi, I would like to ask about persisting the custom class object. For example, consider the followings; ============================================================ class SequenceModel : public x10::lang::Object { public: RTT_H_DECLS_CLASS void _instance_init(); x10aux::ref FMGL(name); x10aux::ref FMGL(sequence); ... } ============================================================ Then, in order to pass to the ODB-DB-API generator, I put the ?#pragma? like this; ============================================================ #include // (1) ODB typedef x10aux::ref StringRef; // (2) ODB #pragma db value(StringRef) type("TEXT NOT NULL") // (2) ODB #pragma db object // (3) ODB class SequenceModel : public x10::lang::Object { public: RTT_H_DECLS_CLASS void _instance_init(); StringRef FMGL(name); // (4) ODB StringRef FMGL(sequence); // (4) ODB ... private: SequenceModel() {} // (5) ODB friend class odb::access; // (6) ODB #pragma db id auto // (7) ODB unsigned long id_; // (7) ODB }; ============================================================ And then, I was wondering whether I need to modify ? /usr/local/include/odb/mysql/traits.hxx? for the specialization of the custom object class, ?StringRef?? Best regards, Myoungkyu Song From mksong at vt.edu Fri Dec 17 23:56:49 2010 From: mksong at vt.edu (Myoungkyu Song) Date: Fri Dec 17 23:57:27 2010 Subject: [odb-users] Calling the persist function passing a custom object class Message-ID: # ODB version: 1.0.0 # OS: Linux 2.6.32-26-generic-Ubuntu # Compiler: g++ (Ubuntu 4.4.3-4ubuntu5) 4.4.3 Hi, I would like to ask about calling the persist function passing the custom class object (e.i., SequenceModel class). For example, consider the followings; ============================================================ *SequenceModel.h* #include // (1) ODB typedef x10aux::ref StringRef; // (2) ODB #pragma db value(StringRef) type("TEXT NOT NULL") // (2) ODB #pragma db object // (3) ODB class SequenceModel : public x10::lang::Object { public: RTT_H_DECLS_CLASS void _instance_init(); StringRef FMGL(name); // (4) ODB StringRef FMGL(sequence); // (4) ODB ... private: SequenceModel() {} // (5) ODB friend class odb::access; // (6) ODB #pragma db id auto // (7) ODB unsigned long id_; // (7) ODB }; ============================================================ Then, I updated the "*traits.hxx and traits.cxx*" in order to re-compile libodb-mysql library. ============================================================ ** traits.hxx* class LIBODB_MYSQL_EXPORT *x10_string_value_traits* { public: typedef x10aux::ref value_type; typedef x10aux::ref query_type; typedef details::buffer image_type; static void set_value (x10aux::ref& 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&, std::size_t& n, bool& is_null, const x10aux::ref&); }; template <> struct LIBODB_MYSQL_EXPORT default_value_traits< x10aux::ref, details::buffer, id_string>:x10_string_value_traits {}; template <> struct LIBODB_MYSQL_EXPORT default_value_traits< x10aux::ref, details::buffer, id_decimal>:x10_string_value_traits {}; template <> struct LIBODB_MYSQL_EXPORT default_value_traits< x10aux::ref, details::buffer, id_enum>:x10_string_value_traits {}; template <> struct LIBODB_MYSQL_EXPORT default_value_traits< x10aux::ref, details::buffer, id_set>:x10_string_value_traits {}; ============================================================ * *traits.cxx* void x10_string_value_traits:: set_image (buffer& b, size_t& n, bool& is_null, const x10aux::ref& 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); } } ============================================================ However, in the client code I have gotten some error messages; ============================================================ void makePersistence(x10aux::ref seqModel) { char* argv[] = { "app", "--user", "root", "--password", "root", "--host", "localhost", "--database", "mydb" }; int argc = 9; try { auto_ptr < database > db(new mysql::database(argc, argv)); transaction t(db->begin()); db->persist(seqModel); t.commit(); cout << "makePersistence: " << endl; } catch (const odb::exception& e) { cerr << e.what() << endl; } } ============================================================ In file included from /usr/local/include/odb/database.hxx:13, from dbtrax.cc:8: /usr/local/include/odb/traits.hxx: At global scope: /usr/local/include/odb/traits.hxx: In instantiation of ?odb::object_traits >?: dbtrax.cc:30: instantiated from here /usr/local/include/odb/traits.hxx:81: error: invalid use of incomplete type ?struct odb::access::object_traits >? /usr/local/include/odb/forward.hxx:23: error: declaration of ?struct odb::access::object_traits >? /usr/local/include/odb/traits.hxx:84: error: invalid use of incomplete type ?struct odb::access::object_traits >? /usr/local/include/odb/forward.hxx:23: error: declaration of ?struct odb::access::object_traits >? dbtrax.cc: In function ?void makePersistence(x10aux::ref)?: dbtrax.cc:30: error: no matching function for call to ?odb::database::persist(x10aux::ref&)? Command exited with non-zero status 1 1.66user 0.15system 0:01.88elapsed 96%CPU (0avgtext+0avgdata 288304maxresident)k 0inputs+8outputs (0major+18350minor)pagefaults 0swaps make: *** [dbtrax.o] Error 1 smk@smk-laptop:~/workspace/x10test1$ ============================================================ Do you have any valuable experience related to this problem? Thank you in advance. Best regards, Myoungkyu Song -------------- next part -------------- A non-text attachment was scrubbed... Name: traits.cxx Type: text/x-c++src Size: 1597 bytes Desc: not available Url : http://codesynthesis.com/pipermail/odb-users/attachments/20101217/137af6a7/traits.cxx -------------- next part -------------- A non-text attachment was scrubbed... Name: traits.hxx Type: text/x-c++hdr Size: 7985 bytes Desc: not available Url : http://codesynthesis.com/pipermail/odb-users/attachments/20101217/137af6a7/traits.hxx -------------- next part -------------- A non-text attachment was scrubbed... Name: SequenceModel.h Type: text/x-chdr Size: 2586 bytes Desc: not available Url : http://codesynthesis.com/pipermail/odb-users/attachments/20101217/137af6a7/SequenceModel.h From mksong at vt.edu Sun Dec 19 01:21:00 2010 From: mksong at vt.edu (Myoungkyu Song) Date: Sun Dec 19 01:21:28 2010 Subject: [odb-users] Including a custom object field member in the persistence class Message-ID: # 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 When it comes to including a custom object field member in the persistence class, the ODB-Example package mentioned in the ODB Manual, specifically the mapping example, demonstrates how to specify the additional source file, "traits.hxx" for the ODB compiler, in order to provide the mapping to the DB system type. However, I have gotten the following errors related to the odb-runtime libraries. =================================================================== time g++ -g -I/home/smk/x10_2.1.0/include -I/home/smk/workspace/x10test1 -I. -Wno-long-long -Wno-unused-parameter -pthread -msse2 -mfpmath=sse -L/usr/local/lib -L/usr/local/lib/mysql -lodb -lodb-mysql -c dbtrax.cc -o dbtrax.o dbtrax.cc: In function ?void makePersistence(StringRef)?: dbtrax.cc:25: warning: deprecated conversion from string constant to ?char*? dbtrax.cc:25: warning: deprecated conversion from string constant to ?char*? dbtrax.cc:25: warning: deprecated conversion from string constant to ?char*? dbtrax.cc:25: warning: deprecated conversion from string constant to ?char*? dbtrax.cc:25: warning: deprecated conversion from string constant to ?char*? dbtrax.cc:25: warning: deprecated conversion from string constant to ?char*? dbtrax.cc:25: warning: deprecated conversion from string constant to ?char*? dbtrax.cc:25: warning: deprecated conversion from string constant to ?char*? dbtrax.cc:25: warning: deprecated conversion from string constant to ?char*? In file included from /usr/local/include/odb/database.hxx:13, from dbtrax.cc:8: /usr/local/include/odb/traits.hxx: At global scope: /usr/local/include/odb/traits.hxx: In instantiation of ?odb::object_traits >?: dbtrax.cc:31: instantiated from here /usr/local/include/odb/traits.hxx:81: error: invalid use of incomplete type ?struct odb::access::object_traits >? /usr/local/include/odb/forward.hxx:23: error: declaration of ?struct odb::access::object_traits >? /usr/local/include/odb/traits.hxx:84: error: invalid use of incomplete type ?struct odb::access::object_traits >? /usr/local/include/odb/forward.hxx:23: error: declaration of ?struct odb::access::object_traits >? dbtrax.cc: In function ?void makePersistence(StringRef)?: dbtrax.cc:31: error: no matching function for call to ?odb::database::persist(StringRef&)? Command exited with non-zero status 1 1.68user 0.09system 0:01.77elapsed 100%CPU (0avgtext+0avgdata 288352maxresident)k 0inputs+8outputs (0major+18353minor)pagefaults 0swaps make: *** [dbtrax.o] Error 1 root@smk-laptop:/home/smk/workspace/x10test1# ========================================================= So, do I need to carry out any additional work? For example, I saw the comments below in another "traits.hxx" for specialization. Would you be able to provide the related example? The example package does not offer the corresponding example. // template // class access::object_traits; // // Specializations should inherit from object_memory, object_factory // and define the following members: // // id_type - object id (primary key) type // id_type id (const T&) - get object id // // void persist (database&, T&) // void update (database&, T&) // void erase (database&, const id_type&) // pointer_type find (database&, const id_type&) // bool find (database&, const id_type&, T&) // Best regards, Myoungkyu Song -------------- next part -------------- A non-text attachment was scrubbed... Name: dbtrax.cc Type: text/x-c++src Size: 911 bytes Desc: not available Url : http://codesynthesis.com/pipermail/odb-users/attachments/20101219/78660868/dbtrax.cc -------------- next part -------------- A non-text attachment was scrubbed... Name: dbtrax.h Type: text/x-chdr Size: 290 bytes Desc: not available Url : http://codesynthesis.com/pipermail/odb-users/attachments/20101219/78660868/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/78660868/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/78660868/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/78660868/Makefile.obj -------------- next part -------------- A non-text attachment was scrubbed... Name: SequenceModel.h Type: text/x-chdr Size: 2586 bytes Desc: not available Url : http://codesynthesis.com/pipermail/odb-users/attachments/20101219/78660868/SequenceModel.h -------------- next part -------------- A non-text attachment was scrubbed... Name: SequenceModel.cc Type: text/x-c++src Size: 4956 bytes Desc: not available Url : http://codesynthesis.com/pipermail/odb-users/attachments/20101219/78660868/SequenceModel.cc -------------- next part -------------- A non-text attachment was scrubbed... Name: traits.hxx Type: text/x-c++hdr Size: 972 bytes Desc: not available Url : http://codesynthesis.com/pipermail/odb-users/attachments/20101219/78660868/traits.hxx From mksong at vt.edu Sun Dec 19 23:27:14 2010 From: mksong at vt.edu (Myoungkyu Song) Date: Sun Dec 19 23:27:38 2010 Subject: [odb-users] Specialization of persist (database&, T&) Message-ID: To: odb-users@codesynthesis.com CC: boris@codesynthesis.com, tilevich@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 #include #include #include #include "SequenceModel.h" #include #include #include #include #include #include using namespace std; typedef x10aux::ref StringRef; typedef x10aux::ref SequenceModelRef; namespace odb { template<> class access::object_traits { public: typedef x10aux::ref id_type; typedef x10aux::ref* 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, details::buffer, id_string> { public: typedef x10aux::ref value_type; typedef x10aux::ref query_type; typedef details::buffer image_type; static void set_value(x10aux::ref& 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 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@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 From mksong at vt.edu Mon Dec 20 02:56:36 2010 From: mksong at vt.edu (Myoungkyu Song) Date: Mon Dec 20 02:57:04 2010 Subject: [odb-users] Re: Specialization of persist (database&, T&) In-Reply-To: References: Message-ID: 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@vt.edu hiizzgi@gmail.com http://people.cs.vt.edu/~mksong/ On Sun, Dec 19, 2010 at 11:27 PM, Myoungkyu Song wrote: > To: odb-users@codesynthesis.com > CC: boris@codesynthesis.com, tilevich@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 > #include > #include > #include > > #include "SequenceModel.h" > > #include > #include > > #include > #include > > #include > #include > > using namespace std; > > typedef x10aux::ref StringRef; > typedef x10aux::ref SequenceModelRef; > > namespace odb { > > template<> > class access::object_traits { > > public: > typedef x10aux::ref id_type; > typedef x10aux::ref* 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, details::buffer, > id_string> { > public: > typedef x10aux::ref value_type; > typedef x10aux::ref query_type; > typedef details::buffer image_type; > > static void set_value(x10aux::ref& 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 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@vt.edu > http://people.cs.vt.edu/~mksong/ > > From boris at codesynthesis.com Mon Dec 20 10:00:01 2010 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Dec 20 09:51:29 2010 Subject: [odb-users] Re: Including a custom object field member in the persistence class In-Reply-To: References: Message-ID: Hi Myoungkyu, Myoungkyu Song writes: > typedef x10aux::ref StringRef; > > void makePersistence(StringRef seqModel) { > > ... > > db->persist(seqModel); You cannot persist value types directly. Only classes marked with '#prgama db object' can be passed to the database::persist() functions. Boris