1 /* 2 * Copyright 2008, Axel Dörfler, axeld@pinc-software.de. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef DATA_SOURCE_H 6 #define DATA_SOURCE_H 7 8 9 #include <InterfaceDefs.h> 10 11 class BString; 12 class SystemInfo; 13 14 15 class DataSource { 16 public: 17 DataSource(int64 initialMin, int64 initialMax); 18 DataSource(); 19 DataSource(const DataSource& other); 20 virtual ~DataSource(); 21 22 virtual DataSource* Copy() const; 23 24 int64 Minimum() const; 25 int64 Maximum() const; 26 bigtime_t RefreshInterval() const; 27 28 virtual void SetLimits(int64 min, int64 max); 29 virtual void SetRefreshInterval(bigtime_t interval); 30 virtual void SetColor(rgb_color color); 31 32 virtual int64 NextValue(SystemInfo& info); 33 virtual void Print(BString& text, int64 value) const; 34 35 virtual const char* Label() const; 36 virtual const char* Unit() const; 37 virtual rgb_color Color() const; 38 virtual bool AdaptiveScale() const; 39 40 static int32 CountSources(); 41 static const DataSource* SourceAt(int32 index); 42 43 protected: 44 int64 fMinimum; 45 int64 fMaximum; 46 bigtime_t fInterval; 47 rgb_color fColor; 48 }; 49 50 51 class MemoryDataSource : public DataSource { 52 public: 53 MemoryDataSource(); 54 virtual ~MemoryDataSource(); 55 56 virtual void Print(BString& text, int64 value) const; 57 virtual const char* Unit() const; 58 }; 59 60 61 class UsedMemoryDataSource : public MemoryDataSource { 62 public: 63 UsedMemoryDataSource(); 64 virtual ~UsedMemoryDataSource(); 65 66 virtual DataSource* Copy() const; 67 68 virtual int64 NextValue(SystemInfo& info); 69 virtual const char* Label() const; 70 }; 71 72 73 class CachedMemoryDataSource : public MemoryDataSource { 74 public: 75 CachedMemoryDataSource(); 76 virtual ~CachedMemoryDataSource(); 77 78 virtual DataSource* Copy() const; 79 80 virtual int64 NextValue(SystemInfo& info); 81 virtual const char* Label() const; 82 }; 83 84 85 class ThreadsDataSource : public DataSource { 86 public: 87 ThreadsDataSource(); 88 virtual ~ThreadsDataSource(); 89 90 virtual DataSource* Copy() const; 91 92 virtual int64 NextValue(SystemInfo& info); 93 virtual const char* Label() const; 94 virtual bool AdaptiveScale() const; 95 }; 96 97 98 class CpuUsageDataSource : public DataSource { 99 public: 100 CpuUsageDataSource(); 101 CpuUsageDataSource(const CpuUsageDataSource& other); 102 virtual ~CpuUsageDataSource(); 103 104 virtual DataSource* Copy() const; 105 106 virtual void Print(BString& text, int64 value) const; 107 virtual int64 NextValue(SystemInfo& info); 108 virtual const char* Label() const; 109 110 private: 111 bigtime_t fPreviousActive; 112 bigtime_t fPreviousTime; 113 }; 114 115 #endif // DATA_SOURCE_H 116