more code added to core
[profile/ivi/automotive-message-broker.git] / lib / abstractsource.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 ABSTRACTSOURCE_H
21 #define ABSTRACTSOURCE_H
22
23 #include <string>
24 #include <list>
25 #include <functional>
26 #include <boost/any.hpp>
27 #include "vehicleproperty.h"
28
29 using namespace std;
30
31 class AbstractSource;
32
33 typedef function<void (VehicleProperty::Property, boost::any)> PropertyChangedSignal;
34
35 /// [void](PropertyList added, PropertyList removed) { }
36
37 typedef function<void (PropertyList, PropertyList)> SupportedChangedSignal;
38
39 typedef list<AbstractSource*> SourceList;
40
41 class AbstractSource
42 {
43
44 public:
45         AbstractSource();
46
47         void propertyChanged(VehicleProperty::Property property, boost::any value);
48
49         void setPropertyChangedCb(PropertyChangedSignal propertyChangedCb);
50         void setSupportedChangedCb(SupportedChangedSignal supportedChangedCb);
51         
52         ///pure virtual methods:
53
54         virtual string name() = 0;
55         virtual void setProperty(VehicleProperty::Property property, boost::any value) = 0;
56         virtual void subscribeToPropertyChanges(VehicleProperty::Property property) = 0;
57         virtual void unsubscribeToPropertyChanges(VehicleProperty::Property property) = 0;
58         virtual PropertyList supported() = 0;
59         
60
61 private:
62         PropertyChangedSignal mPropertyChangedCb;
63         SupportedChangedSignal mSupportedChangedCb;
64     
65 };
66
67 #endif // ABSTRACTSOURCE_H