InspIRCd  3.0
timer.h
1 /*
2  * InspIRCd -- Internet Relay Chat Daemon
3  *
4  * Copyright (C) 2013-2014 Attila Molnar <[email protected]>
5  * Copyright (C) 2013, 2017 Sadie Powell <[email protected]>
6  * Copyright (C) 2012 Robby <[email protected]>
7  * Copyright (C) 2009 Uli Schlachter <[email protected]>
8  * Copyright (C) 2009 Daniel De Graaf <[email protected]>
9  * Copyright (C) 2007-2008 Robin Burchell <[email protected]>
10  * Copyright (C) 2007, 2010 Craig Edwards <[email protected]>
11  * Copyright (C) 2007 Dennis Friis <[email protected]>
12  *
13  * This file is part of InspIRCd. InspIRCd is free software: you can
14  * redistribute it and/or modify it under the terms of the GNU General Public
15  * License as published by the Free Software Foundation, version 2.
16  *
17  * This program is distributed in the hope that it will be useful, but WITHOUT
18  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
20  * details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program. If not, see <http://www.gnu.org/licenses/>.
24  */
25 
26 
27 #pragma once
28 
29 class Module;
30 
41 class CoreExport Timer
42 {
45  time_t trigger;
46 
49  unsigned int secs;
50 
53  bool repeat;
54 
55  public:
60  Timer(unsigned int secs_from_now, bool repeating = false);
61 
64  virtual ~Timer();
65 
68  time_t GetTrigger() const
69  {
70  return trigger;
71  }
72 
77  void SetTrigger(time_t nexttrigger)
78  {
79  trigger = nexttrigger;
80  }
81 
84  void SetInterval(unsigned int interval);
85 
92  virtual bool Tick(time_t TIME) = 0;
93 
96  bool GetRepeat() const
97  {
98  return repeat;
99  }
100 
104  unsigned int GetInterval() const
105  {
106  return secs;
107  }
108 
114  {
115  repeat = false;
116  }
117 };
118 
123 class CoreExport TimerManager
124 {
125  typedef std::multimap<time_t, Timer*> TimerMap;
126 
129  TimerMap Timers;
130 
131  public:
135  void TickTimers(time_t TIME);
136 
140  void AddTimer(Timer *T);
141 
145  void DelTimer(Timer* T);
146 };
Timer::GetRepeat
bool GetRepeat() const
Definition: timer.h:96
Timer::GetInterval
unsigned int GetInterval() const
Definition: timer.h:104
TimerManager
Definition: timer.h:123
Timer::CancelRepeat
void CancelRepeat()
Definition: timer.h:113
Module
Definition: modules.h:247
Timer::SetTrigger
void SetTrigger(time_t nexttrigger)
Definition: timer.h:77
Timer
Definition: timer.h:41
Timer::GetTrigger
time_t GetTrigger() const
Definition: timer.h:68