ChangeTimeline.h

Go to the documentation of this file.
00001 // $Id: ChangeTimeline.h 114 2006-04-30 18:01:54Z bingmann $
00002 
00003 #ifndef VGS_ChangeTimeline_H
00004 #define VGS_ChangeTimeline_H
00005 
00006 #include <deque>
00007 #include <assert.h>
00008 
00009 #include "GraphTypes.h"
00010 #include "GraphData.h"
00011 #include "AttributeBlob_fwd.h"
00012 
00013 namespace VGServer {
00014 
00019 class ChangeFrame
00020 {
00021 public:
00023     enum changeid_t { CHG_NONE=0,
00024                       CHG_ADDVERTEX, CHG_SETVERTEX, CHG_DELVERTEX,
00025                       CHG_ADDEDGE, CHG_SETEDGE, CHG_DELEDGE };
00026 
00027 protected:
00029     struct ChangeEntry
00030     {
00032         changeid_t      chgid;
00033         
00035         unsigned int    vid1, vid2;
00036         
00038         AttributeVertexTinyBlob blob;
00039 
00041         inline ChangeEntry(changeid_t _chgid, unsigned int _vid1, unsigned int _vid2)
00042             : chgid(_chgid), vid1(_vid1), vid2(_vid2)
00043         {
00044         }
00045 
00047         inline ChangeEntry(changeid_t _chgid, unsigned int vid, const AttributeVertexTinyBlob &_blob)
00048             : chgid(_chgid), vid1(vid), blob(_blob)
00049         {
00050         }
00051 
00053         inline ChangeEntry(changeid_t _chgid, unsigned int _vid1, unsigned int _vid2, const AttributeEdgeTinyBlob &eblob)
00054             : chgid(_chgid), vid1(_vid1), vid2(_vid2), blob(eblob.data(), eblob.size())
00055         {
00056         }
00057     };
00058 
00060     typedef std::deque<ChangeEntry>     chgoplist_t;
00061 
00062     chgoplist_t chgoplist;
00063 
00065     friend class GraphContainer;
00066 
00067 public:
00069     void        addVertex(vertexid_t id, const AttributeVertexTinyBlob &b);
00070 
00072     void        setVertexAttr(vertexid_t id, const AttributeVertexTinyBlob &b);
00073 
00075     void        delVertex(vertexid_t id);
00076     
00078     void        addEdge(vertexid_t src, vertexid_t tgt, const AttributeEdgeTinyBlob &b);
00079     
00081     void        setEdgeAttr(vertexid_t src, vertexid_t tgt, const AttributeEdgeTinyBlob &b);
00082 
00084     void        delEdge(vertexid_t src, vertexid_t tgt);
00085 };
00086 
00092 class ChangeTimeline
00093 {
00094 protected:
00095     // Implementation: for a trivial timeline containing only one time slot,
00096     // clstart == clend is the only changelist, and the ChangeFrame list is
00097     // empty. Once the first time slot is added, the clend becomes a copy of
00098     // clstart, and is augmented with all further changes, while clstart
00099     // remains unchanged.
00100 
00104     class Changelist    *clstart;
00105 
00108     class Changelist    *clend;
00109 
00111     const class GraphData &graph;
00112 
00115     typedef std::deque<class ChangeFrame> changeframelist_t;
00116 
00119     changeframelist_t   frames;
00120 
00122     friend class GraphContainer;
00123 
00124 public:
00126     ChangeTimeline(const class GraphData &graph);
00127 
00128     ~ChangeTimeline();
00129 
00131     void        clear();
00132 
00134     bool        addVertex(vertexid_t id);
00135 
00137     bool        setVertexAttr(vertexid_t id, unsigned int attrid, const AnyType &value);
00138     
00140     bool        delVertex(vertexid_t id);
00141     
00143     bool        addEdge(vertexid_t src, vertexid_t tgt);
00144     
00146     bool        setEdgeAttr(vertexid_t src, vertexid_t tgt, unsigned int attrid, const AnyType &value);
00147     
00149     bool        delEdge(vertexid_t src, vertexid_t tgt);
00150 
00153     unsigned int advanceTimeFrame();
00154 
00157     inline unsigned int getFrameCount() const
00158     { return static_cast<unsigned int>(frames.size()); }
00159 
00160     // *** Functions to access the two changelists. Used by GraphConnection in
00161     // *** the right places.
00162 
00164     inline const class Changelist &getChangelistStart() const
00165     { return *clstart; }
00166 
00168     inline const class Changelist &getChangelistEnd() const
00169     { return *clend; }
00170 
00172     inline const class Changelist &getChangelist() const
00173     { assert(clstart == clend); return *clstart; }
00174 
00175 };
00176 
00177 } // namespace VGServer
00178 
00179 #endif // VGS_Changelist_H

Generated on Wed Sep 27 14:34:00 2006 for VGServer by  doxygen 1.4.7