Bug fix: TIVI-1996.
[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  This file is definition of CicoSCResourceManager class
15  */
16 //==========================================================================
17 #ifndef __CICO_SC_RESOURCE_MANAGER_H__
18 #define __CICO_SC_RESOURCE_MANAGER_H__
19
20 #include <list>
21 #include <vector>
22 #include <map>
23 using namespace std;
24
25 #include "ico_syc_mrp_resource_private.h"
26
27 //==========================================================================
28 //  Forward declaration
29 //==========================================================================
30 class CicoSCCommand;
31 class CicoSCPolicyManager;
32 class CicoSCWindowController;
33 class CicoSCInputController;
34
35 //==========================================================================
36 /*
37  *  @brief  This class manages resources
38  */
39 //==========================================================================
40 class CicoSCResourceManager
41 {
42 public:
43     // default constructor
44     CicoSCResourceManager();
45
46     // destructor
47     ~CicoSCResourceManager();
48
49     // initialize resource manager
50     int initialize(void);
51
52     // terminate resource manager
53     void terminate(void);
54
55     // handling command
56     void handleCommand(const CicoSCCommand &cmd, bool internal=false);
57
58     // set CicoSCWindowController instance
59     void setWindowController(CicoSCWindowController *winCtrl);
60
61     // set CicoSCInputController instance
62     void setInputController(CicoSCInputController *inputCtrl);
63
64     // receive changed state
65     void receiveChangedState(int state);
66
67     // get resource manager instance
68     CicoSCPolicyManager * getPolicyManager(void);
69
70 private:
71     // assignment operator
72     CicoSCResourceManager& operator=(const CicoSCResourceManager &object);
73
74     // copy constructor
75     CicoSCResourceManager(const CicoSCResourceManager &object);
76
77     bool acquireDisplayResource(resource_request_t *newreq,
78                                 bool control = true);
79     void releaseDisplayResource(resource_request_t *newreq);
80
81     bool acquireSoundResource(resource_request_t *newreq);
82     void releaseSoundResource(resource_request_t *newreq);
83
84     bool acquireInputResource(resource_request_t *newreq);
85     void releaseInputResource(resource_request_t *newreq);
86
87     resource_request_t* newResourceRequest(int resid,
88                                            int reqtype,
89                                            const CicoSCCommand &cmd);
90
91     void delResourceRequest(resource_request_t *req);
92
93     static void enforceSound(unsigned short state,
94                              resource_request_t *req,
95                              void *user_data);
96
97     resource_request_t * popDispResReq(resource_request_t *req);
98
99     resource_request_t * popSoundResReq(resource_request_t *req);
100
101     resource_request_t * popInputResReq(resource_request_t *req);
102
103     void updateDisplayResource(resource_request_t *req, int chgzoneid=-1);
104     void updateSoundResource(resource_request_t *req);
105     void updateInputResource(resource_request_t *req);
106
107     void updateDisplayResourceRegulation(int state);
108     void updateSoundResourceRegulation(int state);
109     void updateInputResourceRegulation(int state);
110
111     void updateDispResRegulationPreProc(resource_request_t *req);
112     void updateSoundResRegulationPreProc(resource_request_t *req);
113     void updateInputResRegulationPreProc(resource_request_t *req);
114
115     resource_request_t * findCurDispResOwerReq(resource_request_t *req);
116     resource_request_t * popCurDispResOwerReq(resource_request_t *req);
117     void dumpCurDispResOwerReq(void);
118
119     resource_request_t * findWaitingDispResReq(resource_request_t *req);
120     resource_request_t * popWaitingDispResReq(resource_request_t *req);
121     void dumpWaitingDispResReq(void);
122
123     bool isMatchDisplayed(void);
124
125 private:
126     CicoSCPolicyManager       *m_policyMgr;
127     CicoSCWindowController    *m_winCtrl;
128     CicoSCInputController     *m_inputCtrl;
129
130     // pair zoneid and request
131     std::map<unsigned int, resource_request_t*> m_curDispResOwerReq;
132     std::map<int, resource_request_t*> m_curSoundResReq;
133     std::map<int, resource_request_t*> m_curInputResReq;
134
135     std::list<resource_request_t*> m_waitingDispResReq;
136     map<int, list<resource_request_t*> > m_soundReqQueue;
137     map<int, list<resource_request_t*> > m_inputReqQueue;
138
139     // show/hide animation name at regulation on or off
140     const std::string m_animaName;
141
142     // show/hide animation time at regulation on or off
143     int m_animaTime;
144 };
145 #endif  // __CICO_SC_RESOURCE_MANAGER_H__
146 // vim:set expandtab ts=4 sw=4: