The GOMLib allows various modelling of knowledge. So, in order to exhange this knowledge between algorithms, the container objects allow request functionalities on graphical knowledge.
void ohlRequest1() { OHL *my1,*my2; my1 = new OHL(); my1->newObject(new OPoint(1,1)); my1->newObject(new OPoint(2,2)); my1->newObject(new OPoint(3,3)); my2 = new OHL(); my2->newObject(new OPoint(4,4)); my2->newObject(new OPoint(5,5)); my2->newObject(new OPoint(6,6)); my2->newObject(new OHL()); my1->newObject(my2); deque<OGraphic*> ha = my1->readOGraphicArray((string)"OPoint"); //here we search only the OPoint object for(int i=0;i<ha.size();i++) ha[i]->print(); ha.clear(); ha = my1->readOGraphicArray((string)"OHL"); //here we search only the OHL object for(int j=0;j<ha.size();j++) cout << ha[j]->getName() << endl ; ha.clear(); my1->~OHL(); } //de
void ohlRequest2() { OHL *my1,*my2; my1 = new OHL(); my1->newObject(new OPoint(1,1)); my1->newObject(new ODPoint(2,2)); my1->newObject(new OPoint(3,3)); my2 = new OHL(); my2->newObject(new ODPoint(4,4)); my2->newObject(new OPoint(5,5)); my2->newObject(new OPoint(6,6)); my1->newObject(my2); my1->print(); cout << endl; //here we search only the OPoint object deque<OGraphic*> ha1 = my1->readOGraphicArray((string)"OPoint"); deque<OGraphic*> ha2; for(int i=0;i<ha1.size();i++) //here we create an OVPoint array ha2.push_back(new OVPoint(i*0.1,i*0.1)); //here we replace only on the OPoint object by the OVPoint object my1->writeOGraphicArray((string)"OPoint",ha2); my1->print(); cout << endl; ha1.clear(); ha2.clear(); my1->~OHL(); } //de
void graphRequest1() { node n1,n2; edge e; OGraph *o1 = new OGraph(); n1 = o1->newNode(new OPoint(1,1)); n2 = o1->newNode(new OLine(2,2,3,3)); e = o1->newEdge(n1,n2,new ALabel("near")); o1->print(); OGraph *o2 = new OGraph(); n1 = o2->newNode(new OPoint(4,4)); n2 = o2->newNode(new OLine(5,5,6,6)); e = o2->newEdge(n1,n2,new ALabel("near")); o2->print(); o1->newNode(o2); o1->print(); cout << endl; deque<OGraphic*> a = o1->readOGraphicArray((string)"OPoint"); printOGraphicArray(a); o1->~OGraph(); a.clear(); } //de
void graphRequest2() { node n1,n2; edge e; OGraph *o1 = new OGraph(); n1 = o1->newNode(new OPoint(1,1)); n2 = o1->newNode(new OLine(2,2,3,3)); e = o1->newEdge(n1,n2,new ALabel("near")); OGraph *o2 = new OGraph(); n1 = o2->newNode(new OPoint(4,4)); n2 = o2->newNode(new OLine(5,5,6,6)); e = o2->newEdge(n1,n2,new ALabel("near")); o1->newNode(o2); o1->print(); cout << endl; deque<OGraphic*> a1 = o1->readOGraphicArray((string)"OPoint"); printOGraphicArray(a1); deque<OGraphic*> a2; for(int i=0;i<a1.size();i++) a2.push_back(new OVPoint(i*0.1,i*0.1)); o1->writeOGraphicArray((string)"OPoint",a2); o1->print(); cout << endl; o1->~OGraph(); a1.clear(); a2.clear(); } //de