source: trunk/include/ClpEventHandler.hpp @ 348

Last change on this file since 348 was 348, checked in by forrest, 17 years ago

New status 5

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.1 KB
Line 
1// Copyright (C) 2004, International Business Machines
2// Corporation and others.  All Rights Reserved.
3#ifndef ClpEventHandler_H
4#define ClpEventHandler_H
5
6#include "ClpSimplex.hpp"
7
8/** Base class for Clp event handling
9   
10This is just here to allow for event handling.  By event I mean a Clp event
11e.g. end of values pass.
12
13One use would be to let a user handle a system event e.g. Control-C.  This could be done
14by deriving a class MyEventHandler which knows about such events.  If one occurs
15MyEventHandler::event() could clear event status and return 3 (stopped).
16
17Clp would then return to user code.
18
19As it is called every iteration this should be fine grained enough.
20   
21*/
22
23class ClpEventHandler  {
24 
25public:
26  /** enums for what sort of event.
27
28      These will also be returned in ClpModel::secondaryStatus() as int
29  */
30  enum Event {
31    endOfIteration = 100, // used to set secondary status
32    endOfFactorization,
33    endOfValuesPass
34  };
35  /**@name Virtual method that the derived classe should provide.
36   The base class instance does nothing and as event() is only useful method
37   it would not be very useful NOT providing one!
38  */
39  //@{
40  /** This can do whatever it likes.  If return code -1 then carries on
41      if 0 sets ClpModel::status() to 5 (stopped by event) and will return to user.
42      At present if <-1 carries on and if >0 acts as if 0 - this may change
43  */
44  virtual int event(Event whichEvent);
45  //@}
46 
47 
48  /**@name Constructors, destructor */
49
50  //@{
51  /** Default constructor. */
52  ClpEventHandler(ClpSimplex * model = NULL);
53  /** Destructor */
54  virtual ~ClpEventHandler();
55  // Copy
56  ClpEventHandler(const ClpEventHandler&);
57  // Assignment
58  ClpEventHandler& operator=(const ClpEventHandler&);
59  /// Clone
60  virtual ClpEventHandler * clone() const;
61
62  //@}
63 
64  /**@name Sets/gets */
65
66  //@{
67  /** set model. */
68  void setSimplex(ClpSimplex * model);
69  /// Get model
70  inline ClpSimplex * simplex() const
71  { return model_;};
72  //@}
73 
74 
75protected:
76  /**@name Data members
77     The data members are protected to allow access for derived classes. */
78  //@{
79  /// Pointer to simplex
80  ClpSimplex * model_;
81  //@}
82};
83#endif
Note: See TracBrowser for help on using the repository browser.