2 * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
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
10 //==========================================================================
12 * @file CicoSCResourceManager.h
14 * @brief This file is definition of CicoSCResourceManager class
16 //==========================================================================
17 #ifndef __CICO_SC_RESOURCE_MANAGER_H__
18 #define __CICO_SC_RESOURCE_MANAGER_H__
25 #include "ico_syc_mrp_resource_private.h"
26 #include "ico_syc_appresctl.h"
28 //==========================================================================
29 // Forward declaration
30 //==========================================================================
32 class CicoSCPolicyManager;
33 class CicoSCWindowController;
34 class CicoSCInputController;
36 //==========================================================================
38 * @brief This class manages resources
40 //==========================================================================
41 class CicoSCResourceManager
44 // default constructor
45 CicoSCResourceManager();
48 ~CicoSCResourceManager();
50 // initialize resource manager
53 // terminate resource manager
57 void handleCommand(const CicoSCCommand &cmd, bool internal=false);
59 // set CicoSCWindowController instance
60 void setWindowController(CicoSCWindowController *winCtrl);
62 // set CicoSCInputController instance
63 void setInputController(CicoSCInputController *inputCtrl);
65 // receive changed state
66 void receiveChangedState(int state);
68 // get resource manager instance
69 CicoSCPolicyManager * getPolicyManager(void);
72 // assignment operator
73 CicoSCResourceManager& operator=(const CicoSCResourceManager &object);
76 CicoSCResourceManager(const CicoSCResourceManager &object);
78 bool acquireDisplayResource(resource_request_t *newreq,
80 void releaseDisplayResource(resource_request_t *newreq);
82 bool acquireSoundResource(resource_request_t *newreq);
83 void releaseSoundResource(resource_request_t *newreq);
85 bool acquireInputResource(resource_request_t *newreq);
86 void releaseInputResource(resource_request_t *newreq);
88 resource_request_t* newResourceRequest(int resid,
90 const CicoSCCommand &cmd);
92 void delResourceRequest(resource_request_t *req);
94 static void enforceSound(unsigned short state,
95 resource_request_t *req,
98 resource_request_t * popDispResReq(resource_request_t *req);
100 resource_request_t * popSoundResReq(resource_request_t *req);
102 resource_request_t * popInputResReq(resource_request_t *req);
104 void updateDisplayResource(resource_request_t *req, int chgzoneid=-1);
105 void updateSoundResource(resource_request_t *req);
106 void updateInputResource(resource_request_t *req);
108 void updateDisplayResourceRegulation(int state);
109 void updateSoundResourceRegulation(int state);
110 void updateInputResourceRegulation(int state);
112 void updateDispResRegulationPreProc(resource_request_t *req);
113 void updateSoundResRegulationPreProc(resource_request_t *req);
114 void updateInputResRegulationPreProc(resource_request_t *req);
116 resource_request_t * findCurDispResOwerReq(resource_request_t *req);
117 resource_request_t * popCurDispResOwerReq(resource_request_t *req);
118 void dumpCurDispResOwerReq(void);
120 resource_request_t * findWaitingDispResReq(resource_request_t *req);
121 resource_request_t * popWaitingDispResReq(resource_request_t *req);
122 void dumpWaitingDispResReq(void);
124 bool isMatchDisplayed(void);
125 bool acquireOnScreenDisplayResource(resource_request_t *req);
126 bool releaseOnScreenDisplayResource(resource_request_t *req);
127 const resource_request_t* getNoticeOfHighOder();
128 bool resCB(const ico_syc_ev_e ev, const resource_request_t& p) const;
129 bool resCB(const char* sendToAppid, const int ev, const char* ECU,
130 const char* display, const char* layer, const char* layout,
131 const char* area, const char* dispatchApp, const char* role,
132 uint32_t resourceId) const;
133 bool isTypeBaseic(const resource_request_t& p);
134 bool isTypeInterrupt(const resource_request_t& p);
135 bool isTypeOnScreen(const resource_request_t& p);
137 CicoSCPolicyManager *m_policyMgr;
138 CicoSCWindowController *m_winCtrl;
139 CicoSCInputController *m_inputCtrl;
141 // pair zoneid and request
142 std::map<unsigned int, resource_request_t*> m_curDispResOwerReq;
143 std::map<int, resource_request_t*> m_curSoundResReq;
144 std::map<int, resource_request_t*> m_curInputResReq;
146 std::list<resource_request_t*> m_waitingDispResReq;
147 map<int, list<resource_request_t*> > m_soundReqQueue;
148 map<int, list<resource_request_t*> > m_inputReqQueue;
149 std::list<resource_request_t*> m_OnScreenItems;
150 const resource_request_t* m_rrtHO; // resource_request_t of High Oder
152 // show/hide animation name at regulation on or off
153 const std::string m_animaName;
155 // show/hide animation time at regulation on or off
159 //==========================================================================
161 * @brief check type is basic
162 * @param p resorce request info
164 * @retval true: basic
165 * @retval false: not basic
167 inline bool CicoSCResourceManager::isTypeBaseic(const resource_request_t& p)
169 return (RESID_TYPE_BASIC == (p.resid & RESID_TYPE_MASK));
172 //==========================================================================
174 * @brief check type is interrupt
175 * @param p resorce request info
177 * @retval true: interrupt
178 * @retval false: not interrupt
180 inline bool CicoSCResourceManager::isTypeInterrupt(const resource_request_t& p)
182 return (RESID_TYPE_INTERRUPT == (p.resid & RESID_TYPE_MASK));
185 //==========================================================================
187 * @brief check type is onscreen
188 * @param p resorce request info
190 * @retval true: onscreen
191 * @retval false: not onscreen
193 //==========================================================================
194 inline bool CicoSCResourceManager::isTypeOnScreen(const resource_request_t& p)
196 return (RESID_TYPE_ONSCREEN == (p.resid & RESID_TYPE_MASK));
198 #endif // __CICO_SC_RESOURCE_MANAGER_H__
199 // vim:set expandtab ts=4 sw=4: