BVB Source Codes

CRYENGINE Show TimeOfDayScheduler.h Source code

Return Download CRYENGINE: download TimeOfDayScheduler.h Source code - Download CRYENGINE Source code - Type:.h
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. // -------------------------------------------------------------------------
  4. //  File name:   TimeOfDayScheduler.h
  5. //  Version:     v1.00
  6. //  Created:     27/02/2007 by AlexL
  7. //  Compilers:   Visual Studio.NET
  8. //  Description: TimeOfDayScheduler
  9. // -------------------------------------------------------------------------
  10. //  History:
  11. //
  12. ////////////////////////////////////////////////////////////////////////////
  13.  
  14. #ifndef __TIMEOFDAYSCHEDULER_H__
  15. #define __TIMEOFDAYSCHEDULER_H__
  16.  
  17. #pragma once
  18.  
  19. class CTimeOfDayScheduler
  20. {
  21. public:
  22.         // timer id
  23.         typedef int TimeOfDayTimerId;
  24.         static const int InvalidTimerId = -1;
  25.  
  26.         // timer id, user data, current time of day (not scheduled time of day!)
  27.         typedef void (* TimeOfDayTimerCallback)(TimeOfDayTimerId, void*, float);
  28.  
  29.         CTimeOfDayScheduler();
  30.         ~CTimeOfDayScheduler();
  31.  
  32.         void Reset();  // clears all scheduled timers
  33.         void Update(); // updates (should be called every frame, internally updates in intervalls)
  34.  
  35.         void GetMemoryStatistics(ICrySizer* s)
  36.         {
  37.                 s->Add(*this);
  38.                 s->AddContainer(m_entries);
  39.         }
  40.  
  41.         TimeOfDayTimerId AddTimer(float time, TimeOfDayTimerCallback callback, void* pUserData);
  42.         void*            RemoveTimer(TimeOfDayTimerId id); // returns user data
  43.  
  44. protected:
  45.         struct SEntry
  46.         {
  47.                 SEntry(TimeOfDayTimerId id, float time, TimeOfDayTimerCallback callback, void* pUserData)
  48.                 {
  49.                         this->id = id;
  50.                         this->time = time;
  51.                         this->callback = callback;
  52.                         this->pUserData = pUserData;
  53.                 }
  54.  
  55.                 bool operator==(const TimeOfDayTimerId& otherId) const
  56.                 {
  57.                         return id == otherId;
  58.                 }
  59.  
  60.                 bool operator<(const SEntry& other) const
  61.                 {
  62.                         return time < other.time;
  63.                 }
  64.  
  65.                 bool operator<(const float& otherTime) const
  66.                 {
  67.                         return time < otherTime;
  68.                 }
  69.  
  70.                 TimeOfDayTimerId       id;          // 4 bytes
  71.                 float                  time;        // 4 bytes
  72.                 TimeOfDayTimerCallback callback;    // 4/8 bytes
  73.                 void*                  pUserData;   // 4/8 bytes
  74.                 //                                   = 32/48 bytes
  75.         };
  76.  
  77.         typedef std::vector<SEntry> TEntries;
  78.         TEntries         m_entries;
  79.         TimeOfDayTimerId m_nextId;
  80.         float            m_lastTime;
  81.         bool             m_bForceUpdate;
  82. };
  83.  
  84. #endif // __TIMEOFDAYSCHEDULER_H__
  85.  
downloadTimeOfDayScheduler.h Source code - Download CRYENGINE Source code
Related Source Codes/Software:
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top