Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members   Related Pages   Examples  

Knowledge requests

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.

OHL requests
The following function gives examples of a read request.
    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
The following function gives examples of a read/write request.
    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
OGraph requests
The following function gives examples of a read request.
    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
The following function gives examples of a read/write request.
    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

Generated on Fri Jul 30 19:21:03 2004 for GOMLib by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001