This repository has been archived on 2023-10-09. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
blender-archive/intern/ghost/intern/GHOST_TimerManager.h
Nicholas Rishel f3ec0d8e58 Replace Ghost integrals with stdint fixed width integers.
Also replace integer with bool in Ghost API when only used as boolean,
and uint8* with char* in Ghost API when variable is a string.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D11617

Signed-off-by: Nicholas Rishel <rishel.nick@gmail.com>
2021-07-05 11:00:45 -07:00

114 lines
3.0 KiB
C++

/*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*/
/** \file
* \ingroup GHOST
* Declaration of GHOST_TimerManager class.
*/
#pragma once
#include <vector>
#include "GHOST_Types.h"
class GHOST_TimerTask;
/**
* Manages a list of timer tasks.
* Timer tasks added are owned by the manager.
* Don't delete timer task objects.
*/
class GHOST_TimerManager {
public:
/**
* Constructor.
*/
GHOST_TimerManager();
/**
* Destructor.
*/
~GHOST_TimerManager();
/**
* Returns the number of timer tasks.
* \return The number of events on the stack.
*/
uint32_t getNumTimers();
/**
* Returns whether this timer task ins in our list.
* \return Indication of presence.
*/
bool getTimerFound(GHOST_TimerTask *timer);
/**
* Adds a timer task to the list.
* It is only added when it not already present in the list.
* \param timer: The timer task added to the list.
* \return Indication as to whether addition has succeeded.
*/
GHOST_TSuccess addTimer(GHOST_TimerTask *timer);
/**
* Removes a timer task from the list.
* It is only removed when it is found in the list.
* \param timer: The timer task to be removed from the list.
* \return Indication as to whether removal has succeeded.
*/
GHOST_TSuccess removeTimer(GHOST_TimerTask *timer);
/**
* Finds the soonest time the next timer would fire.
* \return The soonest time the next timer would fire,
* or GHOST_kFireTimeNever if no timers exist.
*/
uint64_t nextFireTime();
/**
* Checks all timer tasks to see if they are expired and fires them if needed.
* \param time: The current time.
* \return True if any timers were fired.
*/
bool fireTimers(uint64_t time);
/**
* Checks this timer task to see if they are expired and fires them if needed.
* \param time: The current time.
* \param task: The timer task to check and optionally fire.
* \return True if the timer fired.
*/
bool fireTimer(uint64_t time, GHOST_TimerTask *task);
protected:
/**
* Deletes all timers.
*/
void disposeTimers();
typedef std::vector<GHOST_TimerTask *> TTimerVector;
/** The list with event consumers. */
TTimerVector m_timers;
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("GHOST:GHOST_TimerManager")
#endif
};