GraphData.h

Go to the documentation of this file.
00001 // $Id: GraphData.h 241 2006-07-05 07:29:52Z bingmann $
00002 
00003 #ifndef VGS_GraphData_H
00004 #define VGS_GraphData_H
00005 
00006 #include <vector>
00007 #include <ostream>
00008 
00009 #include "GraphTypes.h"
00010 #include "GraphProperties.h"
00011 #include "AttributeBlob.h"
00012 #include "TpArray.h"
00013 
00014 namespace VGServer {
00015 
00022 class GraphData
00023 {
00024 public:
00025 
00027     struct Vertex
00028     {
00030         unsigned int    edgeidx;
00031 
00034         unsigned int    attridx;
00035 
00038         inline class AnyType getAttr(unsigned int attrid, const GraphData &gd) const
00039         { return gd.vertexattr.getAttrChainValue(attridx, attrid, gd.properties.vertexattr); }
00040     };
00041 
00043     struct Edge
00044     {
00047         vertexid_t      target;
00048 
00051         unsigned int    attridx;
00052 
00055         inline class AnyType getAttr(unsigned int attrid, const GraphData &gd) const
00056         { return gd.edgeattr.getAttrChainValue(attridx, attrid, gd.properties.edgeattr); }
00057     };
00058 
00059 public://private:
00061     class GraphProperties       properties;
00062 
00064     TpArray<Vertex>     vertices;
00065 
00067     TpArray<Edge>       edges;
00068 
00071     AttributeBigBlob    vertexattr;
00072 
00074     AttributeBigBlob    edgeattr;
00075 
00079     unsigned int        vertexcount;
00080 
00082     friend class GraphContainer;
00083     
00085     friend class GraphLoader;
00086 
00088     friend class Changelist;
00089 
00091     friend class VertexRef;
00092 
00094     friend class EdgeRef;
00095 
00096 public:
00097     // *** Functions are all public to the application, but GraphContainer
00098     // *** provides an additional layer with the Changelist.
00099 
00100     explicit GraphData(const class GraphProperties &properties);
00101 
00103     void        swap(class GraphData &other);
00104 
00109     void        applyChangelist(const class Changelist &cl);
00110 
00112     inline const GraphProperties& getProperties() const
00113     { return properties; }
00114 
00115     // *** Vertex Array Functions
00116 
00118     const Vertex* getVertex(vertexid_t id) const;
00119 
00121     bool        existVertex(vertexid_t id) const;
00122 
00124     class AnyType getVertexAttr(vertexid_t id, unsigned int attr) const;
00125 
00127     AttributeVertexTinyBlob getVertexAttrBlob(vertexid_t id) const;
00128 
00130     unsigned int getVertexCount() const
00131     { return vertexcount; }
00132 
00133     // *** Edge Array Functions
00134 
00136     const Edge* getEdge(vertexid_t src, vertexid_t tgt) const;
00137 
00139     unsigned int getEdgeIdx(vertexid_t src, vertexid_t tgt) const;
00140 
00142     bool        existEdge(vertexid_t src, vertexid_t tgt) const;
00143 
00145     class AnyType getEdgeAttr(vertexid_t src, vertexid_t tgt, unsigned int attr) const;
00146 
00148     AttributeEdgeTinyBlob getEdgeAttrBlob(vertexid_t src, vertexid_t tgt) const;
00149 
00151     std::vector<const Edge*> getEdgeList(vertexid_t id) const;
00152 
00154     std::vector<unsigned int> getEdgeIdxList(vertexid_t id) const;
00155 
00157     std::vector<unsigned int> getEdgeTargetList(vertexid_t srcid) const;
00158 
00160     unsigned int getEdgeCount() const
00161     { return edges.size()-1; }
00162 
00164     unsigned int getVertexAttrBytes() const
00165     { return vertices.last().attridx; }
00166 
00168     unsigned int getEdgeAttrBytes() const
00169     { return edges.last().attridx; }
00170 
00171 public:
00172     // *** Debugging Functions
00173 
00176     void        saveSnapshot(std::ostream &s) const;
00177 
00179     bool        loadSnapshot(std::istream &s);
00180 
00182     void        writeFig(bool writefigheader, std::ostream &s, unsigned int attrX, unsigned int attrY) const;
00183 
00185     bool        checkReferences() const;
00186 };
00187 
00188 } // namespace VGServer
00189 
00190 #endif // VGS_GraphData_H

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