0f6250fe2d2056ad969d57beda2a6a073dd401b6
[profile/ivi/ico-uxf-homescreen.git] / lib / system-controller / CicoSCAppResourceController.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  * @brief   CicoSCAppResourceController
11  *          SystemController resource
12  *          Application Resouce Controller
13  *
14  * @date    Aug-05-2013 create start
15  */
16
17 #ifndef CICOSCAPPRESOURCECONTROLLER_H
18 #define CICOSCAPPRESOURCECONTROLLER_H
19 #include <cstddef>
20 #include <string>
21 #include <vector>
22
23 #include "CicoAilItems.h"
24 #include "CicoAulItems.h"
25 #include "CicoSCSysResourceController.h"
26
27 #define D_STRappResource "appResource.json"
28 #define DSTRcpu_shares "cpu_shares"
29 #define DSTRshare "share"
30 #define DSTRappid "appid"
31 /**
32  * @brief System Controller Application Resource Controller class
33  */
34 class CicoSCAppResourceController : public CicoSCSysResourceController
35 {
36 public:
37     CicoSCAppResourceController();
38     ~CicoSCAppResourceController();
39
40     bool initAppResource();
41     bool startAppResource(const std::string& un);
42     bool clearApps();
43
44     bool isAppResource();
45
46     bool entryApp(const std::string& appid, int pid);
47     bool entryApps(std::vector<CicoAulItems>& vAulItem);
48
49     void getAppResourceFilePath(const std::string& un, std::string& fp) const;
50     void createAppResourceFile(const std::string& filepath);
51 protected:
52     bool orderApps(const std::string& filepath);
53     bool readApps(const std::string& filepath);
54     void init_cgroup_app_dir();
55     void init_cgroup_app_cpushare();
56
57 protected:
58     bool m_bDoItApp;
59 private:
60     
61     std::vector<std::string> m_vAppid;
62     std::vector<int> m_vShares;
63     std::string m_filepath;
64 };
65
66 inline bool CicoSCAppResourceController::isAppResource()
67 {
68     return m_bDoItApp;
69 }
70
71 #endif // CICOSCAPPRESOURCECONTROLLER_H