Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r78846 - in sandbox/icl/libs/xplore/br1/sqlbrowser: . Dag data/concept data/qsql
From: afojgo_at_[hidden]
Date: 2012-06-07 10:02:17


Author: jofaber
Date: 2012-06-07 10:02:15 EDT (Thu, 07 Jun 2012)
New Revision: 78846
URL: http://svn.boost.org/trac/boost/changeset/78846

Log:
Extending concepts for the type graph.
Added:
   sandbox/icl/libs/xplore/br1/sqlbrowser/data/concept/Creator.h (contents, props changed)
   sandbox/icl/libs/xplore/br1/sqlbrowser/data/concept/TypeGraphMaker.h (contents, props changed)
Text files modified:
   sandbox/icl/libs/xplore/br1/sqlbrowser/Dag/DbType.h | 35 ++++++++++++++++-----------
   sandbox/icl/libs/xplore/br1/sqlbrowser/Dag/Decoration.h | 4 +-
   sandbox/icl/libs/xplore/br1/sqlbrowser/Dag/TypeGraph.h | 5 ++++
   sandbox/icl/libs/xplore/br1/sqlbrowser/ExtensibleObjectModel.sql | 7 +++++
   sandbox/icl/libs/xplore/br1/sqlbrowser/TypeExtensibleDag.sql | 15 ++++++++---
   sandbox/icl/libs/xplore/br1/sqlbrowser/browser.cpp | 2
   sandbox/icl/libs/xplore/br1/sqlbrowser/data/concept/Selector.h | 50 ++++++++++++++++------------------------
   sandbox/icl/libs/xplore/br1/sqlbrowser/data/concept/SelectorTraits.h | 2
   sandbox/icl/libs/xplore/br1/sqlbrowser/data/qsql/QSqlCreator.h | 8 ++++-
   sandbox/icl/libs/xplore/br1/sqlbrowser/data/qsql/QSqlSelector.h | 3 -
   sandbox/icl/libs/xplore/br1/sqlbrowser/sqlbrowser4.pro | 4 ++
   11 files changed, 78 insertions(+), 57 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-06-07 10:02:15 EDT (Thu, 07 Jun 2012)
@@ -69,14 +69,14 @@
 class TypedField
 {
 public:
- TypedField(): m_uType(0), m_uField(0){}
- TypedField(tKey type, tKey field): m_uType(type), m_uField(field){}
+ TypedField(): m_iType(0), m_iField(0){}
+ TypedField(tKey type, tKey field): m_iType(type), m_iField(field){}
 
- tKey type()const { return m_uType; }
- tKey field()const{ return m_uField; }
+ tKey type()const { return m_iType; }
+ tKey field()const{ return m_iField; }
 private:
- tKey m_uType;
- tKey m_uField;
+ tKey m_iType;
+ tKey m_iField;
 };
 
 typedef QVector<TypedField> tFieldSignature;
@@ -98,7 +98,7 @@
 {
 public:
 private:
- tKey m_uKey;
+ tKey m_iKey;
     tTypeTraits m_aTraits;
     tString m_aName;
     TypeSignature m_aTypeSeq;
@@ -113,18 +113,25 @@
 class EdgeType
 {
 public:
- EdgeType(tKey uKey, const tString& aName)
- : m_uKey(uKey), m_aName(aName) {}
+ EdgeType(tKey iKey, tKey iSrc, tKey iRel, tKey iTrg, const tString& aName)
+ : m_iKey(iKey)
+ , m_iRefSourceType(iSrc)
+ , m_iRefRelationType(iRel)
+ , m_iRefTargetType(iTrg)
+ , m_aName(aName) {}
 
     QString toString()const
- { return QString("Edge: Key=%1, Name=%2").arg(m_uKey).arg(m_aName); }
+ { return QString("Edge: Key=%1, Name=%2").arg(m_iKey).arg(m_aName); }
+
+ tKey sourceType()const { return m_iRefSourceType; }
+ tKey targetType()const { return m_iRefSourceType; }
 
 private:
- tKey m_uKey;
+ tKey m_iKey;
+ tKey m_iRefSourceType;
+ tKey m_iRefRelationType;
+ tKey m_iRefTargetType;
     tString m_aName;
- tObjectTypeSharedPtr m_pSourceType;
- tObjectTypeSharedPtr m_pRelationType;
- tObjectTypeSharedPtr m_pTargetType;
 };
 
 

Modified: sandbox/icl/libs/xplore/br1/sqlbrowser/Dag/Decoration.h
==============================================================================
--- sandbox/icl/libs/xplore/br1/sqlbrowser/Dag/Decoration.h (original)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/Dag/Decoration.h 2012-06-07 10:02:15 EDT (Thu, 07 Jun 2012)
@@ -50,8 +50,8 @@
 
 template<class Object, class Synth>
 Decoration<Object,Synth>::Decoration(const Object& object, const Synth& synth)
- : boost::make_shared<Object>(object)
- , boost::make_shared<Synth>(synth)
+ : m_pObject(boost::make_shared<Object>(object))
+ , m_pSynth(boost::make_shared<Synth>(synth))
 {}
 
 } // dag

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-06-07 10:02:15 EDT (Thu, 07 Jun 2012)
@@ -25,6 +25,11 @@
     //! The TypeGraph is a DecoratedGraph
     typedef DecoratedGraph<tTypeVertexDeco, tTypeEdgeDeco> tTypeGraph;
 
