|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r78479 - in sandbox/icl/libs/xplore/br1/sqlbrowser: . Dag data/concept data/qsql
From: afojgo_at_[hidden]
Date: 2012-05-15 11:26:20
Author: jofaber
Date: 2012-05-15 11:26:18 EDT (Tue, 15 May 2012)
New Revision: 78479
URL: http://svn.boost.org/trac/boost/changeset/78479
Log:
Worked on templates for data access concepts.
Added:
sandbox/icl/libs/xplore/br1/sqlbrowser/data/concept/GetCreator.h (contents, props changed)
Text files modified:
sandbox/icl/libs/xplore/br1/sqlbrowser/Dag/DbType.h | 7 +--
sandbox/icl/libs/xplore/br1/sqlbrowser/Dag/TypeGraph.h | 19 ---------
sandbox/icl/libs/xplore/br1/sqlbrowser/browser.cpp | 26 +++++++++++++
sandbox/icl/libs/xplore/br1/sqlbrowser/data/concept/CreatorTraits.h | 9 +++-
sandbox/icl/libs/xplore/br1/sqlbrowser/data/concept/Selector.h | 23 +++++++++--
sandbox/icl/libs/xplore/br1/sqlbrowser/data/qsql/QSqlCreator.h | 78 +++++++++++++++++++++++++++++++--------
sandbox/icl/libs/xplore/br1/sqlbrowser/data/qsql/QSqlSelector.h | 2
7 files changed, 116 insertions(+), 48 deletions(-)
Modified: sandbox/icl/libs/xplore/br1/sqlbrowser/Dag/DbType.h
==============================================================================
--- sandbox/icl/libs/xplore/br1/sqlbrowser/Dag/DbType.h (original)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/Dag/DbType.h 2012-05-15 11:26:18 EDT (Tue, 15 May 2012)
@@ -90,10 +90,9 @@
};
-//CL Don't optimize premature: Clearness first!!
-//CL I have to prepare and build the TypeGraph first.
-//
-
+//==============================================================================
+//= TypeGraph Objects
+//==============================================================================
class ObjectType
{
public:
Modified: sandbox/icl/libs/xplore/br1/sqlbrowser/Dag/TypeGraph.h
==============================================================================
--- sandbox/icl/libs/xplore/br1/sqlbrowser/Dag/TypeGraph.h (original)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/Dag/TypeGraph.h 2012-05-15 11:26:18 EDT (Tue, 15 May 2012)
@@ -36,25 +36,6 @@
void getTypeGraph(TypeGraph& tygr, const QSqlQuery& query);
-//! Data Access layer. May be sql, xml etc.
-class TypeGraphSqlAccessor // implements DataAccessor
-{
-public:
- // The DataAccessor interface (generic)
- bool prepareGet();
- bool next();
-
- // Interface specific to TypeGraph
- EdgeType edge();
-
-private:
- static tString s_aTypeEdgesQuery;
- static bool m_bInitialized;
-
- int m_Edge_Key_Idx;
- int m_Object_Key_Idx;
-};
-
}} // namespace dag::db
Modified: sandbox/icl/libs/xplore/br1/sqlbrowser/browser.cpp
==============================================================================
--- sandbox/icl/libs/xplore/br1/sqlbrowser/browser.cpp (original)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/browser.cpp 2012-05-15 11:26:18 EDT (Tue, 15 May 2012)
@@ -47,6 +47,9 @@
#include <QtGui>
#include <QtSql>
+//---- First Accessor tests ----------------
+#include "data/qsql/QSqlSelector.h"
+#include "data/concept/Selector.h"
Browser::Browser(QWidget *parent)
: QWidget(parent)
@@ -160,6 +163,7 @@
updateActions();
}
+/*JODO REV
bool Browser::runScript()
{
QString curSql = sqlEdit->toPlainText();
@@ -174,6 +178,28 @@
return success;
}
+*/
+
+bool Browser::runScript()
+{
+ QString curSql = "select * from EdgeType";
+ QSqlQuery curQuery = QSqlQuery(connectionWidget->currentDatabase());
+
+ //JODO Testcode
+ bool success = false;
+ data::QSqlSelector selector;
+ dag::db::TypeGraph tygra;
+
+ success = makeTypeGraph(selector, tygra);
+
+ if(success)
+ emit statusMessage(tr("Test executed successfully."));
+ else
+ emit statusMessage(tr("Error(s), Test aborted."));
+
+ return success;
+}
+
bool Browser::execMulti(QSqlQuery& query, const QString& script)
{
Modified: sandbox/icl/libs/xplore/br1/sqlbrowser/data/concept/CreatorTraits.h
==============================================================================
--- sandbox/icl/libs/xplore/br1/sqlbrowser/data/concept/CreatorTraits.h (original)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/data/concept/CreatorTraits.h 2012-05-15 11:26:18 EDT (Tue, 15 May 2012)
@@ -5,21 +5,24 @@
#pragma once
+#include "Dag/DbType.h"
namespace data
{
+typedef dag::db::tString tString;
+
//==============================================================================
//= Concept: data::Creator Traits
//==============================================================================
template<class Object, class Accessor>
struct CreatorTraits
{
- typedef typename Accessor::iterator iterator;
+ typedef typename Accessor::const_iterator const_iterator;
typedef typename Accessor::tQuery tQuery;
- static tQuery createQuery();
- static Object create(iterator);
+ static tString createQuery();
+ static Object create(const_iterator);
};
} // namespace data
Added: sandbox/icl/libs/xplore/br1/sqlbrowser/data/concept/GetCreator.h
==============================================================================
--- (empty file)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/data/concept/GetCreator.h 2012-05-15 11:26:18 EDT (Tue, 15 May 2012)
@@ -0,0 +1,26 @@
+/****************************************************************************
+**
+**
+****************************************************************************/
+
+#pragma once
+
+#include "data/qsql/QSqlSelector.h"
+
+namespace data
+{
+
+template<class Object, class Accessor>
+struct GetCreator;
+
+template<class Object>
+struct GetCreator<QSqlSelector>
+{
+ typedef QSqlCreator<Object, QSqlSelector> type;
+};
+
+
+} // namespace data
+
+
+
Modified: sandbox/icl/libs/xplore/br1/sqlbrowser/data/concept/Selector.h
==============================================================================
--- sandbox/icl/libs/xplore/br1/sqlbrowser/data/concept/Selector.h (original)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/data/concept/Selector.h 2012-05-15 11:26:18 EDT (Tue, 15 May 2012)
@@ -14,20 +14,33 @@
#include "Dag/TypeGraph.h"
#include "data/concept/IsQuerySelector.h"
+#include "data/qsql/QSqlCreator.h"
namespace data
{
// If it is an SqlAccessor, make the type-graph like so:
template<class Accessor>
-typename boost::enable_if< IsQuerySelector<Accessor>, void>::type
-makeTypeGraph(Accessor& accessor, TypeGraph& typeGraph)
+typename boost::enable_if< IsQuerySelector<Accessor>, bool>::type
+makeTypeGraph(Accessor& accessor, dag::db::TypeGraph& typeGraph)
{
- typedef typename Accessor::iterator iterator;
- DataSelectorConcept<Accessor>::
- select(accessor, CreatorConcept<Object,Accessor>::createQuery());
+ typedef QSqlCreator<dag::db::EdgeType,Accessor> tCreator;
+ typedef typename Accessor::const_iterator const_iterator;
+ //DataSelectorConcept<Accessor>::
+ // select(accessor, CreatorConcept<Object,Accessor>::createQuery());
//JODO transform(accessor, typeGraph, CreatorConcept<TypeEdge,AccessorT>);
//for(iterator it = accessor.begin(); it != accessor.end(); ++it)
+
+ QString ObjSql = CreatorTraits<dag::db::EdgeType,tCreator>::createQuery();
+
+ QMessageBox msgBox;
+ QString msg = "Insertion. ";
+ msg += ObjSql;
+ msgBox.setText(msg);
+ msgBox.exec();
+
+
+ return true;
}
} // namespace data
Modified: sandbox/icl/libs/xplore/br1/sqlbrowser/data/qsql/QSqlCreator.h
==============================================================================
--- sandbox/icl/libs/xplore/br1/sqlbrowser/data/qsql/QSqlCreator.h (original)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/data/qsql/QSqlCreator.h 2012-05-15 11:26:18 EDT (Tue, 15 May 2012)
@@ -6,41 +6,56 @@
#pragma once
#include "Dag/DbType.h"
+#include "data/concept/CreatorTraits.h"
+#include "data/qsql/QSqlSelector.h"
namespace data
{
typedef dag::db::tString tString;
-template<class Object>class QSqlCreator;
-//==============================================================================
-//= Concept: data::Creator Spec: QSqlCreator
-//==============================================================================
-template<class Object>
-struct CreatorTraits<Object, QSqlCreator<Object> >
+template<class Object, class Accessor>
+class QSqlCreator;
+/*
{
- typedef QSqlCreator<Object> tCreator;
- typedef typename tCreator::const_iterator const_iterator;
- typedef typename tCreator::tQuery tQuery;
+public:
+ typedef QSqlCreator type;
+ typedef Object tObject;
+ typedef Accessor tAccessor;
- static tQuery createQuery();
- static Object create(iterator);
+ typedef typename tAccessor::tResultSet tResultSet;
+ typedef typename tAccessor::const_iterator const_iterator;
+
+ static tString createQuery()
+ {
+ return "...";
+ }
+
+ static tObject create(const_iterator it)
+ {
+ return tObject();
+ }
};
+*/
template<>
-class QSqlCreator<dag::db::EdgeType>
+class QSqlCreator<dag::db::EdgeType, QSqlSelector>
{
public:
+ typedef QSqlCreator type;
typedef dag::db::EdgeType tObject;
+ typedef QSqlSelector tAccessor;
- tString createQuery()const
+ typedef tAccessor::tResultSet tResultSet;
+ typedef tAccessor::const_iterator const_iterator;
+
+ static tString createQuery()
{
- return //JODO generate the query from data
- "SELECT ...";
+ return "SELECT ...";
}
- tObject create(const_iterator it)
+ static tObject create(const_iterator it)
{
return dag::db::EdgeType();
}
@@ -48,4 +63,35 @@
+template<class Object, class Accessor>class QSqlCreator;
+
+//==============================================================================
+//= Concept: data::Creator Spec: QSqlCreator
+//==============================================================================
+
+template<class Object, class Accessor>
+struct CreatorTraits<Object, QSqlCreator<Object, Accessor> >
+{
+ typedef QSqlCreator<Object,Accessor> tCreator;
+ typedef typename Accessor::const_iterator const_iterator;
+
+ static tString createQuery(){ return tCreator::createQuery(); }
+ static Object create(const_iterator it){ return tCreator::create(it); }
+};
+
+
+/*
+template<>
+struct CreatorTraits<dag::db::EdgeType, QSqlCreator<dag::db::EdgeType, data::QSqlSelector> >
+{
+ typedef dag::db::EdgeType tObject;
+ typedef data::QSqlSelector tAccessor;
+ typedef QSqlCreator<dag::db::EdgeType, data::QSqlSelector> tCreator;
+ typedef tAccessor::const_iterator const_iterator;
+
+ static tString createQuery(){ tCreator::createQuery(); }
+ static tObject create(const_iterator it){ return tCreator::create(it); }
+};
+*/
+
} // namespace data
Modified: sandbox/icl/libs/xplore/br1/sqlbrowser/data/qsql/QSqlSelector.h
==============================================================================
--- sandbox/icl/libs/xplore/br1/sqlbrowser/data/qsql/QSqlSelector.h (original)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/data/qsql/QSqlSelector.h 2012-05-15 11:26:18 EDT (Tue, 15 May 2012)
@@ -22,7 +22,7 @@
class QSqlSelector
{
public:
- typedef QVector<QVariant> type;
+ typedef QSqlSelector type;
typedef std::size_t size_type;
typedef QVector<QVariant> tResultSet;
typedef tResultSet::const_iterator const_iterator;
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk