summaryrefslogtreecommitdiff
path: root/resourceqt-client/client.h
diff options
context:
space:
mode:
authorWolf Bergenheim <ext-wolf.2.bergenheim@nokia.com>2010-08-23 12:15:15 +0300
committerWolf Bergenheim <ext-wolf.2.bergenheim@nokia.com>2010-09-06 14:36:28 +0300
commit0bcbc969c7dfa362cfffad3f92d375329fee289f (patch)
tree7f1897a8e359091b112cacaea0c8fd4fbf3a4c5f /resourceqt-client/client.h
parenta83adabf1dd858d3dab0cc141fc51fdcb9388d44 (diff)
* Moved CommandLineParser to its own files
* Removed broken timer, replaced it with a simpler timer made in C * Sanitized the use of resources (Use Qt types instead of custom bitmap) * Added a MessageHandler so we can later play with verbosity level
Diffstat (limited to 'resourceqt-client/client.h')
-rw-r--r--resourceqt-client/client.h90
1 files changed, 9 insertions, 81 deletions
diff --git a/resourceqt-client/client.h b/resourceqt-client/client.h
index 200e4b6..249a7a8 100644
--- a/resourceqt-client/client.h
+++ b/resourceqt-client/client.h
@@ -8,87 +8,18 @@
#include <policy/resource-set.h>
#include <sys/resource.h>
-#define RES_AUDIO_PLAYBACK (1<<0)
-#define RES_VIDEO_PLAYBACK (1<<1)
-#define RES_AUDIO_RECORDING (1<<2)
-#define RES_VIDEO_RECORDING (1<<3)
-#define RES_VIBRA (1<<4)
-#define RES_LEDS (1<<5)
-#define RES_BACKLIGHT (1<<6)
-#define RES_SYSTEM_BUTTON (1<<7)
-#define RES_LOCK_BUTTON (1<<8)
-#define RES_SCALE_BUTTON (1<<9)
-#define RES_SNAP_BUTTON (1<<10)
-#define RES_LENS_COVER (1<<11)
-#define RES_HEADSET_BUTTONS (1<<12)
-
-class TimeStat
-{
-public:
- double totalTime;
-
- TimeStat()
- {
- running = false;
- totalTime = 0;
- };
-
- inline void markStart()
- {
- running = true;
- getrusage(RUSAGE_SELF, &start);
- }
-
- inline bool markEnd()
- {
- getrusage(RUSAGE_SELF, &end);
-
- if( !running )
- return false;
-
- running = false;
- timevalSub(&end.ru_utime, &start.ru_utime, &end.ru_utime);
- timevalSub(&end.ru_stime, &start.ru_stime, &end.ru_stime);
-
- double sys = end.ru_stime.tv_sec * 1000.0 + end.ru_stime.tv_usec / 1000.0;
- double usr = end.ru_utime.tv_sec * 1000.0 + end.ru_utime.tv_usec / 1000.0;
- totalTime = sys + usr;
-
- return true;
- }
-
- void report(const char* format)
- {
- printf(format, totalTime);
- }
-
-private:
- bool running;
- struct rusage start;
- struct rusage end;
-
- void timevalSub(struct timeval *a, struct timeval *b, struct timeval *diff)
- {
- diff->tv_sec = a->tv_sec - b->tv_sec;
- if( a->tv_usec < b->tv_usec )
- {
- diff->tv_sec--;
- diff->tv_usec = 1000000 - b->tv_usec + a->tv_usec;
- }
- else
- diff->tv_usec = a->tv_usec - b->tv_usec;
- }
-};
+#include "commandlineparser.h"
+#include "time-stat.h"
class Client : public QObject
{
Q_OBJECT
public:
- Client(QString appClass);
+ Client();
~Client();
- bool initialize(uint32_t all, uint32_t optional, bool alwaysReply, bool autoRelease);
+ bool initialize(const CommandLineParser &commandParser);
static uint32_t parseResourceList(QString resourceListStr);
private slots:
@@ -102,16 +33,12 @@ protected:
void timerEvent(QTimerEvent *e);
private:
- QTextStream* standardInput;
- int mainTimerID;
+ QTextStream standardInput;
+ int mainTimerID;
- uint32_t resourcesAll;
- uint32_t resourcesOptional;
- QString applicationClass;
+ QString applicationClass;
- TimeStat timeStat;
-
- ResourcePolicy::ResourceSet* resourceSet;
+ ResourcePolicy::ResourceSet *resourceSet;
ResourcePolicy::Resource* allocateResource(ResourcePolicy::ResourceType resource, bool optional);
ResourcePolicy::ResourceType getResourceType(uint32_t resource);
@@ -123,3 +50,4 @@ private:
};
#endif
+