00001 00011 #ifndef _Constraint_h 00012 #define _Constraint_h 00013 00014 00015 // SYSTEM INCLUDES 00016 // 00017 00018 // PROJECT INCLUDES 00019 // 00020 00021 // LOCAL INCLUDES 00022 // 00023 #include "CountedPtr.h" 00024 #include "FunctionBase.h" 00025 00026 // FORWARD REFERENCES 00027 // 00028 00029 00030 class Constraint 00031 { 00032 public: 00033 00036 friend class ConstraintDialog; 00037 00040 enum ConstraintType { 00041 EQUAL, 00042 LESS_EQUAL_THAN, 00043 GREATER_EQUAL_THAN 00044 }; 00045 00048 // Ten typ jest wyjątkowo zdefiniowany nie tam, gdzie będzie używany, gdyż 00049 // kontener z ograniczeniami jest wykorzystywany w LinearProblem, 00050 // PenaltyFunction, ConstraintsDialog i *ConstraintsLayer. 00051 typedef vector<Constraint> Container; 00052 00053 // LIFECYCLE 00054 00057 Constraint(void); 00058 00059 00064 Constraint(const Constraint& from); 00065 00071 Constraint(std::auto_ptr<const FunctionBase> apFunction, ConstraintType type); 00072 00073 00076 virtual ~Constraint(void); 00077 00078 00079 // OPERATORS 00080 00087 Constraint& operator=(const Constraint& from); 00088 00089 // OPERATIONS 00090 // 00093 double Value(const ColumnVector& point) const; 00094 00101 bool IsValid(const ColumnVector& point, 00102 bool includeBoundary = true, 00103 double tolerance = 0.001) 00104 const; 00105 00108 Constraint DeepCopy() const; 00109 00110 // ACCESS 00111 00114 const FunctionBase& Function() const; 00115 00118 const ConstraintType Type() const; 00119 00122 wxString ToString(bool full = true) const; 00123 00124 00125 // INQUIRY 00126 00127 protected: 00129 CountedPtr<const FunctionBase> mcpFunction; 00130 ConstraintType mType; 00131 00132 public: 00133 class ProblemSetter 00134 { 00135 public: 00136 ProblemSetter(const ProblemBase* pProblem) 00137 : mpProblem(pProblem) 00138 { 00139 } 00140 00141 void operator()(const Constraint &constraint) 00142 { 00143 if (constraint.mcpFunction.Get() != NULL) 00144 { 00145 constraint.mcpFunction->SetProblem(mpProblem); 00146 } 00147 } 00148 00149 private: 00150 friend class Constraint; 00151 00152 const ProblemBase* mpProblem; 00153 }; 00154 00155 private: 00156 }; 00157 00158 // INLINE METHODS 00159 // 00160 00161 // EXTERNAL REFERENCES 00162 // 00163 00164 #endif // _Constraint_h_