+ void add(const dag::db::EdgeType& aEdge)
+ {
+ boost::add_edge(aEdge.sourceType(), aEdge.targetType(), m_aGraph);
+ }
+
 private:
     //==========================================================================
     //= boost::graph

Modified: sandbox/icl/libs/xplore/br1/sqlbrowser/ExtensibleObjectModel.sql
==============================================================================
--- sandbox/icl/libs/xplore/br1/sqlbrowser/ExtensibleObjectModel.sql (original)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/ExtensibleObjectModel.sql 2012-06-07 10:02:15 EDT (Thu, 07 Jun 2012)
@@ -65,4 +65,11 @@
   inner join Types on Objects.TypeOf = Types.id
 
 -- ----------------------------------------------------------------------------
+-- UTILITIES
 -- ----------------------------------------------------------------------------
+--select * from sqlite_master
+pragma index_list(VarCharObject)
+--pragma index_info(sqlite_autoindex_VarCharObject_1)
+
+--create index Idx_VarCharObject_value on VarCharObject(value)
+

Modified: sandbox/icl/libs/xplore/br1/sqlbrowser/TypeExtensibleDag.sql
==============================================================================
--- sandbox/icl/libs/xplore/br1/sqlbrowser/TypeExtensibleDag.sql (original)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/TypeExtensibleDag.sql 2012-06-07 10:02:15 EDT (Thu, 07 Jun 2012)
@@ -495,15 +495,13 @@
 --NOT HELPFUL:
 --create index IdxVarChar_Obj_Att_Value on VarCharObject (refObject, refAttribute, value)
 
-
-
 -- -----------------------------------------------------------------------------
 -- -----------------------------------------------------------------------------
 -- View Track
 -- create view Track as
 select
   ConstTrackType.Name as TrackType, Vertex.key as TrackId, TrackName.value as Name
-, Duration.value as Dur, Genre.value as Genre, BPM.value as BPM, Label.value as Label, Comment.value as Comment
+, Duration.value as Dur, Genre.refAttribute as Att3, Genre.value as Genre, BPM.value as BPM, Label.value as Label, Comment.value as Comment
 , Playcount.value as Plyd, Rating.value as Rtd
 , ConstAlbumType.Name as AlbType, MotherAlbum.refSourceVertex as AlbId, AlbumName.value as Album, AlbumYear.value as AlbYr
 , ConstTitleType.Name as TitType, MotherTitle.refSourceVertex as TitId, TitleName.value as Title, TitleYear.value as TitYr
@@ -544,8 +542,17 @@
                                                    and ComposerYoBirth.refAttribute = 31
   -- ObjectType(Artist)
   left outer join ObjectType as ConstArtistType on 21 = ConstArtistType.key
-
 
