Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members  

SIG_RobotBuilder.cpp

00001 #include "SIGEL_RobotIO/SIG_RobotBuilder.h"
00002 #include <qfile.h>
00003 #include <qtextstream.h>
00004 
00005 namespace SIGEL_RobotIO {
00006         SIG_RobotBuilder::SIG_RobotBuilder (QString file)
00007                 : SIG_RobotFactory (),
00008                   filename (file)
00009         { }
00010         
00011         SIG_RobotBuilder::~SIG_RobotBuilder (void)
00012         { }
00013         
00014         SIG_Robot *SIG_RobotBuilder::build (void)
00015         {
00016                 robot = new SIG_Robot ();
00017 
00018                 buildInto (*robot);
00019 
00020                 return robot;
00021         }
00022 
00023         void SIG_RobotBuilder::buildInto (SIG_Robot & rob)
00024         {
00025                 // normalization and initiation have been
00026                 // removed due to the disentanglement of
00027                 // the parser passes.
00028                 rob.clear ();
00029                 
00030                 robot = &rob;
00031 
00032                 firstPass ();
00033                 secondPass ();
00034                 rob.loadGeometries ();
00035         }
00036         
00037         QString SIG_RobotBuilder::loadFile (QString name)
00038         {
00039                 QFile f;
00040                 f.setName (name);
00041                 f.open (IO_ReadOnly);
00042                 QTextStream ts (&f);
00043                 QString stri = ts.read ();
00044                 f.close ();
00045                 return stri;
00046         }
00047         
00048         void SIG_RobotBuilder::firstPass (void)
00049         {
00050                 QString homepath;
00051                 int occ = filename.findRev ('/');
00052                 if (occ < 0)
00053                         homepath = "./";
00054                 else
00055                         homepath = filename.left (occ + 1);
00056                 
00057                 SIG_RobotScanner *s = new SIG_RobotScanner
00058                         (loadFile (filename));
00059                 SIG_RobotCompilerObjects *c = new SIG_RobotCompilerObjects
00060                         (*s, robot, homepath);
00061                 c->runPass ();
00062                 delete c;
00063                 delete s;
00064         }
00065         
00066         void SIG_RobotBuilder::secondPass (void)
00067         {
00068                 QString homepath;
00069                 int occ = filename.findRev ('/');
00070                 if (occ < 0)
00071                         homepath = "./";
00072                 else
00073                         homepath = filename.left (occ + 1);
00074                 
00075                 SIG_RobotScanner *s = new SIG_RobotScanner
00076                         (loadFile (filename));
00077                 SIG_RobotCompilerStructure *c = new SIG_RobotCompilerStructure
00078                         (*s, robot, homepath);
00079                 c->runPass ();
00080                 delete c;
00081                 delete s;
00082         }
00083         
00084 }

Generated at Mon Sep 3 01:32:29 2001 for PG 368 - SIGEL by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000