ProblemBase.h

00001 #ifndef _ProblemBase_h
00002 #define _ProblemBase_h
00003 
00004 
00005 // SYSTEM INCLUDES
00006 //
00007 
00008 // PROJECT INCLUDES
00009 //
00010 
00011 // LOCAL INCLUDES
00012 //
00013 #include "CountedPtr.h"
00014 #include "FunctionBase.h"
00015 #include "Method.h"
00016 #include "Result.h"
00017 #include "VariableNames.h"
00018 
00019 // FORWARD REFERENCES
00020 //
00021 
00024 typedef unsigned    ProblemIdType;
00025 
00036 class ProblemBase
00037 {
00038     // Ze względu na wywoływanie FunctionBase::SetProblem w walidatorze.
00039     friend class FunctionValidator;
00040 
00041 public:
00042 // LIFECYCLE
00043 
00051     ProblemBase(std::auto_ptr<const FunctionBase>  apFunction,
00052                 std::auto_ptr<      VariableNames> apVariables);
00053 
00056     virtual ~ProblemBase(void);
00057 
00058 
00059 // OPERATORS
00060 
00061 // OPERATIONS
00062 
00068     virtual std::auto_ptr<Result>       StartSolve() const
00069         throw(OptimizationError);
00070 
00071 //    /** Tworzy wektor do przechowywania wartości zmiennych.
00072 //     *
00073 //     * @return Wektor kolumnowy o długości równej ilości zmiennych
00074 //     * (niezainicjowane wartości).
00075 //     */ // TODO: nazwa? W końcu Create powinno zwaracać auto_ptr
00076 //    ColumnVector                        CreateVector() const;
00077 
00080     virtual std::auto_ptr<ProblemBase>  Clone() const = 0;
00081 
00084     virtual wxString                    ToString() const = 0;
00085 
00086 // ACCESS
00087 
00094     void                    SetMethod(std::auto_ptr<const Method> apMethod);
00095 
00103     void                    SetMethod(std::auto_ptr<      Method> apMethod);
00104 
00113     virtual void            SetFunction(
00114                                 auto_ptr<FunctionBase>  cpFunction,
00115                                 auto_ptr<VariableNames> cpVariables);
00116 
00119     // Niestety, mogłem albo zamienić Method na MethodBase w cały programie albo
00120     // dać tutaj inną nazwę niż Method..
00121     const Method&               UsedMethod() const;
00122 
00127     const FunctionBase&         Function() const;
00128 
00136     virtual const FunctionBase& BaseFunction() const;
00137 
00142     const VariableNames&        Variables() const;
00143 
00146     int                         VariableCount() const;
00147 
00150     virtual wxString            Name() const = 0;
00151 
00154     static const vector<ProblemBase*>&  Problems();
00155 
00158     static ProblemBase*         GetById(ProblemIdType id);
00159 
00167     static ProblemIdType             ClassId();
00168 
00171     virtual ProblemIdType            Id() const = 0;
00172 
00173 // INQUIRY
00174 
00175 protected:
00180     ProblemBase(bool doRegister = false);
00181 
00184     ProblemBase(const ProblemBase& from);
00185 
00188     static ProblemIdType    GenerateId();
00189 
00190     // TODO: teraz to już może być auto_ptr i zwykła zmienna na stosie.
00191     CountedPtr<const FunctionBase>  mcpFunction;  
00192     CountedPtr<const VariableNames> mcpVariables; 
00193     std::auto_ptr<const Method>     mapMethod;    
00194 
00195 private:
00196 
00199     virtual std::auto_ptr<Result> Solve() const throw(OptimizationError);
00200 
00201 
00204     static vector<ProblemBase*>& rProblems();
00205 
00211     static bool CompareId(const ProblemBase* pProblem, ProblemIdType id);
00212 };
00213 
00214 // INLINE METHODS
00215 //
00216 
00217 // EXTERNAL REFERENCES
00218 //
00219 
00220 #endif  // _ProblemBase_h_

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