Merge pull request #16 from OlivierDelbeke/master
[profile/ivi/automotive-message-broker.git] / plugins / gpsnmea / gpsnmea.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 #ifndef GPSNMEAPLUGIN_H
20 #define GPSNMEAPLUGIN_H
21
22 #include <abstractsource.h>
23 #include <string>
24
25 #include "abstractio.hpp"
26
27 using namespace std;
28
29 class Location;
30
31 class GpsNmeaSource: public AbstractSource
32 {
33
34 public:
35         GpsNmeaSource(AbstractRoutingEngine* re, map<string, string> config);
36         ~GpsNmeaSource();
37         
38         const string uuid();
39         void getPropertyAsync(AsyncPropertyReply *reply);
40         void getRangePropertyAsync(AsyncRangePropertyReply *reply);
41         AsyncPropertyReply * setProperty(AsyncSetPropertyRequest request);
42         void subscribeToPropertyChanges(VehicleProperty::Property property);
43         void unsubscribeToPropertyChanges(VehicleProperty::Property property);
44         PropertyList supported();
45
46         int supportedOperations();
47         
48         void supportedChanged(const PropertyList &) {}
49         
50         PropertyInfo getPropertyInfo(VehicleProperty::Property property)
51         {
52                 if(propertyInfoMap.find(property) != propertyInfoMap.end())
53                         return propertyInfoMap[property];
54
55                 return PropertyInfo::invalid();
56         }
57
58         void canHasData();
59
60 private:
61
62         bool tryParse(std::string data);
63
64         void addPropertySupport(VehicleProperty::Property property, Zone::Type zone);
65
66         bool checksum(string sentence);
67
68         std::map<VehicleProperty::Property, PropertyInfo> propertyInfoMap;
69
70         PropertyList mRequests;
71         PropertyList mSupported;
72
73         AbstractIo* device;
74         Location *location;
75
76         std::string mUuid;
77
78         std::string buffer;
79 };
80
81 #endif // EXAMPLEPLUGIN_H