Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r78420 - in sandbox/icl/libs/xplore/br1/sqlbrowser: . Dag
From: afojgo_at_[hidden]
Date: 2012-05-11 10:53:52


Author: jofaber
Date: 2012-05-11 10:53:50 EDT (Fri, 11 May 2012)
New Revision: 78420
URL: http://svn.boost.org/trac/boost/changeset/78420

Log:
Coding type graph.
Added:
   sandbox/icl/libs/xplore/br1/sqlbrowser/Dag/DecoratedGraph.h (contents, props changed)
   sandbox/icl/libs/xplore/br1/sqlbrowser/Dag/Decoration.h (contents, props changed)
   sandbox/icl/libs/xplore/br1/sqlbrowser/Dag/TypeGraph.h (contents, props changed)
Text files modified:
   sandbox/icl/libs/xplore/br1/sqlbrowser/Dag.h | 3 +++
   sandbox/icl/libs/xplore/br1/sqlbrowser/Dag/DbType.h | 28 ----------------------------
   sandbox/icl/libs/xplore/br1/sqlbrowser/dagmodel.cpp | 2 ++
   sandbox/icl/libs/xplore/br1/sqlbrowser/sqlbrowser4.pro | 5 ++++-
   4 files changed, 9 insertions(+), 29 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-11 10:53:50 EDT (Fri, 11 May 2012)
@@ -12,6 +12,9 @@
 
 #include "dagitem.h"
 #include "Dag/DbType.h"
+#include "Dag/Decoration.h" //CL
+#include "Dag/DecoratedGraph.h" //CL
+#include "Dag/TypeGraph.h" //CL
 
 inline QString indentation(int depth)
 {

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-11 10:53:50 EDT (Fri, 11 May 2012)
@@ -159,31 +159,3 @@
 }} //namespace dag { namespace db
 
 
-namespace typedag {
-
-//! Except for sythesized attributes, I could design like this:
-//! vertex(k)->T, T is the associated object. Do we need to store
-//! dynamically sythesized attributes? vertex(k)-><T,S>.
-
-template<class Object, class Synth>
-class VertexDeco
-{
-public:
- typedef boost::shared_ptr<Object> tObjectSharedPtr;
- typedef tObject* tObjectRawPtr;
- typedef const tObject* tObjectConstRawPtr;
-
- typedef boost::shared_ptr<Synth> tSynthSharedPtr;
- typedef tSynth* tSynthRawPtr;
- typedef const tSynth* tSynthConstRawPtr;
-
-public:
-
-private:
- tObjectSharedPtr m_pObject;
- tSynthSharedPtr m_pSynth;
-
-};
-
-} // typedag
-

Added: sandbox/icl/libs/xplore/br1/sqlbrowser/Dag/DecoratedGraph.h
==============================================================================
--- (empty file)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/Dag/DecoratedGraph.h 2012-05-11 10:53:50 EDT (Fri, 11 May 2012)
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+**
+****************************************************************************/
+
+#pragma once
+
+//boost
+#include <boost/graph/graph_traits.hpp>
+#include <boost/graph/adjacency_list.hpp>
+
+
+namespace dag
+{
+
+//! Template DecoratedGraph provides all types for a graph that is decorated
+//! with vertex and edge objects.
+template<class VertexDeco, class EdgeDeco, class Directed = boost::directedS>
+struct DecoratedGraph
+{
+ // The kind of vertex_attr_tag is a vertex_property_tag
+ struct vertex_attr_tag { typedef boost::vertex_property_tag kind; };
+
+ // The kind of edge_attr_tag is a edge_property_tag
+ struct edge_attr_tag { typedef boost::edge_property_tag kind; };
+
+ // Here we associate a real type for content 'VertexAttributes' to the tag type
+ // vertex_attr_tag -> VertexAttributes
+ typedef boost::property<vertex_attr_tag, VertexDeco> tVertexAttrTag;
+ typedef boost::property<edge_attr_tag, EdgeDeco> tEdgeAttrTag;
+
+ typedef boost::adjacency_list
+ < boost::vecS
+ , boost::vecS
+ , Directed
+ , tVertexAttrTag
+ , tEdgeAttrTag
+ > tGraph;
+
+ typedef typename tGraph type;
+ typedef typename tGraph::vertex_descriptor vertex_descriptor;
+ typedef typename tGraph::edge_descriptor edge_descriptor;
+
+ typedef typename boost::property_map<type, vertex_attr_tag>::type tVertexDecoMap;
+ typedef typename boost::property_map<type, edge_attr_tag>::type tEdgeDecoMap;
+
+};
+
+
+} // dag
+

Added: sandbox/icl/libs/xplore/br1/sqlbrowser/Dag/Decoration.h
==============================================================================
--- (empty file)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/Dag/Decoration.h 2012-05-11 10:53:50 EDT (Fri, 11 May 2012)
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+**
+****************************************************************************/
+
+#pragma once
+
+//boost
+#include <boost/shared_ptr.hpp>
+#include <boost/make_shared.hpp>
+
+
+namespace dag
+{
+
+//JODO Decoration is only a transient pair. Consider std::pair<shared_ptr<T>, shared_ptr<S> >
+
+//! Decoration is an object that holds information associated to dag objects
+//! which can be vertexes or edges. Decoration is not much more than a tuple.
+//! We distinguish between
+//! \item Object, that holds content associted to vertexes or edges and
+//! \item Synth, that holds sythesized attributes that can be computed on
+//! graph traversal.
+//!
+//! Sythesized attributes like e.g. traversal depth are independent of content.
+template<class Object, class Synth>
+class Decoration
+{
+public:
+ typedef boost::shared_ptr<Object> tObjectSharedPtr;
+ typedef Object* tObjectRawPtr;
+ typedef const Object* tObjectConstRawPtr;
+
+ typedef boost::shared_ptr<Synth> tSynthSharedPtr;
+ typedef Synth* tSynthRawPtr;
+ typedef const Synth* tSynthConstRawPtr;
+
+public:
+ Decoration(): m_pObject(), m_pSynth(){}
+ Decoration(const Object& object, const Synth& synth);
+
+ tObjectSharedPtr object(){ return m_pObject; }
+ tSynthSharedPtr synth() { return m_pSynth; }
+
+private:
+ tObjectSharedPtr m_pObject;
+ tSynthSharedPtr m_pSynth;
+
+};
+
+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)
+{}
+
+} // dag
+

Added: sandbox/icl/libs/xplore/br1/sqlbrowser/Dag/TypeGraph.h
==============================================================================
--- (empty file)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/Dag/TypeGraph.h 2012-05-11 10:53:50 EDT (Fri, 11 May 2012)
@@ -0,0 +1,36 @@
+/****************************************************************************
+**
+**
+****************************************************************************/
+
+#pragma once
+
+#include "Dag/Decoration.h"
+#include "Dag/DecoratedGraph.h"
+
+#include "Dag/DbType.h"
+
+namespace dag
+{
+
+
+class TypeGraph
+{
+public:
+ typedef boost::shared_ptr<db::ObjectType> tTypeVertexDeco;
+ typedef boost::shared_ptr<db::EdgeType> tTypeEdgeDeco;
+
+ //! The TypeGraph is a DecoratedGraph
+ typedef DecoratedGraph<tTypeVertexDeco, tTypeEdgeDeco> tTypeGraph;
+
+private:
+ //==========================================================================
+ //= boost::graph
+ tTypeGraph::type m_aGraph;
+ tTypeGraph::tVertexDecoMap m_aVertexDecoMap;
+ tTypeGraph::tEdgeDecoMap m_aEdgeDecoMap;
+
+};
+
+} // dag
+

Modified: sandbox/icl/libs/xplore/br1/sqlbrowser/dagmodel.cpp
==============================================================================
--- sandbox/icl/libs/xplore/br1/sqlbrowser/dagmodel.cpp (original)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/dagmodel.cpp 2012-05-11 10:53:50 EDT (Fri, 11 May 2012)
@@ -139,7 +139,9 @@
     int target = edgeData[m_childId].toInt();
     if(!(source==0 && target==0))
     {
+ //JOFA MEMO: Build the graph: Add edges.
         boost::add_edge(source, target, m_dag);
+ //JOFA MEMO: Fill the associated objects. Aka. decorate the graph.
         m_aVertexAttributes[source] = VertexAttributes(source, edgeData[m_parentName].toString());
         m_aVertexAttributes[target] = VertexAttributes(target, edgeData[m_childName].toString());
     }

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-11 10:53:50 EDT (Fri, 11 May 2012)
@@ -15,7 +15,10 @@
     Dag.h \
     CreatorVisitor.h \
     Dag/DbType.h \
- Dag/DbType.cpp
+ Dag/DbType.cpp \
+ Dag/TypeGraph.h \
+ Dag/Decoration.h \
+ Dag/DecoratedGraph.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