00001
00011 class OGraph : public OGraphic
00012 {
00013 protected:
00014 graph og;
00015 node_map<OGraphic*> nl;
00016 edge_map<AGraphic*> el;
00017
00018 public:
00019 OGraphic* clone() const;
00020 inline OGraphic* create() const;
00021 OGraph();
00022 OGraph(bool);
00023 ~OGraph();
00024
00025 inline node newNode();
00026 inline node newNode(OGraphic*);
00027 inline node nodeRead(int);
00028 inline int rangeRead(node) const;
00029
00030 inline OGraphic* objectRead(int);
00031 inline OGraphic* objectRead(node);
00032 inline int rangeRead(OGraphic*);
00033 inline void objectWrite(OGraphic*,int);
00034 inline void objectWrite(OGraphic*,node);
00035 inline void objectPush(OGraphic*,int);
00036 inline void objectPush(OGraphic*,node);
00037
00038 inline edge newEdge(int,int);
00039 inline edge newEdge(int,int,AGraphic*);
00040 inline edge newEdge(node,node);
00041 inline edge newEdge(node,node,AGraphic*);
00042 inline edge edgeRead(int);
00043 inline int rangeRead(edge) const;
00044
00045 inline AGraphic* attributeRead(int);
00046 inline AGraphic* attributeRead(edge);
00047 inline int rangeRead(AGraphic*);
00048 inline void attributeWrite(AGraphic*,int);
00049 inline void attributeWrite(AGraphic*,edge);
00050 inline void attributePush(AGraphic*,int);
00051 inline void attributePush(AGraphic*,edge);
00052
00053 inline deque<OGraphic*> readOGraphicArray();
00054 deque<OGraphic*> readOGraphicArray(string &);
00055 void readOGraphicArray(string &,deque<OGraphic*> &);
00056
00057 void writeOGraphicArray(string &,deque<OGraphic*> &);
00058 int writeOGraphicArray(string &,deque<OGraphic*> &,int);
00059
00060
00061
00062 void gomo(ostream &);
00063 void gomi(istream &);
00064 void xmlo(ostream &);
00065 void svgo(ostream &);
00066 };
00067
00071 inline OGraphic* OGraph::create() const
00072 { return new OGraph(); }
00073
00077 inline node OGraph::newNode()
00078 { node n = og.new_node(); nl[n] = new OGraphicImpl(); return n; }
00082 node OGraph::newNode(OGraphic* o)
00083 { node n = og.new_node(); nl[n] = o; return n; }
00088 inline node OGraph::nodeRead(int p)
00089 {
00090 graph::node_iterator nit = og.nodes_begin(); int c = 0;
00091 while((nit != og.nodes_end())&&(c != p))
00092 { nit++; c++;}
00093 return *nit;
00094 }
00098 inline int OGraph::rangeRead(node n) const
00099 {
00100 graph::node_iterator nit = og.nodes_begin();
00101 for(int i=0;i<og.number_of_nodes();i++)
00102 { if(*nit == n) return i; nit++; }
00103 return -1;
00104 }
00105
00110 inline OGraphic* OGraph::objectRead(int p)
00111 { node n = nodeRead(p); return nl[n]; }
00115 inline OGraphic* OGraph::objectRead(node n)
00116 { return nl[n]; }
00120 inline int OGraph::rangeRead(OGraphic* o)
00121 {
00122 for(int i=0;i<og.number_of_nodes();i++)
00123 if(objectRead(i) == o)
00124 return i;
00125 return -1;
00126 }
00131 inline void OGraph::objectWrite(OGraphic *o,int p)
00132 { node n = nodeRead(p); nl[n] = o; }
00136 inline void OGraph::objectWrite(OGraphic *o,node n)
00137 { nl[n] = o; }
00138
00143 inline void OGraph::objectPush(OGraphic *o,int p)
00144 { node n = nodeRead(p); nl[n]->~OGraphic(); nl[n] = o; }
00149 inline void OGraph::objectPush(OGraphic *o,node n)
00150 { nl[n]->~OGraphic(); nl[n] = o; }
00151
00156 inline edge OGraph::newEdge(int n1, int n2)
00157 { edge e = og.new_edge(nodeRead(n1),nodeRead(n2)); el[e] = new AGraphicImpl(); return e; }
00162 inline edge OGraph::newEdge(int n1, int n2,AGraphic* a)
00163 { edge e = og.new_edge(nodeRead(n1),nodeRead(n2)); el[e] = a; return e;}
00167 inline edge OGraph::newEdge(node n1, node n2)
00168 { edge e = og.new_edge(n1,n2); el[e] = new AGraphicImpl(); return e; }
00172 inline edge OGraph::newEdge(node n1, node n2,AGraphic* a)
00173 { edge e = og.new_edge(n1,n2); el[e] = a; return e; }
00178 inline edge OGraph::edgeRead(int p)
00179 {
00180 graph::edge_iterator eit = og.edges_begin(); int c = 0;
00181 while((eit != og.edges_end())&&(c != p))
00182 { c++; eit++; }
00183 return *eit;
00184 }
00188 inline int OGraph::rangeRead(edge e) const
00189 {
00190 graph::edge_iterator eit = og.edges_begin();
00191 for(int i=0;i<og.number_of_edges();i++)
00192 { if(*eit == e) return i; eit++; }
00193 return -1;
00194 }
00195
00200 inline AGraphic* OGraph::attributeRead(int p)
00201 { edge e = edgeRead(p); return el[e]; }
00205 inline AGraphic* OGraph::attributeRead(edge e)
00206 { return el[e]; }
00210 inline int OGraph::rangeRead(AGraphic* a)
00211 {
00212 for(int i=0;i<og.number_of_edges();i++)
00213 if(attributeRead(i) == a)
00214 return i;
00215 return -1;
00216 }
00221 void OGraph::attributeWrite(AGraphic *a, int p)
00222 { edge e = edgeRead(p); el[e] = a;}
00226 inline void OGraph::attributeWrite(AGraphic* a, edge e)
00227 { el[e] = a; }
00233 void OGraph::attributePush(AGraphic *a, int p)
00234 { edge e = edgeRead(p); el[e]->~AGraphic(); el[e] = a;}
00239 inline void OGraph::attributePush(AGraphic* a, edge e)
00240 { el[e]->~AGraphic(); el[e] = a; }
00244 inline deque<OGraphic*> OGraph::readOGraphicArray()
00245 {
00246 deque<OGraphic*> oa;
00247 graph::node_iterator nit = og.nodes_begin();
00248 while(nit != og.nodes_end())
00249 { oa.push_back(nl[*nit]); nit++; }
00250 return oa;
00251 }