4a74691a8e6e9d78164ca7b0dd2fad1dcf814824
[profile/ivi/automotive-message-broker.git] / lib / abstractsink.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 ABSTRACTSINK_H
21 #define ABSTRACTSINK_H
22
23 #include <string>
24 #include <list>
25 #include <map>
26 #include <functional>
27 #include <boost/any.hpp>
28
29 #include "vehicleproperty.h"
30 #include "abstractpropertytype.h"
31
32 using namespace std;
33
34 class AbstractRoutingEngine;
35 class AbstractSink;
36
37 typedef list<AbstractSink*> SinkList;
38
39 class AbstractSink
40 {
41
42 public:
43         AbstractSink(AbstractRoutingEngine* engine, map<string, string> config);
44         virtual ~AbstractSink();
45         
46         ///Pure virtual methods:
47         
48         /*! uuid() is a unique identifier
49           * @return a guid-style unique identifier
50           */
51         virtual string uuid() = 0;
52
53         /*! propertyChanged is called when a subscribed to property changes.
54           * @see AbstractRoutingEngine::subscribeToPropertyChanges()
55           * @param property name that changed
56           * @param value value of the property that changed. this is a temporary pointer that will be destroyed.
57           * Do not destroy it.  If you need to store the value use value.anyValue() or value.value<T>() to copy.
58           * @param uuid Unique identifier representing the source
59           */
60         virtual void propertyChanged(VehicleProperty::Property property, AbstractPropertyType* value, string  uuid, double timestamp, uint32_t sequence) = 0;
61         virtual void supportedChanged(PropertyList supportedProperties) = 0;
62         
63
64         virtual void setConfiguration(map<string, string> config);
65
66 protected:
67         AbstractRoutingEngine* routingEngine;
68         map<string, string> configuration;
69 };
70
71 class AbstractSinkManager
72 {
73 public:
74         
75         AbstractSinkManager(AbstractRoutingEngine* engine, map<string, string> config);
76         
77 protected:
78         AbstractRoutingEngine* routingEngine;
79         map<string, string> configuration;
80 };
81
82 #endif // ABSTRACTSINK_H