Skip to content

Commit

Permalink
added checks to dynamic_casts, fixes #119
Browse files Browse the repository at this point in the history
  • Loading branch information
mfrey committed Jul 31, 2014
1 parent d167903 commit bf1eaa4
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions src/time/StandardTimerProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,37 @@ StandardTimerProxy::~StandardTimerProxy(){ }

void StandardTimerProxy::run(unsigned long timeoutInMicroSeconds){
StandardClock* clock = dynamic_cast<StandardClock*>(Environment::getClock());
clock->scheduleTimer(timerIdentifier, timeoutInMicroSeconds);

if (clock) {
clock->scheduleTimer(timerIdentifier, timeoutInMicroSeconds);
} else {
/// DEBUG
std::cerr << "[StandardTimerProxy::run] dynamic cast failed!" << std::endl;
}
}

void StandardTimerProxy::interrupt(){
StandardClock* clock = dynamic_cast<StandardClock*>(Environment::getClock());
clock->interruptTimer(timerIdentifier);

if (clock) {
clock->interruptTimer(timerIdentifier);
} else {
/// DEBUG
std::cerr << "[StandardTimerProxy::interrupt] dynamic cast failed!" << std::endl;
}
}

bool StandardTimerProxy::equals(const Timer* otherTimer) const {
const StandardTimerProxy* otherStandardTimerProxy = dynamic_cast<const StandardTimerProxy*>(otherTimer);
if (otherStandardTimerProxy == nullptr) {
return false;
}
return (this->getHashValue() == otherStandardTimerProxy->getHashValue());

if (otherStandardTimerProxy) {
return (this->getHashValue() == otherStandardTimerProxy->getHashValue());
} else {
/// DEBUG
std::cerr << "[StandardTimerProxy::equals] dynamic cast failed!" << std::endl;
}

return false;
}


Expand Down

0 comments on commit bf1eaa4

Please sign in to comment.