mirror of
https://github.com/anope/anope.git
synced 2026-07-01 07:16:38 +02:00
Pretty large coding style cleanup, in source doc
cleanup, and allow protocol mods to depend on each other
This commit is contained in:
+5
-43
@@ -4,21 +4,14 @@
|
||||
* Contact us at team@anope.org
|
||||
*
|
||||
* Please read COPYING and README for further details.
|
||||
* Based on the original code of Epona by Lara.
|
||||
* Based on the original code of Services by Andy Church.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "services.h"
|
||||
#include "timers.h"
|
||||
|
||||
std::vector<Timer *> TimerManager::Timers;
|
||||
|
||||
/** Default constructor, initializes the triggering time
|
||||
* @param time_from_now The number of seconds from now to trigger the timer
|
||||
* @param now The time now
|
||||
* @param repeating Repeat this timer every time_from_now if this is true
|
||||
*/
|
||||
Timer::Timer(long time_from_now, time_t now, bool repeating)
|
||||
{
|
||||
trigger = now + time_from_now;
|
||||
@@ -29,48 +22,31 @@ Timer::Timer(long time_from_now, time_t now, bool repeating)
|
||||
TimerManager::AddTimer(this);
|
||||
}
|
||||
|
||||
/** Default destructor, removes the timer from the list
|
||||
*/
|
||||
Timer::~Timer()
|
||||
{
|
||||
TimerManager::DelTimer(this);
|
||||
}
|
||||
|
||||
/** Set the trigger time to a new value
|
||||
* @param t The new time
|
||||
*/
|
||||
void Timer::SetTimer(time_t t)
|
||||
{
|
||||
trigger = t;
|
||||
}
|
||||
|
||||
/** Retrieve the triggering time
|
||||
* @return The trigger time
|
||||
*/
|
||||
time_t Timer::GetTimer() const
|
||||
{
|
||||
return trigger;
|
||||
}
|
||||
|
||||
/** Returns true if the timer is set to repeat
|
||||
* @return Returns true if the timer is set to repeat
|
||||
*/
|
||||
bool Timer::GetRepeat() const
|
||||
{
|
||||
return repeat;
|
||||
}
|
||||
|
||||
/** Returns the time this timer was created
|
||||
* @return The time this timer was created
|
||||
*/
|
||||
time_t Timer::GetSetTime() const
|
||||
{
|
||||
return settime;
|
||||
}
|
||||
|
||||
/** Sets the interval between ticks
|
||||
* @param t The new interval
|
||||
*/
|
||||
void Timer::SetSecs(time_t t)
|
||||
{
|
||||
secs = t;
|
||||
@@ -80,37 +56,25 @@ void Timer::SetSecs(time_t t)
|
||||
TimerManager::AddTimer(this);
|
||||
}
|
||||
|
||||
/** Returns the interval between ticks
|
||||
* @return The interval
|
||||
*/
|
||||
long Timer::GetSecs() const
|
||||
{
|
||||
return secs;
|
||||
}
|
||||
|
||||
/** Add a timer to the list
|
||||
* @param T A Timer derived class to add
|
||||
*/
|
||||
void TimerManager::AddTimer(Timer *T)
|
||||
void TimerManager::AddTimer(Timer *t)
|
||||
{
|
||||
Timers.push_back(T);
|
||||
Timers.push_back(t);
|
||||
sort(Timers.begin(), Timers.end(), TimerManager::TimerComparison);
|
||||
}
|
||||
|
||||
/** Deletes a timer
|
||||
* @param T A Timer derived class to delete
|
||||
*/
|
||||
void TimerManager::DelTimer(Timer *T)
|
||||
void TimerManager::DelTimer(Timer *t)
|
||||
{
|
||||
std::vector<Timer *>::iterator i = std::find(Timers.begin(), Timers.end(), T);
|
||||
std::vector<Timer *>::iterator i = std::find(Timers.begin(), Timers.end(), t);
|
||||
|
||||
if (i != Timers.end())
|
||||
Timers.erase(i);
|
||||
}
|
||||
|
||||
/** Tick all pending timers
|
||||
* @param ctime The current time
|
||||
*/
|
||||
void TimerManager::TickTimers(time_t ctime)
|
||||
{
|
||||
while (Timers.size() && ctime > Timers.front()->GetTimer())
|
||||
@@ -129,8 +93,6 @@ void TimerManager::TickTimers(time_t ctime)
|
||||
}
|
||||
}
|
||||
|
||||
/** Compares two timers
|
||||
*/
|
||||
bool TimerManager::TimerComparison(Timer *one, Timer *two)
|
||||
{
|
||||
return one->GetTimer() < two->GetTimer();
|
||||
|
||||
Reference in New Issue
Block a user