+ -- TRIALS on general INDEXING
+ order by Genre.refAttribute, Genre.value
+
+-- -----------------------------------------------------------------------------
+-- drop index IdxVarCharValue
+select * from sqlite_master
+create index Idx_Attr_Obj_val on VarCharObject (refAttribute, refObject, value)
+-- -----------------------------------------------------------------------------
+
+
 -- -----------------------------------------------------------------------------
 -- View Track
 -- create view Track as

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-06-07 10:02:15 EDT (Thu, 07 Jun 2012)
@@ -49,7 +49,7 @@
 
 //---- First Accessor tests ----------------
 #include "data/qsql/QSqlSelector.h"
-#include "data/concept/Selector.h"
+#include "data/concept/TypeGraphMaker.h"
 
 #include "gen/NumberGenerator.h"
 #include "gen/NameGenerator.h"

Added: sandbox/icl/libs/xplore/br1/sqlbrowser/data/concept/Creator.h
==============================================================================
--- (empty file)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/data/concept/Creator.h 2012-06-07 10:02:15 EDT (Thu, 07 Jun 2012)
@@ -0,0 +1,36 @@
+/****************************************************************************
+**
+**
+****************************************************************************/
+
+#pragma once
+
+#include <boost/mpl/bool.hpp>
+#include <boost/utility/enable_if.hpp>
+
+#include "data/concept/IsQuerySelector.h"
+
+namespace data
+{
+
+//==============================================================================
+//= concept Creator
+//==============================================================================
+template<class Accessor, class DomainObject>
+typename boost::enable_if< IsQuerySelector<Accessor>, DomainObject>::type
+create(typename Accessor::const_iterator it)
+{
+ typedef typename GetCreator<DomainObject,Accessor>::type tCreator;
+ return CreatorTraits<DomainObject,tCreator>::create(it);
+}
+
+template<class Accessor, class DomainObject>
+typename boost::enable_if< IsQuerySelector<Accessor>, tString>::type
+createQuery()
+{
+ typedef typename GetCreator<DomainObject,Accessor>::type tCreator;
+ return CreatorTraits<DomainObject,tCreator>::createQuery();
+}
+
+
+} // 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-06-07 10:02:15 EDT (Thu, 07 Jun 2012)
@@ -13,46 +13,36 @@
 //local
 #include "Dag/TypeGraph.h"
 
+#include "data/concept/Creator.h"
 #include "data/concept/IsQuerySelector.h"
 #include "data/qsql/QSqlCreator.h"
 
 namespace data
 {
 
-//! Given the Accessor is a QuerySelector, it allows to retirieve resultsets
-//! from some Query objects, the function to make a typeGraph is generic for
-//! all those Accessors
+//==============================================================================
+//= concept Selector
+//==============================================================================
 template<class Accessor>
-typename boost::enable_if< IsQuerySelector<Accessor>, bool>::type
-makeTypeGraph(Accessor& accessor, dag::db::TypeGraph& typeGraph)
+typename boost::enable_if< IsQuerySelector<Accessor>, typename Accessor::size_type>::type
+select(Accessor& accessor, const typename Accessor::tQuery& query)
 {
- typedef typename GetCreator<dag::db::EdgeType,Accessor>::type tCreator;
- typedef typename Accessor::const_iterator const_iterator;
- typedef typename CreatorTraits<dag::db::EdgeType,tCreator> tCreatorInstance;
-
- SelectorTraits<Accessor>::
- select(accessor,
- CreatorTraits<dag::db::EdgeType,tCreator>::createQuery());
-
- QString check;
- for(const_iterator it = accessor.begin(); it != accessor.end(); ++it)
- {
- //check += it->field(4).value().toString();
- dag::db::EdgeType aEdge
- = CreatorTraits<dag::db::EdgeType,tCreator>::create(it);
- check += aEdge.toString();
- check += "\n";
- }
-
-
- QMessageBox msgBox;
- QString msg = "Edges:\n";
- msg += check;
- msgBox.setText(msg);
- msgBox.exec();
+ return SelectorTraits<Accessor>::select(accessor, query);
+}
 
+template<class Accessor>
+typename boost::enable_if< IsQuerySelector<Accessor>, typename Accessor::const_iterator>::type
+begin(const Accessor& accessor)
+{
+ return SelectorTraits<Accessor>::begin(accessor);
+}
 
- return true;
+template<class Accessor>
+typename boost::enable_if< IsQuerySelector<Accessor>, typename Accessor::const_iterator>::type
+end(const Accessor& accessor)
+{
+ return SelectorTraits<Accessor>::end(accessor);
 }
 
+
 } // namespace data

Modified: sandbox/icl/libs/xplore/br1/sqlbrowser/data/concept/SelectorTraits.h
==============================================================================
--- sandbox/icl/libs/xplore/br1/sqlbrowser/data/concept/SelectorTraits.h (original)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/data/concept/SelectorTraits.h 2012-06-07 10:02:15 EDT (Thu, 07 Jun 2012)
@@ -25,7 +25,7 @@
 
     static const_iterator begin(const Accessor& accessor);
     static const_iterator end(const Accessor& accessor);
- static size_type select(const tQuery&);
+ static size_type select(Accessor& accessor, const tQuery&);
 };
 
 } // namespace data

Added: sandbox/icl/libs/xplore/br1/sqlbrowser/data/concept/TypeGraphMaker.h
==============================================================================
--- (empty file)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/data/concept/TypeGraphMaker.h 2012-06-07 10:02:15 EDT (Thu, 07 Jun 2012)
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+**
+****************************************************************************/
+
+#pragma once
+
+//std
+//boost
+#include <boost/mpl/bool.hpp>
+#include <boost/utility/enable_if.hpp>
+//qt
+//local
+#include "Dag/TypeGraph.h"
+
+#include "data/concept/Selector.h"
+
+namespace data
+{
+
+//! Given the Accessor is a QuerySelector, it allows to retirieve resultsets
+//! from some Query objects, the function to make a typeGraph is generic for
+//! all those Accessors
+template<class Accessor>
+typename boost::enable_if< IsQuerySelector<Accessor>, bool>::type
+makeTypeGraph(Accessor& accessor, dag::db::TypeGraph& typeGraph)
+{
+ typedef typename Accessor::const_iterator const_iterator;
+ select(accessor, createQuery<Accessor,dag::db::EdgeType>());
+
+ QString check;
+ for(const_iterator it = begin(accessor); it != end(accessor); ++it)
+ {
+ dag::db::EdgeType aEdge = create<Accessor,dag::db::EdgeType>(it);
+ //boost::add_edge(aEdge.sourceType(), aEdge.targetType(), typeGraph);
+ typeGraph.add(aEdge);
+
+ check += aEdge.toString();
+ check += "\n";
+ }
+
+
+ QMessageBox msgBox;
+ QString msg = "Edges:\n";
+ msg += check;
+ 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-06-07 10:02:15 EDT (Thu, 07 Jun 2012)
@@ -42,8 +42,12 @@
 
     static tObject create(const_iterator it)
     {
- return dag::db::EdgeType(it->field(eKey).value().toInt(),
- it->field(eName).value().toString());
+ return dag::db::EdgeType( (*it).field(eKey).value().toInt()
+ ,(*it).field(eRefSourceType).value().toInt()
+ ,(*it).field(eRefRelationType).value().toInt()
+ ,(*it).field(eRefTargetType).value().toInt()
+ ,(*it).field(eName).value().toString()
+ );
     }
 };
 

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-06-07 10:02:15 EDT (Thu, 07 Jun 2012)
@@ -65,8 +65,7 @@
 
     static const_iterator begin(const QSqlSelector& accessor){ return accessor.begin(); }
     static const_iterator end (const QSqlSelector& accessor){ return accessor.end(); }
- static size_type select(QSqlSelector& accessor, const tString& query)
- { return accessor.select(query); }
+ static size_type select(QSqlSelector& accessor, const tString& query){ return accessor.select(query); }
 };
 
 } // 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-06-07 10:02:15 EDT (Thu, 07 Jun 2012)
@@ -28,7 +28,9 @@
     data/concept/GetCreator.h \
     gen/NameGenerator.h \
     gen/NumberGenerator.h \
- gen/DbGenerator.h
+ gen/DbGenerator.h \
+ data/concept/Creator.h \
+ data/concept/TypeGraphMaker.h
 SOURCES = main.cpp browser.cpp connectionwidget.cpp qsqlconnectiondialog.cpp \
     exttableview.cpp \
     dagitem.cpp \


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