Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r78470 - in sandbox/icl/libs/xplore/br1/sqlbrowser: . Dag data data/concept data/qsql
From: afojgo_at_[hidden]
Date: 2012-05-14 12:12:48


Author: jofaber
Date: 2012-05-14 12:12:46 EDT (Mon, 14 May 2012)
New Revision: 78470
URL: http://svn.boost.org/trac/boost/changeset/78470

Log:
Added class templates for data access concepts.
Added:
   sandbox/icl/libs/xplore/br1/sqlbrowser/data/ (props changed)
   sandbox/icl/libs/xplore/br1/sqlbrowser/data/concept/ (props changed)
   sandbox/icl/libs/xplore/br1/sqlbrowser/data/concept/CreatorTraits.h (contents, props changed)
   sandbox/icl/libs/xplore/br1/sqlbrowser/data/concept/IsQuerySelector.h (contents, props changed)
   sandbox/icl/libs/xplore/br1/sqlbrowser/data/concept/Selector.h (contents, props changed)
   sandbox/icl/libs/xplore/br1/sqlbrowser/data/concept/SelectorTraits.h (contents, props changed)
   sandbox/icl/libs/xplore/br1/sqlbrowser/data/qsql/ (props changed)
   sandbox/icl/libs/xplore/br1/sqlbrowser/data/qsql/QSqlCreator.h (contents, props changed)
   sandbox/icl/libs/xplore/br1/sqlbrowser/data/qsql/QSqlSelector.h (contents, props changed)
Text files modified:
   sandbox/icl/libs/xplore/br1/sqlbrowser/Dag.h | 5 ++
   sandbox/icl/libs/xplore/br1/sqlbrowser/Dag/TypeGraph.cpp | 74 ----------------------------------------
   sandbox/icl/libs/xplore/br1/sqlbrowser/Dag/TypeGraph.h | 4 +-
   sandbox/icl/libs/xplore/br1/sqlbrowser/browser.cpp | 1
   sandbox/icl/libs/xplore/br1/sqlbrowser/sqlbrowser4.pro | 16 ++++++--
   5 files changed, 20 insertions(+), 80 deletions(-)

Modified: sandbox/icl/libs/xplore/br1/sqlbrowser/Dag.h
==============================================================================
--- sandbox/icl/libs/xplore/br1/sqlbrowser/Dag.h (original)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/Dag.h 2012-05-14 12:12:46 EDT (Mon, 14 May 2012)
@@ -12,9 +12,14 @@
 
 #include "dagitem.h"
 #include "Dag/DbType.h"
+
+//JODO CL ..
 #include "Dag/Decoration.h" //CL
 #include "Dag/DecoratedGraph.h" //CL
 #include "Dag/TypeGraph.h" //CL
+#include "data/concept/CreatorTraits.h" //CL
+#include "data/concept/IsQuerySelector.h" //CL
+
 
 inline QString indentation(int depth)
 {

Modified: sandbox/icl/libs/xplore/br1/sqlbrowser/Dag/TypeGraph.cpp
==============================================================================
--- sandbox/icl/libs/xplore/br1/sqlbrowser/Dag/TypeGraph.cpp (original)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/Dag/TypeGraph.cpp 2012-05-14 12:12:46 EDT (Mon, 14 May 2012)
@@ -5,77 +5,3 @@
 
 using namespace dag::db;
 
-void dag::db::getTypeGraph(TypeGraph& tygr, TypeGraphAccessor& accessor)
-{
- accessor.prepareGet();
-
- while(accessor.next())
- tygr.add(accessor.record());
-}
-
-//!
-void dag::db::getTypeGraph(TypeGraph& tygr, Persistor<TypeEdge>& persitor)
-{
- RecIterator it = persitor.prepareGet();
-
- while(it != persitor.end())
- tygr.add(Creator<Persistor<TypeEdge> >::create(it++));
-}
-
-//!
-void dag::db::getTypeGraph(TypeGraph& tygr, Persistor<TypeEdge>& persitor)
-{
- persitor.prepareGet();
-
- while(it != persitor.end())
- tygr.add(Creator<Persistor<TypeEdge> >::create(it++));
-}
-
-
-template<class Object, class Access>
-class Persistor
-{
-public:
- iterator prepareGet()
- {
- // Make a query
- return Access::makeQuery(m_resultSet);
- }
-
- iterator begin()
- {
- return m_resultSet.begin();
- }
-
- iterator end()
- {
- return m_resultSet.end();
- }
-
- Object create(iterator it)
- {
- return Access::create(it);
- }
-
-private:
- Access::ResultSet m_resultSet;
-};
-
-
-
-struct SqlAccess
-{
- template<class Object> //Iterierbarere Container
- static inline iterator makeQuery(SqlAccess::Set resultSet)
- {
- tString sql = SqlAccess<Object>::makeSql();
- // Query abschicken.
- // Results
- };
-
- template<class Object>
- static Object create(iterator it)
- {
- ;
- }
-};

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-14 12:12:46 EDT (Mon, 14 May 2012)
@@ -12,7 +12,7 @@
 
 class QSqlQuery;
 
-namespace dag namespace db {
+namespace dag { namespace db
 {
 
 
@@ -56,5 +56,5 @@
 };
 
 
-}} // dag::db
+}} // 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-14 12:12:46 EDT (Mon, 14 May 2012)
@@ -47,6 +47,7 @@
 #include <QtGui>
 #include <QtSql>
 
+
 Browser::Browser(QWidget *parent)
     : QWidget(parent)
 {

Added: sandbox/icl/libs/xplore/br1/sqlbrowser/data/concept/CreatorTraits.h
==============================================================================
--- (empty file)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/data/concept/CreatorTraits.h 2012-05-14 12:12:46 EDT (Mon, 14 May 2012)
@@ -0,0 +1,25 @@
+/****************************************************************************
+**
+**
+****************************************************************************/
+
+#pragma once
+
+
+namespace data
+{
+
+//==============================================================================
+//= Concept: data::Creator Traits
+//==============================================================================
+template<class Object, class Accessor>
+struct CreatorTraits
+{
+ typedef typename Accessor::iterator iterator;
+ typedef typename Accessor::tQuery tQuery;
+
+ static tQuery createQuery();
+ static Object create(iterator);
+};
+
+} // namespace data

Added: sandbox/icl/libs/xplore/br1/sqlbrowser/data/concept/IsQuerySelector.h
==============================================================================
--- (empty file)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/data/concept/IsQuerySelector.h 2012-05-14 12:12:46 EDT (Mon, 14 May 2012)
@@ -0,0 +1,30 @@
+/****************************************************************************
+**
+**
+****************************************************************************/
+
+#pragma once
+
+#include "data/qsql/QSqlSelector.h"
+
+namespace data
+{
+
+template<class Accessor> struct isQuerySelector;
+
+template<class Accessor>
+struct isQuerySelector
+{
+ static const bool value = false;
+};
+
+template<>
+struct isQuerySelector<QSqlSelector>
+{
+ static const bool value = true;
+};
+
+} // namespace data
+
+
+

Added: sandbox/icl/libs/xplore/br1/sqlbrowser/data/concept/Selector.h
==============================================================================
--- (empty file)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/data/concept/Selector.h 2012-05-14 12:12:46 EDT (Mon, 14 May 2012)
@@ -0,0 +1,34 @@
+/****************************************************************************
+**
+**
+****************************************************************************/
+
+#pragma once
+
+//std
+//boost
+#include <boost/utility/enable_if.hpp>
+//qt
+//local
+#include "Dag/TypeGraph.h"
+
+#include "data/concept/IsQuerySelector.h"
+//CL #include "data/qsql/QSqlSelector.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)
+{
+ typedef typename Accessor::iterator 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)
+}
+
+} // namespace data

Added: sandbox/icl/libs/xplore/br1/sqlbrowser/data/concept/SelectorTraits.h
==============================================================================
--- (empty file)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/data/concept/SelectorTraits.h 2012-05-14 12:12:46 EDT (Mon, 14 May 2012)
@@ -0,0 +1,30 @@
+/****************************************************************************
+**
+**
+****************************************************************************/
+
+#pragma once
+
+//std
+#include <cstddef>
+
+
+// Data access sql, xml, file etc. lives in namespace data
+namespace data
+{
+
+//==============================================================================
+//= Concept: DataSelector Traits
+//==============================================================================
+template<class Accessor, class Query>
+struct SelectorTraits
+{
+ typedef typename Accessor::size_type size_type;
+ typedef typename Accessor::iterator iterator;
+
+ static iterator begin(const Accessor& accessor);
+ static iterator end(const Accessor& accessor);
+ static size_type select(const Query&);
+};
+
+} // namespace data

Added: sandbox/icl/libs/xplore/br1/sqlbrowser/data/qsql/QSqlCreator.h
==============================================================================
--- (empty file)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/data/qsql/QSqlCreator.h 2012-05-14 12:12:46 EDT (Mon, 14 May 2012)
@@ -0,0 +1,49 @@
+/****************************************************************************
+**
+**
+****************************************************************************/
+
+#pragma once
+
+#include "Dag/DbType.h"
+
+namespace data
+{
+
+typedef dag::db::tString tString;
+
+//==============================================================================
+//= Concept: data::Creator Spec: QSqlCreator
+//==============================================================================
+template<class Object>
+struct CreatorTraits<Object, QSqlCreator<Object> >
+{
+ typedef QSqlCreator<Object> tCreator;
+ typedef typename tCreator::iterator iterator;
+ typedef typename tCreator::tQuery tQuery;
+
+ static tQuery createQuery();
+ static Object create(iterator);
+};
+
+template<>
+class QSqlCreator<dag::db::EdgeType>
+{
+public:
+ typedef dag::db::EdgeType tObject;
+
+ tString createQuery()const
+ {
+ return //JODO generate the query from data
+ "SELECT ...";
+ }
+
+ tObject create(iterator it)
+ {
+ return dag::db::EdgeType();
+ }
+};
+
+
+
+} // namespace data

Added: sandbox/icl/libs/xplore/br1/sqlbrowser/data/qsql/QSqlSelector.h
==============================================================================
--- (empty file)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/data/qsql/QSqlSelector.h 2012-05-14 12:12:46 EDT (Mon, 14 May 2012)
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+**
+****************************************************************************/
+
+#pragma once
+
+//std
+#include <cstddef>
+//boost
+//qt
+#include <QSqlQuery.h>
+
+//concepts
+#include "data/concept/Selector.h"
+
+
+// Data access sql, xml, file etc. lives in namespace data
+namespace data
+{
+
+class QSqlSelector
+{
+public:
+ typedef QVector<QVariant> type;
+ typedef typename tResultSet::iterator iterator;
+ typedef QVector<QVariant> tResultSet;
+ typedef QSqlQuery tQuery;
+
+ iterator begin(){ return m_aResultSet.begin(); }
+ iterator end() { return m_aResultSet.end(); }
+ size_type select(const tQuery&);
+
+private:
+ tResultSet m_aResultSet;
+};
+
+
+//==============================================================================
+//= Concept: DataSelector Spec: QSqlSelector
+//==============================================================================
+template<>
+struct SelectorTraits<QSqlSelector, class QSqlQuery>
+{
+ typedef std::size_t size_type;
+ typedef typename QSqlSelector::iterator iterator;
+
+ static iterator begin(const QSqlSelector& accessor){ return accessor.begin(); }
+ static iterator end (const QSqlSelector& accessor){ return accessor.end(); };
+ static size_type select(const QSqlQuery&);
+};
+
+} // namespace data

Modified: sandbox/icl/libs/xplore/br1/sqlbrowser/sqlbrowser4.pro
==============================================================================
--- sandbox/icl/libs/xplore/br1/sqlbrowser/sqlbrowser4.pro (original)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/sqlbrowser4.pro 2012-05-14 12:12:46 EDT (Mon, 14 May 2012)
@@ -3,8 +3,8 @@
 
 QT += sql
 
-INCLUDEPATH += /cygwin/home/jofa/dev/boost/branches/release
-#INCLUDEPATH += C:\NIBuild\3rdparty\boost-1.48.0
+#INCLUDEPATH += /cygwin/home/jofa/dev/boost/branches/release
+INCLUDEPATH += C:\NIBuild\3rdparty\boost-1.48.0
 
 HEADERS = browser.h connectionwidget.h qsqlconnectiondialog.h \
     exttableview.h \
@@ -18,11 +18,19 @@
     Dag/DbType.cpp \
     Dag/TypeGraph.h \
     Dag/Decoration.h \
- Dag/DecoratedGraph.h
+ Dag/DecoratedGraph.h \
+ data/concept/SelectorTraits.h \
+ data/concept/Selector.h \
+ data/concept/IsQuerySelector.h \
+ data/concept/CreatorTraits.h \
+ data/qsql/QSqlSelector.h \
+ data/qsql/QSqlCreator.h
 SOURCES = main.cpp browser.cpp connectionwidget.cpp qsqlconnectiondialog.cpp \
     exttableview.cpp \
     dagitem.cpp \
- dagmodel.cpp
+ dagmodel.cpp \
+ Dag/TypeGraph.cpp \
+ Dag/TypeGraph.cpp
 
 FORMS = browserwidget.ui qsqlconnectiondialog.ui
 build_all:!build_pass {


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