[odb-users] Building GOF Composite Pattern ODB-1.5.0

Dan Coffey dcoffey at netharmonix.com
Wed Aug 3 13:12:28 EDT 2011


Hi Boris,

I've commented out all of the lines that cause odb processing errors 
(attached src on last email)
I then compiled the files (Rdolls ...) using Qt Creator
Then I ran the odb command for each .cpp file without errors and the 
*-odb.[ch]xx and *.ixx files were created without errors.
The Qt .pro file was modified to include all of the created *-odb.[ch]xx 
files.
When I do a rebuild all in Qt I get the following errors from the 
rdollsgroup-odb.hxx file

/D:\Development\C++\TestCode\ODB\rdolls\rdolls-build-desktop\..\rdolls\rdollsgroup-odb.hxx:118: 
error: redefinition of 'struct 
odb::access::object_traits<RdollsGroup>::contains_traits'

D:\Development\C++\TestCode\ODB\rdolls\rdolls-build-desktop\..\rdolls\rdollsgroup-odb.hxx:107: 
error: previous definition of 'struct 
odb::access::object_traits<RdollsGroup>::contains_traits'/

Thanks,

Dan

Env:
XP SP3
minGW
Qt 4.7
g++ 4.5.2

On 8/3/2011 12:15 PM, Dan Coffey wrote:
> Hi Boris,
>
> QMap<QString, QSharedPointer<Rdolls> >
>
> works with the odb commands.  I also tried
> QMap <QString, Rdolls> contains; but this will cause odb to fail.
> QMap <QString, QLazyWeakPointer<Rdolls> > contains; which works with 
> the ODB preprocessor.
>
> In the odb manual example code (pg 58) you have - std::map<insigned 
> short, float> age_weight_map_;
> Is it possible to have a developer defined class as the value?
>
> Attached are the .h files, process.out which has the odb processing 
> commands and results.
> All of these compile in Qt Creator without error, I then run the odb 
> commands and the output is process.out.
> I also include the Qt files.
>
> Thanks,
>
> Dan
>
> On 8/3/2011 10:20 AM, Boris Kolpackov wrote:
>> Hi Dan,
>>
>> Dan Coffey<dcoffey at netharmonix.com>  writes:
>>
>>> QMap<QString, Rdolls>  contains;
>> Maybe that should be:
>>
>>    QMap<QString, Rdolls*>
>>
>> Or, better yet:
>>
>>    QMap<QString, QSharedPointer<Rdolls> >
>>
>> If that doesn't help, please send a minimal but complete header
>> file that fails to compile so that I can take a look. Without
>> seeing the actual C++ declarations I am just guessing.
>>
>> Boris
-------------- next part --------------
// This file was generated by ODB, object-relational mapping (ORM)
// compiler for C++.
//

#ifndef RDOLLSGROUP_ODB_HXX
#define RDOLLSGROUP_ODB_HXX

#include <odb/version.hxx>

#if (ODB_VERSION != 10500UL)
#error ODB runtime version mismatch
#endif

#include <odb/pre.hxx>

// Begin prologue.
//
#include <odb/qt/version.hxx>
#if LIBODB_QT_VERSION != 1050000 // 1.5.0
#  error ODB and C++ compilers see different libodb-qt versions
#endif
#include <odb/qt/basic/mysql/qstring-traits.hxx>
#include <odb/qt/basic/mysql/qbyte-array-traits.hxx>
#include <odb/qt/containers/qhash-traits.hxx>
#include <odb/qt/containers/qlist-traits.hxx>
#include <odb/qt/containers/qlinked-list-traits.hxx>
#include <odb/qt/containers/qmap-traits.hxx>
#include <odb/qt/containers/qset-traits.hxx>
#include <odb/qt/containers/qvector-traits.hxx>
#include <odb/qt/date-time/mysql/qdate-traits.hxx>
#include <odb/qt/date-time/mysql/qtime-traits.hxx>
#include <odb/qt/date-time/mysql/qdate-time-traits.hxx>
#include <QtCore/QSharedPointer>
#include <odb/qt/smart-ptr/pointer-traits.hxx>
#include <odb/boost/version.hxx>
#include <boost/shared_ptr.hpp>
#include <odb/boost/smart-ptr/pointer-traits.hxx>
#include <odb/boost/unordered/container-traits.hxx>
#include <odb/boost/date-time/mysql/gregorian-traits.hxx>
#include <odb/boost/date-time/mysql/posix-time-traits.hxx>
//
// End prologue.

#include "rdollsgroup.h"

#include "rdolls-odb.hxx"

#include <memory>
#include <cstddef>

#include <odb/core.hxx>
#include <odb/traits.hxx>
#include <odb/callback.hxx>
#include <odb/pointer-traits.hxx>
#ifdef BOOST_TR1_MEMORY_HPP_INCLUDED
#  include <odb/tr1/pointer-traits.hxx>
#endif
#include <odb/container-traits.hxx>
#include <odb/result.hxx>

#include <odb/details/buffer.hxx>
#include <odb/details/unused.hxx>

#include <odb/mysql/version.hxx>
#include <odb/mysql/forward.hxx>
#include <odb/mysql/mysql-types.hxx>
#include <odb/mysql/query.hxx>

