TimeEvent.cpp 868 B

1234567891011121314151617181920212223242526272829303132
  1. /**
  2. * Copyright (c) 2012 committers of YAKINDU and others.
  3. * All rights reserved. This program and the accompanying materials
  4. * are made available under the terms of the Eclipse Public License v1.0
  5. * which accompanies this distribution, and is available at
  6. * http://www.eclipse.org/legal/epl-v10.html
  7. * Contributors:
  8. * m.muehlbrandt - initial API and implementation
  9. *
  10. */
  11. #include "TimeEvent.h"
  12. TimeEvent::TimeEvent(sc_eventid evid, sc_integer time_ms, sc_boolean periodic) :
  13. QObject() {
  14. timer = new QTimer();
  15. timer->setSingleShot(!periodic);
  16. this->evid = evid;
  17. connect(timer, SIGNAL(timeout()), this, SLOT(timeout()));
  18. timer->start(time_ms);
  19. }
  20. void TimeEvent::timeout() {
  21. emit timeout(evid);
  22. }
  23. TimeEvent::~TimeEvent() {
  24. disconnect(timer, SIGNAL(timeout()), this, SLOT(timeout()));
  25. timer->stop();
  26. delete timer;
  27. }