remove hard coded path into CMake files
[profile/ivi/ico-vic-amb-plugin.git] / src / config.h
1 /**
2  * Copyright (C) 2012  TOYOTA MOTOR CORPORATION.
3  * 
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  * 
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  * 
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
17  * 
18  */
19 #ifndef CONFIG_H
20 #define CONFIG_H
21
22 #include <string>
23 #include <vector>
24
25 /**
26  * Table of vehicle information that is described in the configuration file.
27  * 04-18 Add String
28  */
29 struct VehicleInfoDefine {
30     struct Status {
31         std::string ambPropertyName;
32         enum DataType {
33             INT, DOUBLE, CHAR, INT16, UINT16, UINT32, INT64, UINT64, BOOL, NONE
34         } type;
35         int typesize;
36         std::string accessControl;
37         std::string defaultvalue;
38         std::string dbusPropertyName;
39     };
40     /* ToDo */
41     //undefine data structure;
42     struct Sense {
43         int temp;
44     };
45     /* ToDo */
46     //undefine data structure;
47     struct EventMask {
48         int temp;
49     };
50
51     char KeyEventType[64];
52     std::vector<Status> status;
53     std::vector<Sense> sense;
54     std::vector<EventMask> event_mask;
55     int priority;
56     std::string dbusInterface;
57     std::string dbusObject;
58 };
59
60 /**
61  * Information Websocket port.
62  */
63 struct PortInfo {
64     struct {
65         int dataPort;
66         int controlPort;
67     } standard;
68
69     struct {
70         int dataPort;
71         int controlPort;
72     } custom;
73 };
74
75 /**
76  * This class handles the data in the configuration file.
77  */
78 class Config {
79 public:
80     /**
81      * Constructor.
82      */
83     Config();
84     /**
85      * Destructor.
86      */
87     ~Config();
88     /**
89      * Read configuration file.
90      *
91      * @param confpath Path to the configuration file.
92      */
93     bool
94     readConfig(std::string confpath);
95     /**
96      * This function will return a table of vehicle information read from the configuration file.
97      *
98      * @return Vehicle information defined by the configuration file.(Failure NULL)
99      */
100     std::vector<VehicleInfoDefine>
101     getVehicleInfoConfig();
102     /**
103      * This function returns the socket port used to Websocket.
104      */
105     PortInfo
106     getPort();
107 protected:
108     bool
109     parseJson(std::string config);
110
111     std::string filename;
112     bool readflag;
113 private:
114     VehicleInfoDefine::Status::DataType
115     getType(char *type, int *size);
116
117     std::vector<VehicleInfoDefine> vehicleinfoList;
118     PortInfo portinfo;
119 };
120 #endif // #ifndef CONFIG_H