CbcEventHandler.hpp
Go to the documentation of this file.
1 
6 #ifndef CbcEventHandler_H
7 #define CbcEventHandler_H
8 
45 #include <map>
46 
47 /* May well already be declared, but can't hurt. */
48 
49 class CbcModel ;
50 
51 /*
52  cvs/svn: $Id: CbcEventHandler.hpp 1432 2010-02-07 19:33:53Z bjarni $
53 */
54 
78 
79 public:
80 
83  enum CbcEvent {
84  node = 200,
97  } ;
98 
104  enum CbcAction {
105  noAction = -1,
107  stop = 0,
118 
119  } ;
120 
123  typedef std::map<CbcEvent, CbcAction> eaMapPair ;
124 
125 
128 
135  virtual CbcAction event(CbcEvent whichEvent) ;
136 
138 
139 
142 
145  CbcEventHandler(CbcModel *model = 0) ;
146 
149  CbcEventHandler(const CbcEventHandler &orig) ;
150 
154 
157  virtual CbcEventHandler* clone() const ;
158 
161  virtual ~CbcEventHandler() ;
162 
164 
167 
170  inline void setModel(CbcModel *model) {
171  model_ = model ;
172  }
173 
176  inline const CbcModel* getModel() const {
177  return model_ ;
178  }
179 
182  inline void setDfltAction(CbcAction action) {
183  dfltAction_ = action ;
184  }
185 
188  inline void setAction(CbcEvent event, CbcAction action) {
189  if (eaMap_ == 0) {
190  eaMap_ = new eaMapPair ;
191  }
192  (*eaMap_)[event] = action ;
193  }
194 
196 
197 
198 protected:
199 
205 
209 
213 
217 
219 } ;
220 
221 #endif
222 
std::map< CbcEvent, CbcAction > eaMapPair
Data type for event/action pairs.
virtual CbcAction event(CbcEvent whichEvent)
Return the action to be taken for an event.
CbcModel * model_
Pointer to associated CbcModel.
void setAction(CbcEvent event, CbcAction action)
Set the action code associated with an event.
CbcAction dfltAction_
Default action.
Base class for Cbc event handling.
CbcAction
Action codes returned by the event handler.
virtual CbcEventHandler * clone() const
Clone (virtual) constructor.
eaMapPair * eaMap_
Pointer to a map that holds non-default event/action pairs.
CbcEventHandler & operator=(const CbcEventHandler &rhs)
Assignment.
const CbcModel * getModel() const
Get model.
CbcEventHandler(CbcModel *model=0)
Default constructor.
virtual ~CbcEventHandler()
Destructor.
void setModel(CbcModel *model)
Set model.
void setDfltAction(CbcAction action)
Set the default action.
CbcEvent
Events known to cbc.
Simple Branch and bound class.
Definition: CbcModel.hpp:98