[odb-users] Issue getting relashonships off the ground
Brian Bourke-Martin
brianbourke75 at gmail.com
Fri Sep 19 17:22:28 EDT 2014
I have a very simple relationship setup which I cannot get the odb output
to compile and it's giving me the below compiler error. I am using Qt
smart pointers to implement the relationship and I always seem to be
running into the same error no matter how many permutations I go through.
In file included from /usr/local/include/odb/database.hxx:499:0,
from /usr/local/include/odb/sqlite/database.hxx:16,
from
/home/brian/darkfield/NxtGen5/build/odb_gen/Part-odb.cxx:15:
/usr/local/include/odb/database.ixx: In member function ‘typename
odb::object_traits<T>::pointer_type odb::database::find_(const typename
odb::object_traits<T>::id_type&) [with T = Inspection, odb::database_id DB
= (odb::database_id)1u, typename odb::object_traits<T>::pointer_type =
QSharedPointer<Inspection>, typename odb::object_traits<T>::id_type =
QUuid]’:
/usr/local/include/odb/database.txx:82:38: instantiated from ‘typename
odb::object_traits<T>::pointer_type odb::database::load_(const typename
odb::object_traits<T>::id_type&) [with T = Inspection, odb::database_id DB
= (odb::database_id)1u, typename odb::object_traits<T>::pointer_type =
QSharedPointer<Inspection>, typename odb::object_traits<T>::id_type =
QUuid]’
/usr/local/include/odb/sqlite/database.ixx:100:37: instantiated from
‘typename odb::object_traits<T>::pointer_type
odb::sqlite::database::load(const typename odb::object_traits<T>::id_type&)
[with T = Inspection, typename odb::object_traits<T>::pointer_type =
QSharedPointer<Inspection>, typename odb::object_traits<T>::id_type =
QUuid]’
/home/brian/darkfield/NxtGen5/build/odb_gen/Part-odb.cxx:246:42:
instantiated from here
/usr/local/include/odb/database.ixx:570:54: error: no matching function for
call to ‘odb::object_traits_impl<Inspection,
(odb::database_id)1u>::find(odb::database&, const id_type&)’
/usr/local/include/odb/database.ixx:570:54: note: candidate is:
/home/brian/darkfield/NxtGen5/build/odb_gen/Inspection-odb.hxx:372:5: note:
static bool odb::access::object_traits_impl<Inspection,
(odb::database_id)1u>::find(odb::database&, const id_type&,
odb::access::object_traits<Inspection>::object_type&)
/home/brian/darkfield/NxtGen5/build/odb_gen/Inspection-odb.hxx:372:5: note:
candidate expects 3 arguments, 2 provided
here is the the parent class
#ifndef PART_H
#define PART_H
class Part;
#include <odb/core.hxx>
#include <odb/qt/lazy-ptr.hxx>
#include <QtCore/QString>
#include <QtCore/QByteArray>
#include <QtCore/QUuid>
#include <QtCore/QDateTime>
#include <QtCore/QSharedPointer>
#include <QtCore/QList>
#include <QtCore/QSet>
#include "Inspection.h"
/** this class represents the atomic parts which are acquired */
#pragma db object
class Part{
public:
/** public constructor */
Part(QString id);
/** gets the id */
const QString Id() const;
/** Get (or create) the inspection for a given system name */
QSharedPointer<Inspection> GetInspection(QString systemName = "");
private:
/** constructor */
Part(){}
/** odb needed reference */
friend class odb::access;
/** a list of all of the inspections for this part */
//#pragma db value_not_null inverse(parent)
QList<QSharedPointer<Inspection> > inspections;
/** holds a unique name/id for this object */
#pragma db id
QString id;
};
#endif // PART_H
And here is the child
#ifndef INSPECTION_H
#define INSPECTION_H
class Inspection;
#include <odb/core.hxx>
#include <odb/qt/lazy-ptr.hxx>
#include <QtCore/QString>
#include <QtCore/QByteArray>
#include <QtCore/QUuid>
#include <QtCore/QDateTime>
#include <QtCore/QSharedPointer>
#include <QtCore/QList>
#include <QtCore/QSet>
//#include "SurfaceDefect.h"
#include "vec2f.h"
#include "Part.h"
#include "MILImage.h"
using namespace std;
#pragma db object
class Inspection{
public:
/** gets the full image object for this inspection */
const QWeakPointer<MILImage> GetFullImage() const;
/** gets the start time of the inspection */
const QDateTime GetStarted() const;
/** gets the end time of the inspection */
const QDateTime GetEnded() const;
/** Gets the system name on which the inspection was acquired */
const QString GetSystemName() const;
/** sets the full image and takes ownership of it */
void SetFullImage(MILImage* fullImage);
/** sets the start time of the inspection */
void SetStarted(QDateTime started);
/** Sets the end time of the inspection */
void SetEnded(QDateTime ended);
private:
/** constructor */
Inspection(QString systemName);
/** odb needed reference */
friend class odb::access;
/** we give access to the part class to allow for construction */
friend class Part;
/** A unique identifier for the inspection */
#pragma db id
QUuid id;
/** the name of the system which acquired the inspection */
QString systemName;
/** The time and date the inspection was recorded to disk */
QDateTime Recorded;
/** A vector of all defects */
//#pragma db inverse(Source)
//QVector< QLazyWeakPointer<SurfaceDefect> > SurfaceDefects;
/** The username of the person inspecting the sheet */
QString Username;
/** All the metadata crammed into one QString */
QString MetaData;
/** The positions of the 4 corners of a sheet */
// TODO: this should not be transient
#pragma db transient
Vec2f Corners[4];
/** The time and date the inspection started */
QDateTime started;
/** the time and date the inspection ended */
QDateTime ended;
/** the full inspection image */
#pragma db transient
QSharedPointer<MILImage> fullImage;
/** the parent part of this object */
#pragma db not_null
QSharedPointer<Part> parent;
};
#endif // INSPECTION_H
Any help which could be given would be great!
More information about the odb-users
mailing list