namespace odb
{
  // RdollsGroup
  //
  template <>
  class access::object_traits< ::RdollsGroup >
  {
    public:
    typedef ::RdollsGroup object_type;
    typedef ::boost::shared_ptr< ::RdollsGroup > pointer_type;
    typedef object_traits< ::Rdolls >::id_type id_type;

    typedef object_traits< ::Rdolls >::id_image_type id_image_type;

    struct image_type: object_traits< ::Rdolls >::image_type
    {
      std::size_t version;
    };

    struct query_columns: object_traits< ::Rdolls >::query_columns
    {
    };

    // contains_ptrs
    //
    struct contains_ptrs_traits: access::object_traits< ::Rdolls >::contains_ptrs_traits
    {
      static const std::size_t cond_column_count = 1UL;
      static const std::size_t data_column_count = 3UL;

      static const char* const insert_one_statement;
      static const char* const select_all_statement;
      static const char* const delete_all_statement;
    };

    // contains_
    //
    struct contains_traits: access::object_traits< ::Rdolls >::contains_traits
    {
      static const std::size_t cond_column_count = 1UL;
      static const std::size_t data_column_count = 3UL;

      static const char* const insert_one_statement;
      static const char* const select_all_statement;
      static const char* const delete_all_statement;
    };

    // contains
    //
    struct contains_traits
    {
      static const std::size_t cond_column_count = 1UL;
      static const std::size_t data_column_count = 3UL;

      static const char* const insert_one_statement;
      static const char* const select_all_statement;
      static const char* const delete_all_statement;

      typedef ::QMap< ::QString, ::QSharedPointer< ::Rdolls > > container_type;
      typedef odb::access::container_traits< container_type > container_traits;
      typedef container_traits::key_type key_type;
      typedef container_traits::value_type value_type;

      typedef map_functions<key_type, value_type> functions_type;
      typedef mysql::container_statements< contains_traits > statements_type;

      struct cond_image_type
      {
        // key
        //
        details::buffer key_value;
        unsigned long key_size;
        my_bool key_null;

        std::size_t version;
      };

      struct data_image_type
      {
        // key
        //
        details::buffer key_value;
        unsigned long key_size;
        my_bool key_null;

        // value
        //
        unsigned long long value_value;
        my_bool value_null;

        std::size_t version;
      };

      static void
      bind (MYSQL_BIND*,
            const MYSQL_BIND* id,
            std::size_t id_size,
            cond_image_type&);

      static void
      bind (MYSQL_BIND*,
            const MYSQL_BIND* id,
            std::size_t id_size,
            data_image_type&);

      static void
      grow (data_image_type&, my_bool*);

      static void
      init (data_image_type&, const key_type&, const value_type&);

      static void
      init (key_type&, value_type&, const data_image_type&, database&);

      static void
      insert_one (const key_type&, const value_type&, void*);

      static bool
      load_all (key_type&, value_type&, void*);

      static void
      delete_all (void*);

      static void
      persist (const container_type&,
               const mysql::binding& id,
               statements_type&);

      static void
      load (container_type&,
            const mysql::binding& id,
            statements_type&);

      static void
      update (const container_type&,
              const mysql::binding& id,
              statements_type&);

      static void
      erase (const mysql::binding& id, statements_type&);
    };

    static id_type
    id (const object_type&);

    static id_type
    id (const image_type&);

    static bool
    grow (image_type&, my_bool*);

    static void
    bind (MYSQL_BIND*, image_type&, bool);

    static void
    bind (MYSQL_BIND*, id_image_type&);

    static bool
    init (image_type&, const object_type&);

    static void
    init (object_type&, const image_type&, database&);

    static void
    init (id_image_type&, const id_type&);

    typedef mysql::query query_base_type;

    struct query_type: query_base_type, query_columns
    {
      query_type ();
      query_type (const std::string&);
      query_type (const query_base_type&);
    };

    struct container_statement_cache_type;

    static const std::size_t in_column_count = 4UL;
    static const std::size_t out_column_count = 5UL;

    static const char* const persist_statement;
    static const char* const find_statement;
    static const char* const update_statement;
    static const char* const erase_statement;
    static const char* const query_clause;

    static void
    callback (database&, object_type&, callback_event);

    static void
    callback (database&, const object_type&, callback_event);

    static void
    persist (database&, object_type&);

    static void
    update (database&, const object_type&);

    static void
    erase (database&, const id_type&);

    static pointer_type
    find (database&, const id_type&);

    static bool
    find (database&, const id_type&, object_type&);

    template<typename T>
    static result<T>
    query (database&, const query_type&);

    public:
    static bool
    find_ (mysql::object_statements< object_type >&, const id_type&);

    static void
    load_ (mysql::object_statements< object_type >&, object_type&);

    static void
    query_ (database&,
            const query_type&,
            mysql::object_statements< object_type >&,
            details::shared_ptr< mysql::select_statement >&);
  };
}

#include "rdollsgroup-odb.ixx"

// Begin epilogue.
//
//
// End epilogue.

#include <odb/post.hxx>

#endif // RDOLLSGROUP_ODB_HXX


More information about the odb-users mailing list