Add LCOV remarkers to increase line coverage rate
[platform/core/api/maps-service.git] / src / session / command.h
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef __MAPS_SERVICE_SESSION_COMMAND_H__
18 #define __MAPS_SERVICE_SESSION_COMMAND_H__
19
20 #include "maps_plugin.h"
21 #include "module.h"
22
23 namespace session
24 {
25 typedef enum _command_type_e {
26         MAPS_DATA_COMMAND,
27         MAPS_VIEW_SET_CENTER_COMMAND,
28         MAPS_VIEW_MOVE_CENTER_COMMAND,
29         MAPS_VIEW_ZOOM_COMMAND,
30         MAPS_VIEW_ROTATE_COMMAND,
31         MAPS_VIEW_ZOOM_ROTATE_COMMAND,
32         MAPS_VIEW_READY_COMMAND,
33         MAPS_UNDEF_COOMAND = -1
34 } command_type_e;
35
36 /*----------------------------------------------------------------------------*/
37
38 //LCOV_EXCL_START
39 class command
40 {
41         private:
42                 maps_service_h m;
43         protected:
44                 int my_req_id;
45                 int error;
46                 bool is_merged;
47         public:
48                 static volatile int command_request_id;
49         public:
50                 static command empty_instance;
51         private:
52                 command()
53                         : m(NULL), my_req_id(-1), error(0), is_merged(false)
54                 {
55                 }               /* Please, do not construct an empty object */
56         public:
57                  command(maps_service_h ms);
58                  command(const command &src);
59                  virtual ~command();
60                  command & operator=(const command &src);
61         public:
62                  virtual int run();
63                 void destroy();
64         public:
65                 static command *empty_ptr()
66                 {
67                         return &empty_instance;
68                 }
69         protected:
70                 plugin::interface_s *interface() const;
71                 maps_plugin_h handle() const;
72         public:
73                 plugin::plugin_s *plugin()const;
74         public:
75                 virtual command_type_e get_type() const;
76                 virtual int get_priority() const;
77                 virtual void merge(const command *c);
78         public:
79                 bool merged() const;
80         protected:
81                 void set_merged();
82 };
83
84 /*----------------------------------------------------------------------------*/
85
86 class command_handler
87 {
88         private:
89                 plugin::plugin_s *plg;
90         public:
91                 void *user_data;
92                 int user_req_id;
93                 int plg_req_id;
94         public:
95                  command_handler(plugin::plugin_s *plugin, void *user_data,
96                                  int user_req_id);
97                  virtual ~command_handler();
98         private:
99                  command_handler() : plg(NULL), user_data(NULL),
100                         user_req_id(-1), plg_req_id(-1)
101                 {
102                 };
103                 command_handler(const command_handler &src) : plg(NULL),
104                         user_data(NULL), user_req_id(-1), plg_req_id(-1)
105                 {
106                 };
107                 command_handler &operator=(const command_handler &src)
108                 {
109                         return *this;
110                 }
111         public:
112                 plugin::plugin_s *plugin()const
113                 {
114                         return plg;
115                 }
116                 void set_supported_place_data(maps_place_h place);
117                 void set_supported_route_data(maps_route_h route);
118                 void set_supported_place_list_data(maps_place_list_h place_list);
119                 static bool set_supported_place_list_data_cb(int index, maps_place_h place, void *user_data);
120         public:
121                 static void destroy(void *p);
122 };
123
124 /*----------------------------------------------------------------------------*/
125
126 class pending_request
127 {
128         private:
129                 plugin::plugin_s *plg;
130         public:
131                 pending_request(plugin::plugin_s *plugin);
132                 virtual ~pending_request()
133                 {
134                 };
135         private:
136                 pending_request() : plg(NULL) {
137                 }
138                 pending_request(const pending_request &src)
139                 {
140                 }
141                 pending_request &operator=(const pending_request &src)
142                 {
143                         return *this;
144                 }
145         public:
146                 bool add(const int user_req_id);
147                 void update(int user_req_id, command_handler *handler);
148                 void remove(int user_req_id);
149                 command_handler *look_up(const int user_req_id);
150                 int extract_plg_id(const int user_req_id);
151                 bool contains(const int user_req_id);
152         private:
153                 int *int_dup(const int n);
154 };
155 }
156 //LCOV_EXCL_STOP
157
158 #endif                          /* __MAPS_SERVICE_SESSION_COMMAND_H__ */