Changeset 1286 for branches/sandbox/Cbc/src/CbcEventHandler.cpp
 Timestamp:
 Nov 9, 2009 6:33:07 PM (10 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

branches/sandbox/Cbc/src/CbcEventHandler.cpp
r1271 r1286 15 15 16 16 // 17 // Default Constructor 17 // Default Constructor 18 18 // 19 19 20 20 CbcEventHandler::CbcEventHandler (CbcModel *model) 21 : model_(model),22 dfltAction_(CbcEventHandler::noAction),23 eaMap_(0)21 : model_(model), 22 dfltAction_(CbcEventHandler::noAction), 23 eaMap_(0) 24 24 { /* nothing more required */ } 25 25 26 26 // 27 // Copy constructor 27 // Copy constructor 28 28 // 29 29 /* 30 30 Here we need to clone the event/action map, if it exists 31 31 */ 32 CbcEventHandler::CbcEventHandler (const CbcEventHandler & rhs) 33 : model_(rhs.model_), 34 dfltAction_(rhs.dfltAction_), 35 eaMap_(0) 36 { if (rhs.eaMap_ != 0) 37 { eaMap_ = new eaMapPair(*rhs.eaMap_) ; } } 32 CbcEventHandler::CbcEventHandler (const CbcEventHandler & rhs) 33 : model_(rhs.model_), 34 dfltAction_(rhs.dfltAction_), 35 eaMap_(0) 36 { 37 if (rhs.eaMap_ != 0) { 38 eaMap_ = new eaMapPair(*rhs.eaMap_) ; 39 } 40 } 38 41 39 42 // 40 // Assignment operator 43 // Assignment operator 41 44 // 42 45 CbcEventHandler& 43 CbcEventHandler::operator=(const CbcEventHandler & rhs)46 CbcEventHandler::operator=(const CbcEventHandler & rhs) 44 47 { 45 if (this != &rhs) { 46 model_ = rhs.model_ ; 47 dfltAction_ = rhs.dfltAction_ ; 48 if (rhs.eaMap_ != 0) 49 { eaMap_ = new eaMapPair(*rhs.eaMap_) ; } 50 else 51 { eaMap_ = 0 ; } } 52 return (*this) ; } 48 if (this != &rhs) { 49 model_ = rhs.model_ ; 50 dfltAction_ = rhs.dfltAction_ ; 51 if (rhs.eaMap_ != 0) { 52 eaMap_ = new eaMapPair(*rhs.eaMap_) ; 53 } else { 54 eaMap_ = 0 ; 55 } 56 } 57 return (*this) ; 58 } 53 59 54 60 // 55 61 // Clone 56 62 // 57 CbcEventHandler* 63 CbcEventHandler* 58 64 CbcEventHandler::clone() const 59 { return (new CbcEventHandler(*this)) ; } 65 { 66 return (new CbcEventHandler(*this)) ; 67 } 60 68 61 69 // 62 // Destructor 70 // Destructor 63 71 // 64 72 /* … … 66 74 */ 67 75 CbcEventHandler::~CbcEventHandler () 68 { if (eaMap_ != 0) delete eaMap_ ; } 76 { 77 if (eaMap_ != 0) delete eaMap_ ; 78 } 69 79 70 80 … … 78 88 Otherwise return the default action. 79 89 */ 80 { if (eaMap_ != 0) 81 { eaMapPair::iterator entry = eaMap_>find(event) ; 82 if (entry != eaMap_>end()) 83 { return (entry>second) ; } 84 else 85 { return (dfltAction_) ; } } 86 else 87 { return (dfltAction_) ; } } 90 { 91 if (eaMap_ != 0) { 92 eaMapPair::iterator entry = eaMap_>find(event) ; 93 if (entry != eaMap_>end()) { 94 return (entry>second) ; 95 } else { 96 return (dfltAction_) ; 97 } 98 } else { 99 return (dfltAction_) ; 100 } 101 } 88 102
Note: See TracChangeset
for help on using the changeset viewer.