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

SIG_ProgramLine.h

00001 /* ----------------------------------------------------------------------- */
00002 /* CLASS:     SIG_ProgrammLine.h                                           */
00003 /* FUNCTION:  This class contains all functions that are needed to work    */
00004 /*            with a program line (that's contained by a SIG_Program).     */
00005 /*            Every program line is a sequence of numbers, which are       */
00006 /*            depended on the line's type.                                 */
00007 /* ----------------------------------------------------------------------- */
00008 
00009 
00010 
00011 #if !defined(SIGEL_PROGRAMPACKAGE_SIG_PROGRAMLINE_H) 
00012 #define SIGEL_PROGRAMPACKAGE_SIG_PROGRAMLINE_H
00013 
00014 #include<qlist.h>
00015 #include<qarray.h>
00016 #include<qtextstream.h>
00017 #include<qstring.h>
00018 
00019 #include "SIGEL_Tools/SIG_Randomizer.h"
00020 #include "SIGEL_Robot/SIG_LanguageParameters.h"
00021 
00022 namespace SIGEL_Program
00023    {
00024 
00025 // -----------------------------------------------------------------------
00026 // ENUM DEFINITION
00027 // -----------------------------------------------------------------------
00028 
00036 enum Robotinstruction {
00037 
00038      COPY,
00039      LOAD,
00040      ADD,
00041      SUB,
00042      MUL,
00043      DIV,
00044      MOD,
00045      MIN,
00046      MAX,
00047      CMP,
00048      JMP,
00049      SENSE,
00050      MOVE,
00051      DELAY,
00052      NOP,
00053 };
00054 
00055 
00063 class SIG_ProgramLine
00064 {
00065 
00070    protected:
00071    Robotinstruction instructionType;
00072 
00079    protected:
00080    QArray< int > element;
00081    
00082 
00089    public:
00090    SIG_ProgramLine();
00091 
00097    public:
00098    SIG_ProgramLine( SIGEL_Tools::SIG_Randomizer &r, 
00099                     SIGEL_Robot::SIG_LanguageParameters &languageP,
00100                     QArray< int > &prob );
00101  
00108    public:
00109    virtual ~SIG_ProgramLine();   
00110 
00111                                             
00117    public:
00118    void generateRandomRobotInstruction( SIGEL_Robot::SIG_LanguageParameters &languageP,
00119                                         SIGEL_Tools::SIG_Randomizer &r,
00120                                         QArray< int > &prob  );
00121           
00128    public:
00129    void clearLine();
00130 
00140    public:
00141    void copyLine( SIGEL_Program::SIG_ProgramLine *source, 
00142                   SIGEL_Program::SIG_ProgramLine *destination );
00143   
00149    public:
00150    void randomRobotinstruction( SIGEL_Robot::SIG_LanguageParameters &languageP,
00151                                 SIGEL_Tools::SIG_Randomizer &r,
00152                                 QArray< int > &prob );
00157    public:
00158    void print();
00159 
00167    public:
00168    void setElement( int no, int value );
00169 
00177    public:
00178    void resizeElements( int size );
00179 
00180 
00187    public:
00188    void writeToFile( QTextStream &file );
00189 
00208    public:
00209    bool readFromFile( QString &str, 
00210                       SIGEL_Program::SIG_ProgramLine *line );
00211 
00217    public:
00218    void printToString(QString &lineStr);
00219 
00224    public:
00225    QArray< int > getElementsArray();
00226 
00227 
00232    public:
00233    Robotinstruction getRobotinstructionType();
00234 
00245    public:
00246    int getInstructionElement(int no);
00247 
00256    public:
00257    int getElement(int no);
00258 
00265    public:
00266    int getNumberOfElements();
00267 
00274    SIGEL_Program::SIG_ProgramLine& operator =(SIGEL_Program::SIG_ProgramLine const & prgLine);
00275 
00280   public:
00281   void setRobotinstructionType( Robotinstruction instr );
00282 
00289    public:
00290    void setRobotinstruction(SIGEL_Program::Robotinstruction instr, int op1, int op2);
00291 
00296    protected:
00297    void readTwoRegisters(QString &str,int &reg1,int &reg2);
00298 
00303    protected:
00304    void readOneRegisterAndIntegerConstant(QString &str,int &reg1,int &cnst);
00305 
00310    protected:
00311    void readOneRegister(QString &str,int &reg);   
00312    
00313    };
00314 
00315 };
00316 
00317 #endif // SIGEL_PROGRAMPACKAGE_SIG_PROGRAMLINE_H

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