00001 00006 #ifndef CbcEventHandler_H 00007 #define CbcEventHandler_H 00008 00045 #include <map> 00046 00047 /* May well already be declared, but can't hurt. */ 00048 00049 class CbcModel ; 00050 00051 /* 00052 cvs/svn: $Id: CbcEventHandler.hpp 741 2007-08-10 16:18:20Z forrest $ 00053 */ 00054 00077 class CbcEventHandler 00078 { 00079 00080 public: 00081 00084 enum CbcEvent 00085 { 00086 node = 200, 00088 treeStatus, 00090 solution, 00092 heuristicSolution 00093 } ; 00094 00100 enum CbcAction 00101 { 00102 noAction = -1, 00104 stop = 0, 00108 restart, 00110 restartRoot 00111 } ; 00112 00115 typedef std::map<CbcEvent,CbcAction> eaMapPair ; 00116 00117 00120 00127 virtual CbcAction event(CbcEvent whichEvent) ; 00128 00130 00131 00134 00137 CbcEventHandler(const CbcModel *model = NULL) ; 00138 00141 CbcEventHandler(const CbcEventHandler &orig) ; 00142 00145 CbcEventHandler& operator=(const CbcEventHandler &rhs) ; 00146 00149 virtual CbcEventHandler* clone() const ; 00150 00153 virtual ~CbcEventHandler() ; 00154 00156 00159 00162 inline void setModel(CbcModel *model) 00163 { model_ = model ; } 00164 00167 inline const CbcModel* getModel() const 00168 { return model_ ; } 00169 00172 inline void setDfltAction(CbcAction action) 00173 { dfltAction_ = action ; } 00174 00177 inline void setAction(CbcEvent event, CbcAction action) 00178 { if (eaMap_ == 0) 00179 { eaMap_ = new eaMapPair ; } 00180 (*eaMap_)[event] = action ; } 00181 00183 00184 00185 protected: 00186 00192 00195 const CbcModel *model_ ; 00196 00199 CbcAction dfltAction_ ; 00200 00203 eaMapPair *eaMap_ ; 00204 00206 } ; 00207 00208 #endif