HyperspaceExplorer 0.7.1
Statement.h
00001 /*
00002 Hyperspace Explorer - visualizing higher-dimensional geometry
00003 Copyright (C) 2010  Lene Preuss <lene.preuss@gmail.com>
00004 
00005 This program is free software; you can redistribute it and/or modify
00006 it under the terms of the GNU General Public License as published by
00007 the Free Software Foundation; either version 2 of the License, or
00008 (at your option) any later version.
00009 
00010 This program is distributed in the hope that it will be useful,
00011 but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 GNU General Public License for more details.
00014 
00015 You should have received a copy of the GNU General Public License along
00016 with this program; if not, write to the Free Software Foundation, Inc.,
00017 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00018 
00019 */
00020 
00021 #include "Rotation.h"
00022 #include "Vector.h"
00023 
00024 #include <string>
00025 
00026 class Parser;
00027 
00029 
00030 namespace Script {
00031 
00033 
00034     class BadStatementException: public std::runtime_error {
00035         public:
00037             BadStatementException(const std::string &what):
00038                 std::runtime_error(what) { }
00039     };
00040 
00043 
00045 
00048     class Statement {
00049 
00050         public:
00054             Statement(const Parser *parser, const std::string &arg):
00055                 _arg(arg), _parser(parser) { }
00057             virtual bool execute();
00058 
00059         protected:
00061             const std::string &arg() { return _arg; }
00063             const Parser *parser() { return _parser; }
00064 
00065         private:
00066             std::string _arg;       
00067             const Parser *_parser;  
00068     };
00069 
00071 
00072     class BoolStatement: public Statement {
00073         public:
00077             BoolStatement (const Parser *p, const std::string &_arg);
00079             virtual bool execute() = 0;
00080 
00081         protected:
00083             bool getValue() { return _bool; }
00084 
00085         private:
00086             bool _bool;         
00087     };
00088 
00090 
00092     class SizeStmt: public Statement {
00093         public:
00097             SizeStmt(const Parser *p, const std::string &_arg);
00099             virtual bool execute();
00100         private:
00101             unsigned _width;    
00102             unsigned _height;   
00103     };
00104 
00106 
00108     class ObjectStmt: public Statement {
00109         public:
00113             ObjectStmt(const Parser *p, const std::string &_arg):
00114                     Statement(p, _arg) { }
00116             virtual bool execute();
00117     };
00118 
00120 
00122     template <typename T = unsigned> class ParmStmt: public Statement {
00123         public:
00127             ParmStmt(const Parser *p, const std::string &_arg):
00128                 Statement(p, _arg) { }
00130             virtual bool execute();
00131     };
00132 
00134 
00137     class XformStmt: public Statement {
00138         public:
00142             XformStmt(const Parser *p, const std::string &_arg);
00144             virtual bool execute();
00145 
00146         protected:
00148             VecMath::Rotation<4> &r() { return _r; }
00149 
00150         private:
00151             VecMath::Rotation<4> _r;    
00152     };
00153 
00155 
00158     class RotStmt: public XformStmt {
00159         public:
00163             RotStmt(const Parser *p, const std::string &_arg):
00164                 XformStmt(p, _arg) { }
00166             virtual bool execute();
00167     };
00168 
00170 
00173     class DeltaStmt: public XformStmt {
00174         public:
00178             DeltaStmt(const Parser *p, const std::string &_arg):
00179                 XformStmt(p, _arg) { }
00181             virtual bool execute();
00182     };
00183 
00185 
00188     class RotDeltaStmt: public DeltaStmt {
00189         public:
00193             RotDeltaStmt(const Parser *p, const std::string &_arg):
00194                 DeltaStmt(p, _arg) { }
00196             virtual bool execute();
00197     };
00198 
00200 
00202     class FramesStmt: public Statement {
00203         public:
00207             FramesStmt(const Parser *p, const std::string &_arg);
00209             virtual bool execute();
00210         private:
00211             unsigned _frames;   
00212     };
00213 
00215 
00217     class LoopStmt: public Statement {
00218         public:
00222             LoopStmt(const Parser *p, const std::string &_arg);
00224             virtual bool execute();
00225         private:
00226             unsigned _loops;    
00227     };
00228 
00230 
00232     class ColorStmt: public BoolStatement {
00233         public:
00237             ColorStmt(const Parser *p, const std::string &_arg):
00238                 BoolStatement(p, _arg) { }
00240             virtual bool execute();
00241     };
00242 
00244 
00246     class ShadingStmt: public BoolStatement {
00247         public:
00251             ShadingStmt(const Parser *p, const std::string &_arg):
00252                 BoolStatement(p, _arg) { }
00254             virtual bool execute();
00255     };
00256 
00258 
00260     class LightStmt: public BoolStatement {
00261         public:
00265             LightStmt(const Parser *p, const std::string &_arg):
00266                 BoolStatement(p, _arg) { }
00268             virtual bool execute();
00269     };
00270 
00272 
00274     class TransStmt: public BoolStatement {
00275         public:
00279             TransStmt(const Parser *p, const std::string &_arg):
00280                 BoolStatement(p, _arg) { }
00282             virtual bool execute();
00283     };
00284 
00286 
00288     class WireStmt: public BoolStatement {
00289         public:
00293             WireStmt(const Parser *p, const std::string &_arg):
00294                 BoolStatement(p, _arg) { }
00296             virtual bool execute();
00297     };
00298 
00300 
00302     class SolidStmt: public BoolStatement {
00303         public:
00307             SolidStmt(const Parser *p, const std::string &_arg):
00308                 BoolStatement(p, _arg) { }
00310             virtual bool execute();
00311     };
00312 
00314 
00316     class FogStmt: public BoolStatement {
00317         public:
00321             FogStmt(const Parser *p, const std::string &_arg):
00322                 BoolStatement(p, _arg) { }
00324             virtual bool execute();
00325     };
00326 
00328 
00330     class Fog4DStmt: public BoolStatement {
00331         public:
00335             Fog4DStmt(const Parser *p, const std::string &_arg):
00336                 BoolStatement(p, _arg) { }
00338             virtual bool execute();
00339     };
00340 
00342 
00344     class CoordsStmt: public BoolStatement {
00345         public:
00349             CoordsStmt(const Parser *p, const std::string &_arg):
00350                 BoolStatement(p, _arg) { }
00352             virtual bool execute();
00353     };
00354 
00356 
00358     class AnimateStmt: public Statement {
00359         public:
00362             AnimateStmt(const Parser *p): Statement(p, "") { }
00364             virtual bool execute();
00365     };
00366 
00368 
00370     class SleepStmt: public Statement {
00371         public:
00375             SleepStmt(const Parser *p, const std::string &_arg);
00377             virtual bool execute();
00378         private:
00379             unsigned _msec;     
00380     };
00381 
00383 
00385     class ImgDirStmt: public Statement {
00386         public:
00390             ImgDirStmt(const Parser *p, const std::string &_arg):
00391                 Statement(p, _arg) { }
00393             virtual bool execute();
00394     };
00395 
00397 
00399     class ImgPrefixStmt: public Statement {
00400         public:
00404             ImgPrefixStmt(const Parser *p, const std::string &_arg):
00405                 Statement(p, _arg) { }
00407             virtual bool execute();
00408     };
00409 
00411 
00412     class StatementFactory {
00413         public:
00415             static Statement *createStatement(const Parser *,
00416                                               const std::string &);
00417     };
00418 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends

Generated on Mon Apr 9 2012 20:25:16 for HyperspaceExplorer 0.7.1 by doxygen 1.7.4  -  Hosted bySourceForge.net Logo