[gme-users] GME Tutorial Question

Sowayan, Abdullah (N-ED Software Inc.) abdullah.sowayan at lmco.com
Thu Mar 18 17:22:47 CDT 2010


Hi folks,

So I was able to move a little forward with the tutorial example. I instantiate my visitor in invokeEx and call accept on the NetDiagram.

My question is a simple one, do I have to do the traversal myself, or can I pass the root model (NetDiagram) and have something traverse it for me and call accept on the visitor?


void Component::invokeEx( Project& project, FCO& currentFCO, const std::set<FCO>& setSelectedFCOs, long lParam )
{
#ifdef GME_ADDON
      project->setAutoCommit( false);
#endif
      using namespace GMEConsole;
      Console::Out::WriteLine("Interpreter started...");
      // ======================
      // TODO: Insert application specific code here

  Console::Out::WriteLine((std::string("Router list for network ") + project->getRootFolder()->getName()).c_str());
      std::set<BON::Object> diagrams = project->getRootFolder()->getChildObjects("NetDiagram");
      for (std::set<BON::Object>::iterator it = diagrams.begin(); it != diagrams.end(); it++) {
            Networking::NetDiagram diagram = *it;
    Networking::networkingVisitor* netvisit = new Networking::networkingVisitor;
    diagram->accept(netvisit);
    delete netvisit;
//          ProcessDiagram(diagram);
      }

      Console::Out::WriteLine("Interpreter completed...");
}




bool networkingVisitor::visitNetDiagram( const Networking::NetDiagram& object )
{
      if ( !object)
            return false;

  GMEConsole::Console::Out::WriteLine("Abdul Abdul Abdul");

      return true;
}

Thanks,
Abdul


From: gme-users-bounces at list.isis.vanderbilt.edu [mailto:gme-users-bounces at list.isis.vanderbilt.edu] On Behalf Of Sowayan, Abdullah (N-ED Software Inc.)
Sent: Thursday, March 18, 2010 5:33 PM
To: A list for GME users to share thoughts and discuss bugs and fixes.
Subject: [gme-users] GME Tutorial Question

Hi folks,

I am trying to follow the GME tutorial. It has been many, many years since I wrote an interpreter. I was specifically intrigued with the BON2 Extender.

I have generated the visitor classes using the BON2Extender interpreter in GME, and my whole project builds fine. What I can't seem to figure out is how to get my visitor invoked.

In my simple interpreter (based on the tutorial) I have this:

networkingVisitor::networkingVisitor()
{
  myfile.open("Abdul.txt");
}

bool networkingVisitor::visitHost( const Networking::Host& object )
{
      if ( !object)
            return false;

  myfile << "Abdul Abdul Abdul" << std::endl;

      return true;
}


Abdul.txt never gets created. It is not clear to me where I should instantiate my visitor and call accept() method.

Any help would be greatly appreciated.

Thanks,
Abdul


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://list.isis.vanderbilt.edu/pipermail/gme-users/attachments/20100318/4cfd2c57/attachment.html 


More information about the gme-users mailing list