Refactoring homescreen.
[profile/ivi/ico-uxf-homescreen.git] / lib / system-controller / CicoSCResourceManager.h
1 /*
2  * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
3  *
4  * This program is licensed under the terms and conditions of the
5  * Apache License, version 2.0.  The full text of the Apache License is at
6  * http://www.apache.org/licenses/LICENSE-2.0
7  *
8  */
9
10 //==========================================================================
11 /**
12  *  @file   CicoSCResourceManager.h
13  *
14  *  @brief 
15  */
16 //==========================================================================
17 #ifndef __CICO_SC_RESOURCE_MANAGER_H__
18 #define __CICO_SC_RESOURCE_MANAGER_H__
19
20 #include <list>
21 using namespace std;
22
23 #include "ico_syc_mrp_resource_private.h"
24
25 class CicoSCCommand;
26 class CicoSCPolicyManager;
27 class CicoSCWindowController;
28 class CicoSCInputController;
29
30 class CicoSCResourceManager
31 {
32 public:
33     // default constructor
34     CicoSCResourceManager();
35
36     // destructor
37     ~CicoSCResourceManager();
38
39     // initialize resource manager
40     int initialize(void);
41   
42     // terminate resource manager
43     void terminate(void);
44  
45     // handling command
46     void handleCommand(const CicoSCCommand &cmd, bool internal=false);
47
48     // set CicoSCWindowController instance
49     void setWindowController(CicoSCWindowController *winCtrl);
50
51     // set CicoSCInputController instance
52     void setInputController(CicoSCInputController *inputCtrl);
53
54     // receive changed state
55     void receiveChangedState(int state);
56
57 private:
58     // assignment operator
59     CicoSCResourceManager& operator=(const CicoSCResourceManager &object);
60
61     // copy constructor
62     CicoSCResourceManager(const CicoSCResourceManager &object);
63
64     bool acquireDisplayResource(resource_request_t *req, int addprio);
65     bool releaseDisplayResource(resource_request_t *req);
66
67     bool acquireSoundResource(resource_request_t *req, int addprio);
68     bool releaseSoundResource(resource_request_t *req);
69
70     bool acquireInputResource(resource_request_t *req, int addprio);
71     bool releaseInputResource(resource_request_t *req);
72
73
74     resource_request_t* newResourceRequest(int resid,
75                                            int reqtype,
76                                            const CicoSCCommand &cmd);
77
78     void delResourceRequest(resource_request_t *req);
79
80     static void enforceDisplay(unsigned short state,
81                                const char *appid,
82                                unsigned int id,
83                                void *user_data);
84
85     static void enforceSound(unsigned short state,
86                              pid_t pid,
87                              void *user_data);
88
89     static void enforceInput(unsigned short state,
90                              const char *appid,
91                              const char *device,
92                              void *user_data);
93
94 private:
95     CicoSCPolicyManager    *m_policyMgr;
96     CicoSCWindowController *m_winCtrl;
97     CicoSCInputController  *m_inputCtrl;
98
99     list<list<resource_request_t*> > m_dispReqQueue;
100     list<list<resource_request_t*> > m_soundReqQueue;
101     list<list<resource_request_t*> > m_inputReqQueue;
102 };
103 #endif  // __CICO_SC_RESOURCE_MANAGER_H__
104 // vim:set expandtab ts=4 sw=4: