Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r78403 - in sandbox/icl/libs/xplore/br1/sqlbrowser: . Dag
From: afojgo_at_[hidden]
Date: 2012-05-10 09:58:26


Author: jofaber
Date: 2012-05-10 09:58:24 EDT (Thu, 10 May 2012)
New Revision: 78403
URL: http://svn.boost.org/trac/boost/changeset/78403

Log:
Coding type graph.
Text files modified:
   sandbox/icl/libs/xplore/br1/sqlbrowser/Dag.h | 45 +++++++++++++++++++++++++--------------
   sandbox/icl/libs/xplore/br1/sqlbrowser/Dag/DbType.h | 38 ++++++++++++++++++++++++++++++++-
   sandbox/icl/libs/xplore/br1/sqlbrowser/dagmodel.cpp | 8 +++---
   sandbox/icl/libs/xplore/br1/sqlbrowser/sqlbrowser4.pro | 4 +-
   4 files changed, 71 insertions(+), 24 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-10 09:58:24 EDT (Thu, 10 May 2012)
@@ -33,17 +33,31 @@
 class VertexAttributes
 {
 public:
- VertexAttributes(): m_nodeId(), m_name(), m_depth() {}
- VertexAttributes(const QString& name, int id): m_nodeId(id), m_name(name), m_depth(), p_dagItem() {}
+ typedef dag::db::tKey tKey;
+ typedef dag::db::tObject tObject;
+ typedef dag::db::tObjectSharedPtr tObjectSharedPtr;
 
- void setName(const QString& name) { m_name = name; }
- QString name()const { return m_name; }
+public:
+ VertexAttributes(): m_aKey(), m_depth() {}
+
+ VertexAttributes(tKey key, const tObjectSharedPtr& pObject) //JODO REMOVE
+ : m_aKey(key), m_pObject(pObject), m_depth(), p_dagItem() {}
+
+ VertexAttributes(tKey key, const QString& aName)
+ : m_aKey(key), m_pObject(boost::make_shared<tObject>())
+ , m_depth(), p_dagItem()
+ {
+ m_pObject->setName(aName);
+ }
+
+ void setName(const QString& name) { m_pObject->setName(name); }
+ QString name()const { return m_pObject->name(); }
 
     void setDepth(int depth){ m_depth = depth; }
     int depth()const { return m_depth; }
 
- void setNodeId(int nodeId) { m_nodeId = nodeId; }
- int nodeId()const { return m_nodeId; }
+ void setKey(tKey aKey) { m_aKey = aKey; }
+ tKey key()const { return m_aKey; }
 
     void setDagItem(DagItem* dagItem) { p_dagItem = dagItem; }
     DagItem* dagItem()const { return p_dagItem; }
@@ -54,9 +68,8 @@
     int inc(){ return ++m_depth; }
 
 private:
- int m_nodeId;
- QString m_name;
- int m_depth;
+ tKey m_aKey;
+ int m_depth;
 
     //---- Db::Object associated to the Vertex ---------------------------------
     dag::db::tObjectSharedPtr m_pObject;
@@ -69,16 +82,16 @@
 class EdgeAttributes
 {
 public:
- EdgeAttributes(): m_nodeId() {}
- EdgeAttributes(const QString& name, int id): m_nodeId(id) {}
+ typedef dag::db::tKey tKey;
+public:
+ EdgeAttributes(): m_aKey() {}
+ EdgeAttributes(tKey aKey): m_aKey(aKey) {}
 
 private:
- int m_nodeId;
+ tKey m_aKey;
 
- //---- Db::Object associated to the Edge ---------------------------------
+ //---- Db::Object associated to the Edge -----------------------------------
     dag::db::tObjectSharedPtr m_pObject;
-
- //---- DagModel ------------------------------------------------------------
 };
 
 //JODO: m_depth/depth() may be removed. It's currently only needed for debugging.
@@ -109,7 +122,7 @@
 
     inline void copyBoostNode2DagItem(const VertexAttributes& src, tVariVector& target)//JODO cpp
     {
- target[dag::node::posId] = QVariant(src.nodeId());
+ target[dag::node::posId] = QVariant(src.key());
         target[dag::node::posName] = QVariant(src.name());
     }
 }//namespace dag

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-10 09:58:24 EDT (Thu, 10 May 2012)
@@ -9,6 +9,8 @@
 #include <bitset>
 //boost
 #include <boost/scoped_ptr.hpp>
+#include <boost/shared_ptr.hpp>
+#include <boost/make_shared.hpp>
 //qt
 #include <QtCore/QVariant>
 #include <QtCore/QVector>
@@ -88,8 +90,8 @@
 };
 
 
-//Don't optimize premature: Clearness first!!
-//I have to prepare and build the TypeGraph first.
+//CL Don't optimize premature: Clearness first!!
+//CL I have to prepare and build the TypeGraph first.
 //
 
 class ObjectType
@@ -120,6 +122,7 @@
 };
 
 
+
 //==============================================================================
 //= dag::db::Objects
 //==============================================================================
@@ -136,9 +139,13 @@
 
     bool isConsistent()const; //!< Checks for consistency between types and data
 
+ void setName(const QString& aName) { m_aName = aName; }
+ QString name()const { return m_aName; }
+
 private:
     Type m_aType;
     tVariVector m_aValue;
+ QString m_aName; //JODO for ease of testing only. Remove soon.
 };
 
 typedef Object<ObjectType> tObject;
@@ -152,4 +159,31 @@
 }} //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
 

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-10 09:58:24 EDT (Thu, 10 May 2012)
@@ -140,8 +140,8 @@
     if(!(source==0 && target==0))
     {
         boost::add_edge(source, target, m_dag);
- m_aVertexAttributes[source] = VertexAttributes(edgeData[m_parentName].toString(), source);
- m_aVertexAttributes[target] = VertexAttributes(edgeData[m_childName].toString(), target);
+ m_aVertexAttributes[source] = VertexAttributes(source, edgeData[m_parentName].toString());
+ m_aVertexAttributes[target] = VertexAttributes(target, edgeData[m_childName].toString());
     }
 }
 
@@ -376,8 +376,8 @@
         if(!(source==0 && target==0))
         {
             boost::add_edge(source, target, m_dag);
- m_aVertexAttributes[source] = VertexAttributes((*iter)[m_parentName].toString(), source);
- m_aVertexAttributes[target] = VertexAttributes((*iter)[m_childName].toString(), target);
+ m_aVertexAttributes[source] = VertexAttributes(source, (*iter)[m_parentName].toString());
+ m_aVertexAttributes[target] = VertexAttributes(target, (*iter)[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-10 09:58:24 EDT (Thu, 10 May 2012)
@@ -3,8 +3,8 @@
 
 QT += sql
 
-INCLUDEPATH += /cygwin/home/jofa/dev/boost/branches/release
-#INCLUDEPATH += /cygwin/home/jofa/dev/boost/trunk
+#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 \


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