automotive-message-broker  0.14.803
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
murphysource.h
1 
2 /*
3 Copyright (C) 2012 Intel Corporation
4 
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9 
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14 
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19 
20 
21 #ifndef MURPHYSOURCE_H
22 #define MURPHYSOURCE_H
23 
24 #include <murphy/common.h>
25 #include <murphy/common/process.h>
26 
27 #include <abstractsource.h>
28 #include <string>
29 
30 // #include <vehicleproperty.h>
31 // #include <abstractpropertytype.h>
32 
33 using namespace std;
34 
36 {
37 
38 public:
39  MurphySource(AbstractRoutingEngine* re, map<string, string> config);
40  ~MurphySource();
41 
42  const string uuid() { return "murphy"; }
43  void getPropertyAsync(AsyncPropertyReply *reply);
44  void getRangePropertyAsync(AsyncRangePropertyReply *reply);
45  AsyncPropertyReply * setProperty(AsyncSetPropertyRequest request);
46  void subscribeToPropertyChanges(VehicleProperty::Property property);
47  void unsubscribeToPropertyChanges(VehicleProperty::Property property);
48  PropertyList supported();
49 
50  int supportedOperations();
51 
52  void supportedChanged(const PropertyList &) {}
53 
54  void processValue(string propertyName, AbstractPropertyType *value);
55 
56  bool hasProperty(string propertyName);
57 
58  void setState(mrp_process_state_t state);
59  mrp_process_state_t getState();
60 
61  void setConnected(bool connected);
62 
63  int connectToMurphy();
64 
65  PropertyInfo getPropertyInfo(const VehicleProperty::Property &property);
66 
67 private:
68  void checkSubscriptions();
69  void setConfiguration(map<string, string> config);
70  void readyToConnect(mrp_mainloop_t *ml);
71 
72  PropertyList m_supportedProperties;
73 
74  MurphySource *m_source;
76 
77  // known properties
78 
79  map<string, AbstractPropertyType *> murphyProperties;
80 
81  // murphy integration
82 
83  mrp_mainloop_t *m_ml;
84  mrp_transport_t *m_tport;
85  string m_address; // transport address
86  mrp_process_state_t m_state;
87  bool m_connected;
88 };
89 
90 #endif // MURPHYSOURCE_H