Rev 1646 | Details | Compare with Previous | Last modification | View Log | SVN | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 1593 | runge | 1 | /* |
| 2 | * |
||
| 3 | * Copyright (C) 2010 Mattias Runge |
||
| 4 | * |
||
| 5 | * This program is free software; you can redistribute it and/or modify |
||
| 6 | * it under the terms of the GNU General Public License as published by |
||
| 7 | * the Free Software Foundation; either version 2 of the License, or |
||
| 8 | * (at your option) any later version. |
||
| 9 | * |
||
| 10 | * This program is distributed in the hope that it will be useful, |
||
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
| 13 | * GNU General Public License for more details. |
||
| 14 | * |
||
| 15 | * You should have received a copy of the GNU General Public License along |
||
| 16 | * with this program; if not, write to the Free Software Foundation, Inc., |
||
| 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
||
| 18 | * |
||
| 19 | */ |
||
| 20 | |||
| 21 | #ifndef TIMER_TIMER_H |
||
| 22 | #define TIMER_TIMER_H |
||
| 23 | |||
| 24 | #include <boost/asio.hpp> |
||
| 25 | #include <boost/signals2.hpp> |
||
| 26 | #include <boost/shared_ptr.hpp> |
||
| 27 | |||
| 1768 | runge | 28 | #include "logging/Logger.h" |
| 29 | |||
| 1595 | runge | 30 | #include "types.h" |
| 1593 | runge | 31 | |
| 32 | namespace atom { |
||
| 33 | namespace timer { |
||
| 34 | |||
| 35 | class Timer |
||
| 36 | { |
||
| 37 | public: |
||
| 38 | typedef boost::shared_ptr<Timer> Pointer; |
||
| 39 | |||
| 40 | typedef boost::signals2::signal<void(TimerId)> SignalOnTimeout; |
||
| 41 | |||
| 42 | Timer(boost::asio::io_service& io_service, TimerId id, unsigned int timeout, bool repeat); |
||
| 1646 | runge | 43 | Timer(boost::asio::io_service& io_service, TimerId id, std::string time); |
| 1593 | runge | 44 | virtual ~Timer(); |
| 45 | |||
| 46 | void ConnectSlots(const SignalOnTimeout::slot_type& slot_on_timeout); |
||
| 47 | |||
| 48 | TimerId GetId(); |
||
| 49 | bool GetRepeat(); |
||
| 50 | void Start(); |
||
| 51 | void Cancel(); |
||
| 52 | |||
| 53 | private: |
||
| 54 | boost::asio::deadline_timer instance_; |
||
| 55 | TimerId id_; |
||
| 1646 | runge | 56 | std::string time_; |
| 1593 | runge | 57 | unsigned int timeout_; |
| 58 | bool repeat_; |
||
| 59 | |||
| 1768 | runge | 60 | logging::Logger LOG; |
| 61 | |||
| 1593 | runge | 62 | SignalOnTimeout signal_on_timeout_; |
| 63 | |||
| 64 | void TimeoutHandler(const boost::system::error_code& error); |
||
| 65 | }; |
||
| 66 | |||
| 67 | }; // namespace timer |
||
| 68 | }; // namespace atom |
||
| 69 | |||
| 70 | #endif // TIMER_TIMER_H |