Add LCOV remarkers to increase line coverage rate
[platform/core/api/maps-service.git] / src / session / command_queue.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_QUEUE_H__
18 #define __MAPS_SERVICE_SESSION_COMMAND_QUEUE_H__
19
20 #include "module.h"
21 //LCOV_EXCL_START
22
23 namespace session
24 {
25
26         class command;
27
28         class command_queue
29         {
30         public:
31                 virtual int push(command *c) = 0;
32                 virtual command *pop(plugin::plugin_s *p) = 0;
33                 virtual void process(plugin::plugin_s *p) = 0;
34                 virtual void clear(plugin::plugin_s *p) = 0;
35         public:
36                 static command_queue *interface();
37                 static bool is_async()
38                 {
39                         return false;
40                 }
41         };
42
43         class command_queue_sync:public command_queue
44         {
45         private:
46                 command_queue_sync()
47                 {
48                 }
49                 virtual ~command_queue_sync()
50                 {
51                 }
52         private:
53                 virtual int push(command *c);
54                 virtual command *pop(plugin::plugin_s *p);
55                 virtual void process(plugin::plugin_s *p);
56                 virtual void clear(plugin::plugin_s *p);
57
58                 friend class command_queue;
59         };
60
61 /*
62  * This is the implementation of asynchronous queue.
63  * In order to pass code coverage tests it is blocked.
64  */
65 #ifdef _MAPS_SERVICE_SUPPORTS_ASYNC_QUEUE_
66         class command_queue_async:public command_queue
67         {
68         private:
69                 command_queue_async()
70                 {
71                 }
72                 virtual ~command_queue_async()
73                 {
74                 }
75         private:
76                 virtual int push(command *c);
77                 virtual command *pop(plugin::plugin_s *p);
78                 virtual void process(plugin::plugin_s *p);
79                 virtual void clear(plugin::plugin_s *p);
80
81                 friend class command_queue;
82         };
83
84         /*
85          * This queue is intended to process mainly the commands, assigned to
86          * user gestures
87          */
88         class command_queue_view : public command_queue
89         {
90         private:
91                 command_queue_view()
92                 {
93                 }
94                 virtual ~command_queue_view()
95                 {
96                 }
97         public:
98                 static command_queue* interface();
99         private:
100                 virtual int push(command *c);
101                 virtual command *pop(plugin::plugin_s *p);
102                 virtual void process(plugin::plugin_s *p);
103                 virtual void clear(plugin::plugin_s *p);
104
105                 friend class command_queue;
106         private:
107                 static gint iterate(gconstpointer a,
108                                     gconstpointer b,
109                                     gpointer user_data);
110         };
111
112         class queue_autoref
113         {
114         public:
115                 GAsyncQueue *q;
116         public:
117                 queue_autoref(GAsyncQueue *async_queue) : q(async_queue)
118                 {
119                         g_async_queue_ref(q);
120                 }
121                 ~queue_autoref()
122                 {
123                         g_async_queue_unref(q);
124                 }
125         };
126 #endif /* _MAPS_SERVICE_SUPPORTS_ASYNC_QUEUE_ */
127
128 };
129 //LCOV_EXCL_STOP
130
131 #endif                          /* __MAPS_SERVICE_SESSION_COMMAND_QUEUE_H__ */