• Main Page
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

C:/CVUT/diplomka/Automata_editor/algorithms/algorithms.h

Go to the documentation of this file.
00001 #ifndef _ALGORITHMS_H_11656963715131_
00002 #define _ALGORITHMS_H_11656963715131_
00003 
00004 #include <QObject>
00005 #include "interfaces/ialgorithm.h"
00006 
00007 #ifndef QT_STATICPLUGIN
00008 #   define QT_STATICPLUGIN
00009 #endif
00010 
00011 class IAutomataCreator;
00012 
00013 class BasicAlgorithm : public IAlgorithm
00014 {
00015 public:
00016     BasicAlgorithm();
00017 
00018     virtual ~BasicAlgorithm() {}
00019 
00020     bool requireCreator() const { return true; }
00021 
00022     void setAutomataCreator(const QSharedPointer<IAutomataCreator> &creator);
00023 
00024     bool hasSettingsDialog() const { return false; }
00025     void runSettingsDialog(QWidget *) {}
00026 
00027     bool run(const IAutomaton::TAutomataList &input, QSharedPointer<IAutomaton> &result,
00028              QString *report = 0) const;
00029 
00030 protected:
00031     //! each basic algorithm has to implements this method
00032     virtual bool runInternal(const IAutomaton::TAutomataList &input,
00033                              QSharedPointer<IAutomaton> &result) const = 0;
00034 
00035     virtual bool removeMultipleInitials(QSharedPointer<IAutomaton> &automaton) const;
00036     virtual bool removeEpsilonTransitions(QSharedPointer<IAutomaton> &automaton) const;
00037     virtual bool determinize(QSharedPointer<IAutomaton> &automaton) const;
00038 
00039     void makeSureNameUnique(const QSharedPointer<IAutomaton> &automaton,
00040                             QString &name) const;
00041 
00042     void makeSureNamesUnique(const QSharedPointer<IAutomaton> &automaton1,
00043                              const QSharedPointer<IAutomaton> &automaton2) const;
00044 
00045     //! const because doesn't change algorithm, however changes report member
00046     virtual void addReport(const QString &text) const;
00047 
00048     IState::TIStateNameSet getEpsilonClosure(const QSharedPointer<IAutomaton> &automaton,
00049                                              const QSharedPointer<IState> &state) const;    
00050     
00051     bool tryMergeAlphabet(const ITransition::TCharSet &alphabet1,
00052                           const ITransition::TCharSet &alphabet2,
00053                           ITransition::TCharSet &alphabet) const;
00054 
00055     QSharedPointer<IAutomataCreator>    m_creator;
00056     
00057 private:
00058     mutable QString     m_report;
00059 };
00060 
00061 
00062 
00063 class BasicAlgorithmWithSettings : public BasicAlgorithm
00064 {
00065 public:
00066     BasicAlgorithmWithSettings(bool preserveNames = false, bool preserveLabels = false);
00067 
00068     bool hasSettingsDialog() const { return true; }
00069     void runSettingsDialog(QWidget *parent);
00070     
00071     //! \name algorithm's settings
00072     //! \{
00073     bool preserveNames() const { return m_preserveNames; }
00074     bool preserveLabels() const { return m_preserveLabels; }
00075     void setPreserveNames(bool preserve) { m_preserveNames = preserve; }
00076     void setPreserveLabels(bool preserve) { m_preserveLabels = preserve; }
00077     //! \}
00078 
00079 protected:    
00080     QString chooseStateName(QSharedPointer<IAutomaton> &automaton,
00081                             const QStringList &nameList, int num) const;
00082     QString chooseStateLabel(const QStringList &labelList, int num) const;
00083     
00084 private:
00085     bool    m_preserveNames;
00086     bool    m_preserveLabels;
00087 };
00088 
00089 
00090 
00091 /*!
00092  * Jan Holub, X36JPR-03/23, 2008/2009
00093  */
00094 class RemoveEpsilonAlgorithm : public BasicAlgorithm
00095 {
00096 public:
00097     ~RemoveEpsilonAlgorithm();
00098 
00099     QString getName() const;
00100     
00101     int getInputCount() const { return 1; }
00102 
00103 protected:
00104     bool runInternal(const IAutomaton::TAutomataList &input,
00105                      QSharedPointer<IAutomaton> &result) const;    
00106 };
00107 
00108 
00109 
00110 /*!
00111  * Jan Holub, X36JPR-03/14, 2008/2009
00112  */
00113 class RemoveInaccessibleAlgorithm: public BasicAlgorithm
00114 {
00115 public:
00116     ~RemoveInaccessibleAlgorithm();
00117 
00118     QString getName() const;
00119 
00120     int getInputCount() const { return 1; }
00121 
00122 protected:
00123     bool runInternal(const IAutomaton::TAutomataList &input,
00124                      QSharedPointer<IAutomaton> &result) const;
00125 };
00126 
00127 
00128 
00129 /*!
00130  * Jan Holub, X36JPR-03/17, 2008/2009
00131  */
00132 class RemoveUselessAlgorithm: public BasicAlgorithm
00133 {
00134 public:
00135     ~RemoveUselessAlgorithm();
00136 
00137     QString getName() const;
00138 
00139     int getInputCount() const { return 1; }
00140 
00141 protected:
00142     bool runInternal(const IAutomaton::TAutomataList &input,
00143                      QSharedPointer<IAutomaton> &result) const;
00144 };
00145 
00146 
00147 
00148 /*!
00149  * Jan Holub, X36JPR-03/17, 2008/2009
00150  */
00151 class RemoveMultipleInitialsAlgorithm: public BasicAlgorithm
00152 {
00153 public:
00154     ~RemoveMultipleInitialsAlgorithm();
00155     
00156     QString getName() const;
00157 
00158     int getInputCount() const { return 1; }
00159 
00160 protected:
00161     bool runInternal(const IAutomaton::TAutomataList &input,
00162                      QSharedPointer<IAutomaton> &result) const;
00163 };
00164 
00165 
00166 
00167 /*!
00168  * Jan Holub, X36JPR-03/33, 2008/2009
00169  */
00170 class DeterminizeAlgorithm: public BasicAlgorithmWithSettings
00171 {
00172 public:
00173     DeterminizeAlgorithm();
00174     ~DeterminizeAlgorithm();
00175     
00176     QString getName() const;
00177     
00178     int getInputCount() const { return 1; }
00179     
00180 protected:
00181     bool runInternal(const IAutomaton::TAutomataList &input,
00182                      QSharedPointer<IAutomaton> &result) const;    
00183 };
00184 
00185 
00186 /*!
00187  * VSB Ostrava, TI, http://www.elearn.vsb.cz/archivcd/FEI/UTI/, Minimalizace KA
00188  */
00189 class MinimalizeAlgorithm : public BasicAlgorithm
00190 {
00191 public:
00192     ~MinimalizeAlgorithm();
00193 
00194     QString getName() const;
00195 
00196     int getInputCount() const
00197     {
00198         return 1;
00199     }
00200 
00201 protected:
00202     bool runInternal(const IAutomaton::TAutomataList &input,
00203                      QSharedPointer<IAutomaton> &result) const;    
00204 };
00205 
00206 
00207 
00208 /*!
00209  * X36PJP, Algorithm 2.71 - Jazyky a preklady, prof. Ing. Borivoj Melichar, DrSc. 2003
00210  */
00211 class UniteParallelAlgorithm : public BasicAlgorithmWithSettings
00212 {
00213 public:
00214     UniteParallelAlgorithm();
00215     ~UniteParallelAlgorithm();
00216     
00217     QString getName() const;
00218     
00219     int getInputCount() const { return 2; }
00220 
00221 protected:
00222     bool runInternal(const IAutomaton::TAutomataList &input,
00223                      QSharedPointer<IAutomaton> &result) const;
00224 };
00225 
00226 
00227 
00228 /*!
00229  * X36PJP, Algorithm 2.75 - Jazyky a preklady, prof. Ing. Borivoj Melichar, DrSc. 2003
00230  */
00231 class IntersectionParallelAlgorithm : public BasicAlgorithmWithSettings
00232 {
00233 public:
00234     IntersectionParallelAlgorithm();
00235     ~IntersectionParallelAlgorithm();
00236     
00237     QString getName() const;
00238     
00239     int getInputCount() const { return 2; }
00240 
00241 protected:
00242     bool runInternal(const IAutomaton::TAutomataList &input,
00243                      QSharedPointer<IAutomaton> &result) const;
00244 };
00245 
00246 
00247 class AlgorithmHolder : public QObject, public IAlgorithmHolder
00248 {
00249     Q_OBJECT
00250     Q_INTERFACES(IAlgorithmHolder)
00251 public:
00252     AlgorithmHolder();
00253     ~AlgorithmHolder();
00254 
00255     IAlgorithm::TAlgorithmList getAlgorithms() const;
00256 
00257     QString getVersion() const { return "2.0"; }
00258 
00259     QString getPluginName() const { return "Basic automata algorthms"; }
00260 
00261 protected:
00262 
00263 };
00264 
00265 #endif // _ALGORITHMS_H_11656963715131_

Generated on Tue Jan 4 2011 03:03:21 for Autoamata editor by  doxygen 1.7.0