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

general/SPref.h

Go to the documentation of this file.
00001 /* #start# ***********************************************************
00002 
00003                              Scheduling Simulator
00004                     Lehrstuhl f"ur Effiziente Algorithmen
00005                        Technische Universit"at M"unchen
00006 
00007  File    : $Id: SPref.h,v 1.7 2003/01/13 00:31:18 taeubig Exp $
00008 
00009  Purpose : a singleton class which is used to globally access the Preferences 
00010            file format of the .rc-file (an example):
00011 
00012      ident "value"
00013      earth "flat"
00014      bogart "cool"
00015      answer "42"
00016 
00017  RCS-Log:
00018  $Log: SPref.h,v $
00019  Revision 1.7  2003/01/13 00:31:18  taeubig
00020  added using declaration for std::string
00021 
00022  Revision 1.6  2003/01/09 17:07:27  taeubig
00023  replaced leda_string by string
00024 
00025  Revision 1.5  2003/01/08 18:57:12  meierb
00026  added randomized release times
00027 
00028  Revision 1.1.1.1  2002/12/02 22:26:19  meierb
00029  my_schedule
00030 
00031  Revision 1.3  2002/11/11 16:52:47  taeubig
00032  header include changes
00033 
00034  Revision 1.2  2002/09/17 07:25:13  woerster
00035  added functions to save recently opened files
00036 
00037  Revision 1.1  2002/08/29 12:59:58  taeubig
00038  Added the sources
00039 
00040  Revision 1.17  2000/06/15 13:42:33  taeubig
00041  Added rejected state support
00042 
00043  Revision 1.16  2000/06/14 19:00:42  taeubig
00044  Meshview enable/disable
00045 
00046  Revision 1.15  2000/05/24 13:34:59  taeubig
00047  New compiler (gcc-2.95) and new Qt (2.1)
00048  Replaced "list" by "leda_list" etc.
00049 
00050  Revision 1.14  2000/01/11 17:26:12  zoidl
00051  added javadoc comments
00052 
00053  Revision 1.13  2000/01/09 09:38:38  kern
00054  put logging functions into one function to reduce the amount of events
00055 
00056  Revision 1.12  2000/01/05 14:33:51  kern
00057  added events to setSchedFilter and setEditFilter
00058 
00059  Revision 1.11  2000/01/04 12:09:05  kern
00060  removed small bug in setLogOptCritValues
00061 
00062  Revision 1.10  1999/12/27 10:05:48  kern
00063  added new logger prefs
00064 
00065  Revision 1.9  1999/12/20 10:44:54  kern
00066  added pref events
00067 
00068  Revision 1.8  1999/12/14 09:15:16  kern
00069  added preferences for logger in visualization part
00070 
00071  Revision 1.7  1999/12/10 10:34:38  kern
00072  added preferences for machine view
00073 
00074  Revision 1.6  1999/12/08  23:02:45  zoidl
00075  added logging of EDITEVENTs
00076 
00077  Revision 1.5  1999/12/07 14:14:28  zoidl
00078  added schedFilter for STextLog
00079 
00080  Revision 1.4  1999/12/06 14:11:22  kern
00081  added some more preferences for visualization
00082 
00083  Revision 1.3  1999/12/01  14:00:54  zoidl
00084  rounding problems solved with epsilon in preferences
00085 
00086  Revision 1.2  1999/12/01 09:48:13  kern
00087  added pref-functions for visualization part
00088 
00089  Revision 1.1  1999/11/26 17:46:56  hall
00090  SPref added
00091 
00092 
00093  * #end# ************************************************************* */
00094 
00095 #ifndef SPREF_H
00096 #define SPREF_H
00097 
00098 // system header files
00099 #include <cassert>
00100 #include <string>
00101 
00102 #include <LEDA/string.h>
00103 #include <LEDA/list.h>
00104 
00105 // project header files
00106 #include "SObservable.h"
00107 #include "SPrefEvent.h"
00108 
00109 // QT header files
00110 #include <qrect.h>
00111 #include <qpoint.h>
00112 
00113 using std::string;
00114 
00120 // -----------------------------------------------------------------------
00121 class SPref : public SObservable
00122 {  
00123 public:
00124   // just to get rid of the dumb-fuck warning 
00125   SPref(int blub) { assert(false); };
00126 
00131   static SPref &instance();
00132 
00135   ~SPref() {};
00136 
00139   void load();
00140 
00143   void save();
00144 
00149   static string getRootDir();
00150 
00151   // *** Access-functions to the pref-variables
00152   const leda_string &getJobHiddenColor() const { return _jobHiddenColor; };
00153   void setJobHiddenColor(const leda_string &s) { 
00154     if( s != _jobHiddenColor ) {
00155       _jobHiddenColor = s;
00156       SPrefEvent ev( SPrefEvent::JOBLAYOUT );
00157       notifyObservers( ev );   
00158     }
00159   };
00160   const leda_string &getJobReleasedColor() const { return _jobReleasedColor; };
00161   void setJobReleasedColor(const leda_string &s) { 
00162     if( s != _jobReleasedColor ) {
00163       _jobReleasedColor = s;
00164       SPrefEvent ev( SPrefEvent::JOBLAYOUT );
00165       notifyObservers( ev ); 
00166     }
00167   };
00168   const leda_string &getJobRunningColor() const { return _jobRunningColor; };
00169   void setJobRunningColor(const leda_string &s) { 
00170     if( s != _jobRunningColor ) {
00171       _jobRunningColor = s;
00172       SPrefEvent ev( SPrefEvent::JOBLAYOUT );
00173       notifyObservers( ev ); 
00174     }
00175   };
00176   const leda_string &getJobFinishedColor() const
00177     { return _jobFinishedColor; };
00178   void setJobFinishedColor(const leda_string &s) { 
00179     if( s != _jobFinishedColor ) {
00180       _jobFinishedColor = s;
00181       SPrefEvent ev( SPrefEvent::JOBLAYOUT );
00182       notifyObservers( ev );  
00183     }
00184   };
00185   const leda_string &getJobRejectedColor() const
00186     { return _jobRejectedColor; };
00187   void setJobRejectedColor(const leda_string &s) { 
00188     if( s != _jobRejectedColor ) {
00189       _jobRejectedColor = s;
00190       SPrefEvent ev( SPrefEvent::JOBLAYOUT );
00191       notifyObservers( ev );  
00192     }
00193   };
00194   const int &getUsePixmaps() const { return _usePixmaps; };
00195   void setUsePixmaps(const int &i) { 
00196     if( _usePixmaps != i ) {
00197       _usePixmaps = i;
00198       SPrefEvent ev( SPrefEvent::JOBLAYOUT );
00199       notifyObservers( ev );  
00200     }
00201   };
00202   const leda_string &getJobPixmapFile() const { return _jobPixmapFile; };
00203   void setJobPixmapFile(const leda_string &s) { 
00204     if( _jobPixmapFile != s ) {
00205       _jobPixmapFile = s;
00206       SPrefEvent ev( SPrefEvent::JOBLAYOUT );
00207       notifyObservers( ev );  
00208     }
00209   }; 
00210   void setJobLayoutSettings( const leda_string &hcol, const leda_string &recol, 
00211            const leda_string &rucol, const leda_string &fcol,
00212            const leda_string &rjcol,
00213            int width, int height, const leda_string &shape,
00214            int usepix, const leda_string &pixfile) {
00215     if( (hcol != _jobHiddenColor) || (recol != _jobReleasedColor) ||
00216   (rucol != _jobRunningColor ) || (fcol != _jobFinishedColor ) ||
00217   (rjcol != _jobRejectedColor ) ||
00218   (width != _nodeWidth) || (height != _nodeHeight) || 
00219   (shape != _nodeShape) ||
00220   (_usePixmaps != usepix) || (_jobPixmapFile != pixfile) ) {
00221       _jobHiddenColor = hcol;
00222       _jobReleasedColor = recol;
00223       _jobRunningColor = rucol;
00224       _jobFinishedColor = fcol;
00225       _jobRejectedColor = rjcol;
00226       _nodeWidth = width;
00227       _nodeHeight = height;
00228       _nodeShape = shape;
00229       _usePixmaps = usepix;
00230       _jobPixmapFile = pixfile;
00231       SPrefEvent ev( SPrefEvent::JOBLAYOUT );
00232       notifyObservers( ev );  
00233     }
00234   }; 
00235   int getNodeWidth() const { return _nodeWidth; };
00236   void setNodeWidth( int w ) { 
00237     if( _nodeWidth != w ) {
00238       _nodeWidth = w;
00239       SPrefEvent ev( SPrefEvent::JOBLAYOUT );
00240       notifyObservers( ev );   
00241     }
00242   };
00243   int getNodeHeight() const { return _nodeHeight; };
00244   void setNodeHeight( int h ) { 
00245     if( _nodeHeight != h ) {
00246       _nodeHeight = h;
00247       SPrefEvent ev( SPrefEvent::JOBLAYOUT );
00248       notifyObservers( ev );  
00249     }
00250   };
00251   const leda_string &getNodeShape() const { return _nodeShape; };
00252   void setNodeShape(const leda_string &s) { 
00253     if( _nodeShape != s ) {
00254       _nodeShape = s;
00255       SPrefEvent ev( SPrefEvent::JOBLAYOUT );
00256       notifyObservers( ev );  
00257     }
00258   };
00259   const leda_string &getMachGifFile() const { return _machGifFile; };
00260   void setMachGifFile(const leda_string &s) { 
00261     if( _machGifFile != s ) {
00262       _machGifFile = s;
00263       SPrefEvent ev( SPrefEvent::MACHLAYOUT );
00264       notifyObservers( ev );  
00265     }
00266   };
00267 
00268   const leda_string &getAlgorithm() const { return _algorithm; };
00269   const leda_string &getPlayerTasksystemFile() const { return _playerTasksystem; };
00270   const leda_string &getPlayerLogFile() const { return _playerLogFile; };
00271   void setAlgorithm(const leda_string &alg, const leda_string &playerTS, 
00272         const leda_string &playerLog) { 
00273     if( (_algorithm != alg) || (_playerTasksystem != playerTS) || 
00274   (_playerLogFile != playerLog) ) {
00275       _algorithm = alg;
00276       _playerTasksystem = playerTS;
00277       _playerLogFile = playerLog;
00278       SPrefEvent ev( SPrefEvent::ALGSETTINGS );
00279       notifyObservers( ev );
00280     }
00281   };
00282     
00283   int getLogTextActivated() { return _logTextActivated; };
00284   const string &getLogTextStream() { return _logTextStream; };
00285   const int &getSchedFilter() const { return _schedFilter; };
00286   const int &getEditFilter() const { return _editFilter; };
00287   void setLogTextSettings( int act, const string &s, int schedfilter,
00288          int editfilter) { 
00289     if( (_logTextActivated != act) || (_logTextStream != s) ||
00290   (_schedFilter != schedfilter)  || (_editFilter != editfilter ) ) {
00291       _schedFilter = schedfilter;
00292       _editFilter = editfilter;
00293       _logTextStream = s; 
00294       _logTextActivated = act;
00295       SPrefEvent ev( SPrefEvent::LOGSETTINGS );
00296       notifyObservers( ev );  
00297     }
00298   }; 
00299 
00300   int getLogPlayerActivated() { return _logPlayerActivated; }; 
00301   const string &getLogPlayerStream() { return _logPlayerStream; };
00302   void setLogPlayerSettings( int act, const string &s ) {
00303     if( (_logPlayerActivated != act) || (_logPlayerStream != s) ) {
00304       _logPlayerStream = s;
00305       _logPlayerActivated = act;
00306       SPrefEvent ev( SPrefEvent::LOGSETTINGS );
00307       notifyObservers( ev );  
00308     }
00309   };
00310   
00311   int getLogOptCritActivated() { return _logOptCritActivated; };
00312   void getLogOptCritValues( int &criterion, int &type, int &weighted ) {
00313     criterion = _logOptCritCriterion;
00314     type = _logOptCritType;
00315     weighted =_logOptCritWeighted;
00316   };
00317   void setLogOptCritSettings( int act, int criterion, int type, int weighted ) {
00318     if( ( _logOptCritActivated != act ) || ( _logOptCritCriterion != criterion ) 
00319   || ( _logOptCritType != type ) || ( _logOptCritWeighted != weighted ) ) {
00320       _logOptCritActivated = act;
00321       _logOptCritCriterion = criterion;
00322       _logOptCritType = type;
00323       _logOptCritWeighted = weighted;
00324       SPrefEvent ev( SPrefEvent::LOGSETTINGS );
00325       notifyObservers( ev ); 
00326     }
00327   };
00328   
00329   void setSchedWinPos( QPoint p ) { 
00330     _schedWinGeo.setX( p.x() );
00331     _schedWinGeo.setY( p.y() ); 
00332   };
00333   void setSchedWinSize( int w, int h ) { 
00334     _schedWinGeo.setWidth( w );
00335     _schedWinGeo.setHeight( h );
00336   };
00337   const QRect &getSchedWinGeometry() { return _schedWinGeo; };
00338   void setDAGWinPos( QPoint p ) { 
00339     _dagWinGeo.setX( p.x() );
00340     _dagWinGeo.setY( p.y() ); 
00341   };
00342   void setDAGWinSize( int w, int h ) { 
00343     _dagWinGeo.setWidth( w );
00344     _dagWinGeo.setHeight( h );
00345   };
00346   const QRect &getDAGWinGeometry() { return _dagWinGeo; };
00347   void setMachineWinPos( QPoint p ) { 
00348     _machineWinGeo.setX( p.x() );
00349     _machineWinGeo.setY( p.y() ); 
00350   };
00351   void setMachineWinSize( int w, int h ) { 
00352     _machineWinGeo.setWidth( w );
00353     _machineWinGeo.setHeight( h );
00354   };
00355   const QRect &getMachineWinGeometry() { return _machineWinGeo; }; 
00356   void setMeshWinPos( QPoint p ) { 
00357     _meshWinGeo.setX( p.x() );
00358     _meshWinGeo.setY( p.y() ); 
00359   };
00360   void setMeshWinSize( int w, int h ) { 
00361     _meshWinGeo.setWidth( w );
00362     _meshWinGeo.setHeight( h );
00363   };
00364   const QRect &getMeshWinGeometry() { return _meshWinGeo; }; 
00365   void setGanttWinPos( QPoint p ) {
00366     _ganttWinGeo.setX( p.x() );
00367     _ganttWinGeo.setY( p.y() ); 
00368   };
00369   void setGanttWinSize( int w, int h ) { 
00370     _ganttWinGeo.setWidth( w );
00371     _ganttWinGeo.setHeight( h );
00372   };
00373   const QRect &getGanttWinGeometry() { return _ganttWinGeo; };
00374 
00375   void setRecentFiles(leda_list<string> recentFiles) {
00376     _recentFiles = recentFiles;
00377   }
00378   const leda_list<string> getRecentFiles() {
00379     return _recentFiles;
00380   }
00381 
00382   // procTimes (jobs, operations) less than this epsilon are interpreted 
00383   // as zero, became necessary due to rounding errors
00384   const double &getProcTimeEps() const { return _procTimeEps; };
00385   void setProcTimeEps(const double &d) { _procTimeEps = d; };
00386 
00387   // *** 
00388 private:
00389   // pointer to the only instance of the class
00390   static SPref _instance;    
00391   // contains the name of the .rc-file 
00392   string _rcName;
00393 
00394   // *** the actual pref-variables
00395   leda_list<string> _recentFiles;
00396   leda_string _jobHiddenColor; 
00397   leda_string _jobReleasedColor; 
00398   leda_string _jobRunningColor; 
00399   leda_string _jobFinishedColor;
00400   leda_string _jobRejectedColor;
00401   leda_string _algorithm;
00402   leda_string _playerTasksystem;
00403   leda_string _playerLogFile;
00404   string _logTextStream;
00405   int _logTextActivated;
00406   string _logPlayerStream;
00407   int _logPlayerActivated;
00408   int _logOptCritActivated;
00409   int _logOptCritCriterion;
00410   int _logOptCritType;
00411   int _logOptCritWeighted;
00412   int _usePixmaps;
00413   leda_string _jobPixmapFile;
00414   int _nodeWidth;
00415   int _nodeHeight;
00416   leda_string _nodeShape;
00417   leda_string _machGifFile;
00418   QRect _schedWinGeo;
00419   QRect _dagWinGeo;
00420   QRect _machineWinGeo; 
00421   QRect _meshWinGeo; 
00422   QRect _ganttWinGeo;
00423   double _procTimeEps;
00424   int _schedFilter;
00425   int _editFilter; 
00426   // ***
00427 
00428   // never used from the outside!
00429   SPref() { _rcName = getRootDir() + "/.schedrc"; load(); };
00430   //  copying is forbidden!
00431   SPref(const SPref &p);            // copy constructor (empty)
00432   SPref &operator=(const SPref &p); // operator= (empty)
00433 };
00434 // ----------------------------------------------------------------------
00435 
00436 #endif

Generated on Thu May 22 16:48:08 2003 for Sketch-it! by doxygen1.2.18