Process.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #ifndef Prozess_H
  2. #define Prozess_H
  3. #include "OperatingSystem.h"
  4. #include "ReferenceCounter.h"
  5. #ifdef WIN32
  6. # pragma comment(lib, "Psapi.lib")
  7. #endif
  8. namespace Framework
  9. {
  10. #ifdef WIN32
  11. struct MemoryInfo; //! from this file
  12. #endif
  13. class Process; //! from this file
  14. #ifdef WIN32
  15. struct MemoryInfo
  16. {
  17. unsigned long ausgelagerteFehler;
  18. __int64 hoechsteAusgelagerterSpeicher;
  19. __int64 ausgelagerterSpeicher;
  20. __int64 hoechsterAusgelagerterPool;
  21. __int64 ausgelagerterPool;
  22. __int64 hoechsterNichtAusgelagerterPool;
  23. __int64 nichtAusgelagerterPool;
  24. __int64 vorreservierterSpeicher;
  25. __int64 hoechsterVorreservierterSpeicher;
  26. };
  27. #endif
  28. //! This class retrieves information about a running process
  29. //! (CPU, MEM). On Ubuntu always the own process
  30. class Process : public virtual ReferenceCounter
  31. {
  32. private:
  33. #ifdef WIN32
  34. int numProcessors;
  35. ULARGE_INTEGER lastCPU, lastSysCPU, lastUserCPU;
  36. void* pHandle;
  37. #endif
  38. public:
  39. //! Constructor
  40. DLLEXPORT Process();
  41. //! non-constant
  42. #ifdef WIN32
  43. //! Sets the process to monitor (Windows only)
  44. DLLEXPORT void setProcess(void* pHandle);
  45. #endif
  46. //! Returns the CPU usage of the process
  47. DLLEXPORT double getCPU() const;
  48. //! Returns the memory usage of the process
  49. DLLEXPORT __int64 getMem() const;
  50. #ifdef WIN32
  51. //! Returns detailed information about the memory usage of the
  52. //! process (Windows only)
  53. DLLEXPORT MemoryInfo getMemInfo() const;
  54. //! Returns the number of threads (Windows only)
  55. DLLEXPORT int getThreadAnzahl() const;
  56. #endif
  57. };
  58. } // namespace Framework
  59. #endif