BVB Source Codes

CRYENGINE Show StatisticsHelpers.h Source code

Return Download CRYENGINE: download StatisticsHelpers.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:   StatisticsHelpers.h
  5. //  Version:     v1.00
  6. //  Created:     04/03/2010 by Sergey Mikhtonyuk
  7. //  Description:
  8. // -------------------------------------------------------------------------
  9. //  History:
  10. //
  11. ////////////////////////////////////////////////////////////////////////////
  12. #ifndef   _STATISTICSHELPERS_H__
  13. #define   _STATISTICSHELPERS_H__
  14.  
  15. #pragma once
  16.  
  17. #define STATS_MODE_CVAR 1
  18.  
  19. #include <CryScriptSystem/IScriptSystem.h>
  20. #include <CryGame/IGameStatistics.h>
  21.  
  22. //////////////////////////////////////////////////////////////////////////
  23.  
  24. class CGameStatistics;
  25. class CScriptBind_GameStatistics;
  26.  
  27. //////////////////////////////////////////////////////////////////////////
  28.  
  29. class CStatsContainer : public IStatsContainer
  30. {
  31.         typedef std::vector<std::pair<CTimeValue, SStatAnyValue>> TEventTrack;
  32.         typedef std::vector<TEventTrack>                          TEventTracks;
  33.         typedef std::vector<SStatAnyValue>                        TStateTrack;
  34.  
  35. public:
  36.         CStatsContainer() : m_refCount(0), m_unloadableMemUsage(0) {}
  37.         virtual void   Init(size_t numEvents, size_t numStates);
  38.         virtual void   AddEvent(size_t eventID, const CTimeValue& time, const SStatAnyValue& val);
  39.         virtual void   AddState(size_t stateID, const SStatAnyValue& val);
  40.         virtual size_t GetEventTrackLength(size_t eventID) const;
  41.         virtual void   GetEventInfo(size_t eventID, size_t idx, CTimeValue& outTime, SStatAnyValue& outParam) const;
  42.         virtual void   GetStateInfo(size_t stateID, SStatAnyValue& outValue) const;
  43.         virtual void   Clear();
  44.         virtual bool   IsEmpty() const;
  45.         virtual void   GetMemoryStatistics(ICrySizer* pSizer);
  46.         virtual void   AddRef();
  47.         virtual void   Release();
  48.  
  49. private:
  50.         CStatsContainer(const CStatsContainer& other);
  51.         CStatsContainer& operator=(const CStatsContainer& rhs);
  52.  
  53. private:
  54.         TEventTracks m_events;
  55.         TStateTrack  m_states;
  56.         int          m_refCount;
  57.         size_t       m_unloadableMemUsage;
  58. };
  59.  
  60. //////////////////////////////////////////////////////////////////////////
  61.  
  62. class CDefaultStorageFactory : public IStatsStorageFactory
  63. {
  64. public:
  65.         virtual IStatsContainer* CreateContainer();
  66. };
  67.  
  68. //////////////////////////////////////////////////////////////////////////
  69.  
  70. class CStatsTracker : public IStatsTracker
  71. {
  72. public:
  73.         CStatsTracker(const SNodeLocator& locator, CGameStatistics* pGameStats, IScriptTable* pTable = 0);
  74.         ~CStatsTracker();
  75.         virtual void             StateValue(size_t stateID, const SStatAnyValue& value);
  76.         virtual void             Event(size_t eventID, const SStatAnyValue& value);
  77.         virtual IStatsContainer* GetStatsContainer();
  78.         virtual void             GetMemoryStatistics(ICrySizer* pSizer);
  79.  
  80.         SNodeLocator             GetLocator() const;
  81.         IScriptTable*            GetScriptTable() const;
  82.  
  83.         void                     GetMemoryUsage(ICrySizer* pSizer) const {}
  84. private:
  85.         CStatsTracker(const CStatsTracker& other);
  86.         CStatsTracker& operator=(const CStatsTracker& rhs);
  87.  
  88. private:
  89.         IStatsContainerPtr m_container;
  90.         SNodeLocator       m_locator;
  91.         SmartScriptTable   m_scriptTable;
  92.         CGameStatistics*   m_pGameStats;
  93. };
  94.  
  95. //////////////////////////////////////////////////////////////////////////
  96.  
  97. struct SDeadStatNode
  98. {
  99.         typedef std::vector<SDeadStatNode*> TChildren;
  100.  
  101.         SNodeLocator   locator;
  102.         CStatsTracker* tracker;
  103.         TChildren      children;
  104.         mutable size_t cachedMemoryStats;
  105.  
  106.         SDeadStatNode(const SNodeLocator& loc, CStatsTracker* track);
  107.         ~SDeadStatNode();
  108.         size_t GetMemoryStatistics() const;
  109.         void   GetMemoryStatistics(ICrySizer* pSizer) const;
  110.  
  111. private:
  112.         SDeadStatNode(const SDeadStatNode& other);
  113.         SDeadStatNode& operator=(const SDeadStatNode& rhs);
  114. };
  115.  
  116. //////////////////////////////////////////////////////////////////////////
  117.  
  118. struct SScopeData
  119. {
  120.         typedef std::map<SNodeLocator, CStatsTracker*> TElements;
  121.         typedef std::vector<SDeadStatNode*>            TDeadNodes;
  122.  
  123.         SNodeLocator   locator;
  124.         CStatsTracker* tracker;
  125.         TElements      elements;
  126.         TDeadNodes     deadNodes;
  127.  
  128.         SScopeData(SNodeLocator _locator, CStatsTracker* _tracker);
  129.         void GetMemoryStatistics(ICrySizer* pSizer) const;
  130. };
  131.  
  132. //////////////////////////////////////////////////////////////////////////
  133.  
  134. class CStatRegistry
  135. {
  136.         typedef std::vector<SGameStatDesc> TStatRegistry;
  137.         typedef std::map<string, size_t>   TStatMap;
  138.  
  139. public:
  140.         CStatRegistry() {}
  141.         bool                 Register(const SGameStatDesc statDescs[], size_t numStats);
  142.         size_t               Register(const char* scriptName, const char* serializeName);
  143.         size_t               Count() const;
  144.         size_t               GetID(const char* scriptName) const;
  145.         const SGameStatDesc* GetDesc(size_t statID) const;
  146.         void                 GetMemoryStatistics(ICrySizer* pSizer) const;
  147.  
  148. private:
  149.         CStatRegistry(const CStatRegistry& other);
  150.         CStatRegistry& operator=(const CStatRegistry& rhs);
  151.         bool           ValidateRegistration(const SGameStatDesc* statDescs, size_t numStats);
  152.  
  153.         TStatRegistry m_statRegistry;
  154.         TStatMap      m_statMap;
  155. };
  156.  
  157. //////////////////////////////////////////////////////////////////////////
  158.  
  159. class CElemRegistry
  160. {
  161.         typedef std::vector<SGameElementDesc> TElemRegistry;
  162.         typedef std::map<string, size_t>      TElemMap;
  163.  
  164. public:
  165.         CElemRegistry() {}
  166.         bool                    Register(const SGameElementDesc elemDescs[], size_t numElems);
  167.         size_t                  Count() const;
  168.         size_t                  GetID(const char* scriptName) const;
  169.         const SGameElementDesc* GetDesc(size_t statID) const;
  170.         void                    GetMemoryStatistics(ICrySizer* pSizer) const;
  171.  
  172. private:
  173.         CElemRegistry(const CElemRegistry& other);
  174.         CElemRegistry& operator=(const CElemRegistry& rhs);
  175.         bool           ValidateRegistration(const SGameElementDesc* elemDescs, size_t numElems);
  176.  
  177.         TElemRegistry m_elemRegistry;
  178.         TElemMap      m_elemMap;
  179. };
  180.  
  181. //////////////////////////////////////////////////////////////////////////
  182.  
  183. class CGameScopes
  184. {
  185. public:
  186.         typedef std::vector<SGameScopeDesc> TScopeRegistry;
  187.         typedef std::map<string, size_t>    TScopeMap;
  188.         typedef std::vector<SScopeData>     TScopeStack;
  189.  
  190.         CGameScopes();
  191.  
  192.         bool                  RegisterGameScopes(const SGameScopeDesc scopeDescs[], size_t numScopes);
  193.         const SGameScopeDesc* GetScopeDesc(size_t id) const;
  194.         const SGameScopeDesc* GetScopeDesc(const char* scriptName) const;
  195.  
  196.         CStatsTracker*        PushGameScope(size_t scopeID, uint32 timestamp, CGameStatistics* gameStatistics);
  197.         SDeadStatNode*        PopGameScope();
  198.  
  199.         size_t                FindScopePos(size_t scopeID) const;
  200.         size_t                GetRegisteredCount() const;
  201.         size_t                GetStackSize() const;
  202.  
  203.         const SScopeData& GetScopeAt(size_t pos) const;
  204.         SScopeData&       GetScopeAt(size_t pos);
  205.         const SScopeData& GetLastScope() const;
  206.         SScopeData&       GetLastScope();
  207.  
  208.         void              GetMemoryStatistics(ICrySizer* pSizer) const;
  209.  
  210. private:
  211.         CGameScopes(const CGameScopes& other);
  212.         CGameScopes& operator=(const CGameScopes& rhs);
  213.         bool         ValidateScopes(const SGameScopeDesc scopeDescs[], size_t numScopes);
  214.         void         GrowRegistry(size_t numScopes);
  215.         void         InsertScopesInRegistry(const SGameScopeDesc* scopeDescs, size_t numScopes);
  216.  
  217. private:
  218.         TScopeRegistry m_scopeRegistry;
  219.         TScopeMap      m_scopeMap;
  220.         TScopeStack    m_scopeStack;
  221. };
  222.  
  223. //////////////////////////////////////////////////////////////////////////
  224.  
  225. #endif // __STATISTICSHELPERS_H__
  226.  
downloadStatisticsHelpers.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