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 277 2006-03-16 19:18:04Z lou $ 00053 */ 00054 00077 class CbcEventHandler 00078 { 00079 00080 public: 00081 00084 enum CbcEvent 00085 { 00086 node = 200, 00088 treeStatus, 00090 solution 00091 } ; 00092 00098 enum CbcAction 00099 { 00100 noAction = -1, 00102 stop = 0, 00106 restart, 00108 restartRoot 00109 } ; 00110 00113 typedef std::map<CbcEvent,CbcAction> eaMapPair ; 00114 00115 00118 00125 virtual CbcAction event(CbcEvent whichEvent) ; 00126 00128 00129 00132 00135 CbcEventHandler(const CbcModel *model = NULL) ; 00136 00139 CbcEventHandler(const CbcEventHandler &orig) ; 00140 00143 CbcEventHandler& operator=(const CbcEventHandler &rhs) ; 00144 00147 virtual CbcEventHandler* clone() const ; 00148 00151 virtual ~CbcEventHandler() ; 00152 00154 00157 00160 inline void setModel(CbcModel *model) 00161 { model_ = model ; } 00162 00165 inline const CbcModel* getModel() const 00166 { return model_ ; } ; 00167 00170 inline void setDfltAction(CbcAction action) 00171 { dfltAction_ = action ; } 00172 00175 inline void setAction(CbcEvent event, CbcAction action) 00176 { if (eaMap_ == 0) 00177 { eaMap_ = new eaMapPair ; } 00178 (*eaMap_)[event] = action ; } 00179 00181 00182 00183 protected: 00184 00190 00193 const CbcModel *model_ ; 00194 00197 CbcAction dfltAction_ ; 00198 00201 eaMapPair *eaMap_ ; 00202 00204 } ; 00205 00206 #endif