changes to allow build on Ubuntu 12.04
[profile/ivi/automotive-message-broker.git] / lib / abstractroutingengine.h
1 /*
2     Copyright (C) 2012  Intel 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
20 #ifndef ABSTRACTROUTINGENGINE_H
21 #define ABSTRACTROUTINGENGINE_H
22
23 #include "sys/types.h"
24 #include <stdlib.h>
25
26 #include <boost/any.hpp>
27 #include <functional>
28 #include <time.h>
29 #include "vehicleproperty.h"
30 #include "abstractpropertytype.h"
31
32 class AbstractSink;
33 class AbstractSource;
34 class AsyncPropertyReply;
35
36
37 typedef std::function<void (AsyncPropertyReply*)> GetPropertyCompletedSignal;
38
39 class PropertyValueTime {
40 public:
41         AbstractPropertyType* value;
42         time_t timestamp;
43 };
44
45 class AsyncPropertyRequest
46 {
47 public:
48         AsyncPropertyRequest()
49                 :property(VehicleProperty::NoValue)
50         {
51
52         }
53
54         AsyncPropertyRequest(const AsyncPropertyRequest &request)
55         {
56                 this->property = request.property;
57                 this->completed = request.completed;
58         }
59
60         AsyncPropertyRequest & operator = (const AsyncPropertyRequest & other)
61         {
62                 this->property = other.property;
63                 this->completed = other.completed;
64
65                 return *this;
66         }
67
68         VehicleProperty::Property property;
69         GetPropertyCompletedSignal completed;
70 };
71
72 class AsyncPropertyReply: public AsyncPropertyRequest
73 {
74 public:
75         AsyncPropertyReply(const AsyncPropertyRequest &request)
76                 :AsyncPropertyRequest(request), value(NULL), success(false)
77         {
78
79         }
80
81         AbstractPropertyType* value;
82         bool success;
83 };
84
85 class AsyncSetPropertyRequest: public AsyncPropertyRequest
86 {
87 public:
88         AsyncSetPropertyRequest()
89                 :value(NULL)
90         {
91
92         }
93
94         AsyncSetPropertyRequest(const AsyncPropertyRequest &request)
95                 :AsyncPropertyRequest(request), value(NULL)
96         {
97
98         }
99
100         AbstractPropertyType* value;
101 };
102
103 class AsyncRangePropertyRequest: public AsyncPropertyRequest
104 {
105 public:
106         AsyncRangePropertyRequest()
107                 :begin(0), end(0)
108         {
109
110         }
111
112         AsyncRangePropertyRequest(const AsyncPropertyRequest &request)
113                 :AsyncPropertyRequest(request), begin(0), end(0)
114         {
115                 this->property = request.property;
116                 this->completed = request.completed;
117         }
118
119         AsyncRangePropertyRequest(const AsyncRangePropertyRequest &request)
120                 :AsyncPropertyRequest(request)
121         {
122                 this->property = request.property;
123                 this->completed = request.completed;
124                 this->begin = request.begin;
125                 this->end = request.end;
126         }
127
128         time_t begin;
129         time_t end;
130 };
131
132 class AsyncRangePropertyReply: public AsyncRangePropertyRequest
133 {
134 public:
135         AsyncRangePropertyReply(AsyncRangePropertyRequest request)
136                 :AsyncRangePropertyRequest(request)
137         {
138
139         }
140
141         std::list<PropertyValueTime*> values;
142 };
143
144 class AbstractRoutingEngine
145 {
146 public:
147         virtual void setSupported(PropertyList supported, AbstractSource* source) = 0;
148         virtual void updateSupported(PropertyList added, PropertyList removed) = 0;
149         virtual void updateProperty(VehicleProperty::Property property, AbstractPropertyType* value) = 0;
150
151         /// sinks:
152         virtual void registerSink(AbstractSink* self) = 0;
153         virtual void  unregisterSink(AbstractSink* self) = 0;
154         virtual AsyncPropertyReply * getPropertyAsync(AsyncPropertyRequest request) = 0;
155         virtual AsyncRangePropertyReply * getRangePropertyAsync(AsyncRangePropertyRequest request) = 0;
156         virtual AsyncPropertyReply * setProperty(AsyncSetPropertyRequest request) = 0;
157         virtual void subscribeToProperty(VehicleProperty::Property, AbstractSink* self) = 0;
158         virtual void unsubscribeToProperty(VehicleProperty::Property, AbstractSink* self) = 0;
159         virtual PropertyList supported() = 0;
160 };
161
162 #endif // ABSTRACTROUTINGENGINE_H