source: branches/devel/Cbc/src/CbcEventHandler.cpp @ 417

Last change on this file since 417 was 310, checked in by andreasw, 14 years ago

first commit for autotools conversion to be able to move more files

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.7 KB
Line 
1// Copyright (C) 2004, International Business Machines
2// Corporation and others.  All Rights Reserved.
3
4// Shamelessly adapted from ClpEventHandler.
5
6#include "CoinPragma.hpp"
7
8#include "CbcEventHandler.hpp"
9
10
11//#############################################################################
12// Constructors / Destructor / Assignment
13//#############################################################################
14
15//-------------------------------------------------------------------
16// Default Constructor
17//-------------------------------------------------------------------
18
19CbcEventHandler::CbcEventHandler (const CbcModel *model)
20  : model_(model),
21    dfltAction_(CbcEventHandler::noAction),
22    eaMap_(0)
23{  /* nothing more required */ }
24
25//-------------------------------------------------------------------
26// Copy constructor
27//-------------------------------------------------------------------
28/*
29  Here we need to clone the event/action map, if it exists
30*/
31CbcEventHandler::CbcEventHandler (const CbcEventHandler & rhs) 
32  : model_(rhs.model_),
33    dfltAction_(rhs.dfltAction_),
34    eaMap_(0)
35{ if (rhs.eaMap_ != 0)
36  { eaMap_ = new eaMapPair(*rhs.eaMap_) ; } }
37
38//----------------------------------------------------------------
39// Assignment operator
40//-------------------------------------------------------------------
41CbcEventHandler&
42CbcEventHandler::operator=(const CbcEventHandler& rhs)
43{
44  if (this != &rhs) {
45    model_ = rhs.model_ ;
46    dfltAction_ = rhs.dfltAction_ ;
47    if (rhs.eaMap_ != 0)
48    { eaMap_ = new eaMapPair(*rhs.eaMap_) ; }
49    else
50    { eaMap_ = 0 ; } }
51  return (*this) ; }
52
53//----------------------------------------------------------------
54// Clone
55//-------------------------------------------------------------------
56CbcEventHandler* 
57CbcEventHandler::clone() const
58{ return (new CbcEventHandler(*this)) ; }
59
60//-------------------------------------------------------------------
61// Destructor
62//-------------------------------------------------------------------
63/*
64  Take care to free the event/action map.
65*/
66CbcEventHandler::~CbcEventHandler ()
67{ if (eaMap_ != 0) delete eaMap_ ; }
68
69
70//-------------------------------------------------------------------
71// event() -- return the action for an event.
72//-------------------------------------------------------------------
73
74CbcEventHandler::CbcAction CbcEventHandler::event(CbcEvent event)
75/*
76  If an event/action map exists and contains an entry for the event, return it.
77  Otherwise return the default action.
78*/
79{ if (eaMap_ != 0)
80  { eaMapPair::iterator entry = eaMap_->find(event) ;
81    if (entry != eaMap_->end())
82    { return (entry->second) ; }
83    else
84    { return (dfltAction_) ; } }
85  else
86  { return (dfltAction_) ; } }
87
Note: See TracBrowser for help on using the repository browser.