Method.h

00001 #ifndef _Method_h
00002 #define _Method_h
00003 
00004 
00005 // SYSTEM INCLUDES
00006 //
00007 
00008 // PROJECT INCLUDES
00009 //
00010 
00011 // LOCAL INCLUDES
00012 //
00013 #include "Error.h"
00014 #include "Observable.h"
00015 #include "OptimizationError.h"
00016 #include "Result.h"
00017 #include "StopConditionBase.h"
00018 
00019 // FORWARD REFERENCES
00020 //
00021 class ProblemBase;
00022 
00023 typedef unsigned    MethodIdType;
00024 
00035 class Method
00036     : public Observable
00037 {
00038 public:
00039 // LIFECYCLE
00040 
00041 
00044     virtual ~Method(void);
00045 
00046 
00047 // OPERATORS
00048 
00049 // OPERATIONS
00050 
00061     std::auto_ptr<Result>   StartOptimize(const ProblemBase& problem) const
00062         throw(OptimizationError);
00063 
00064 
00067     virtual std::auto_ptr<Method>       Clone() const = 0;
00068 
00069 
00075     void                                Abort() const;
00076 
00082     void                                Prestart() const;
00083 
00091     static void                         Init();
00092 
00093     virtual void                        UpdateStartingConditions
00094                                             (const Result* result) const = 0;
00095 
00096     virtual void                        ResetStartingConditions() const = 0;
00097 
00098 // ACCESS
00099 
00102     static const vector<Method*>&   Methods();
00103 
00113     static Method*                  GetById(MethodIdType id);
00114 
00117     static MethodIdType             ClassId();
00118 
00121     virtual const wxString&         Name() const = 0;
00122 
00125     // TODO: przerobić na abstrakcyjną, jak będą gotowe we wszystkich metodach.
00126     virtual wxString                ToString(bool standalone = true) const;
00127                                                                 // = 0;
00128 
00131     virtual MethodIdType            Id() const = 0;
00132 
00133 // INQUIRY
00134 
00137     virtual bool            CanHandle(const ProblemBase *pProblem) const = 0;
00138 
00139 
00142     virtual StopConditions  AllowedStopConditions() const;
00143 
00144 protected:
00145 
00160     void                    NotifyYield() const throw(Error);
00161 
00166     Method(void);
00167 
00172     static MethodIdType        GenerateId();
00173 
00174     virtual wxString&               rName() = 0;
00175 
00178     enum {
00179         ABSTRACT_METHOD_ID = 1
00180     };
00181 
00182 private:
00194     virtual std::auto_ptr<Result>   Optimize(const ProblemBase& problem) const
00195         throw(OptimizationError) = 0;
00196 
00197 
00198     mutable bool        mAbort;         
00199     mutable wxLongLong  mPreviousTime;  
00200 
00201     // STATIC
00202 
00205     static bool CompareName(const Method* pMethod, const wxString* pName);
00206 
00209     static bool CompareId(const Method* pMethod, MethodIdType id);
00210 
00214     static bool NameLesser(const Method* method1, const Method* method2);
00215 
00218     static vector<Method*>& rMethods();
00219 
00220 };
00221 
00222 // INLINE METHODS
00223 //
00224 
00225 // EXTERNAL REFERENCES
00226 //
00227 
00228 #endif  // _Method_h_

Wygenerowano Fri Sep 29 21:04:47 2006 dla EduOptim2 programem  doxygen 1.4.6