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

robprofile.h

Go to the documentation of this file.
00001 /*
00002  * robprofile.h
00003  * 
00004  * Copyright (c) 2000-2004 by Florian Fischer (florianfischer@gmx.de)
00005  * and Martin Trautmann (martintrautmann@gmx.de) 
00006  * 
00007  * This file may be distributed and/or modified under the terms of the 
00008  * GNU General Public License version 2 as published by the Free Software 
00009  * Foundation. 
00010  * 
00011  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00012  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00013  * 
00014  */
00015 
00020 #ifndef __RT_PROFILE__
00021 #define __RT_PROFILE__
00022 
00023 #include "robfrontend.h"
00024 #include "robmanage.h"
00025 #include "robbase.h"
00026 
00027 #include <rtsystem.h>
00028 #include <rtstreams.h>
00029 
00030 using namespace lrt;
00031 
00032 namespace rt {
00033 
00035 enum ProfileMode {
00036         profCount,     
00037         profTime,      
00038         profFailure    
00039 };
00040 
00042 class ProfilePlugin : public FrontendPlugin  
00043 {
00044 public:
00045         virtual FpInterpretePos getInterpretePos();
00046         virtual String getName();
00047         virtual String getHelpText();
00048         virtual bool interpreteParams(const Array<String>& params, Array<bool>& used);
00049         virtual void fillOptions(SimOptions& options);
00050 
00052         ProfileMode getMode() { return mode; }
00055         void setMode(ProfileMode m) { mode = m; }
00056 
00057         ProfilePlugin(Frontend* parent);
00058         ~ProfilePlugin() {}
00059 private:
00060         ProfileMode mode;
00061 };
00062 
00063 struct ProfileBankData {
00064         String name;
00065         Map<Instr*, unsigned int> data;
00066 };
00067 
00068 typedef Map< Bank*, ProfileBankData >  ProfileMap; 
00069 
00070 class ProfileSupervisor : public ExecSupervisor
00071 {
00072 public:
00073         ProfileSupervisor(Frontend* parent, ProfileMode mode);
00074         virtual void initSim(Simulation* const curSim);
00075         virtual void onExec(Instr* instr, Bank* bank, Task* task);
00076         virtual void exitSim(Simulation* const curSim);
00077 private:
00078         enum trool { // troolean value (for more examples, cf. Win32 API)
00079                 trError = -1,
00080                 trFalse = 0,
00081                 trTrue = 1
00082         };
00083 
00084         ProfileMap profData;
00085         void printProgram(Program*);
00086         void printHtml(const String& profFileName); 
00087         void printInstrs(Bank*, OutputStream* out);
00088         // is the bank in one of the programs of that simulation? 
00089         bool isReachable(Bank*, const String& name, Simulation*);
00090         // NOTE. We don't want to detect the fatal errors again (the instruction already does that
00091         // by itself, and they can be shown) but the more subtle cases here :
00092         //   * trying to create or move when there is already a bot in front of you
00093         //   * trying to trans or rtrans when there is no bot in front of you
00094         //   * insert others here...
00095         trool detectFailure(Instr* instr, Bank* bank, Task* task);
00096 
00097         ProfileMode mode;
00098         Frontend* parent;
00099 };
00100 
00101 } // namespace
00102 
00103 #endif
00104 

This is the RoboTour API documentation version 0.1 • Copyright (C) by Florian Fischer