1 // Copyright (c) 2014 Intel Corporation. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef VEHICLE_VEHICLE_H_
6 #define VEHICLE_VEHICLE_H_
8 #include <abstractpropertytype.h>
12 #include <superptr.hpp>
15 #include <thread> // NOLINT
26 ObjectZone():zone(0) {}
28 ObjectZone(const std::string& o, int z, const std::string& op)
29 : name(o), zone(z), object_path(op) {}
31 ObjectZone(const ObjectZone& other)
32 : name(other.name), zone(other.zone), object_path(other.object_path) {}
38 std::string object_path;
40 bool operator ==(const ObjectZone& other) const {
41 return object_path == other.object_path;
44 picojson::object value;
47 struct ObjectZoneCompare {
48 bool operator() (const ObjectZone& lhs, const ObjectZone& rhs) {
49 return (lhs.name == rhs.name && lhs.zone < rhs.zone) ||
50 (lhs.name < rhs.name);
54 typedef std::function<void (picojson::object)> GetReply;
55 typedef std::function<void (std::string)> ErrorReply;
61 static common::Instance* instance;
65 explicit Vehicle(common::Instance* i);
68 void Get(const std::string& property, Zone::Type zone, double ret_id);
69 void GetZones(const std::string& property, double ret_id);
70 void Subscribe(const std::string& property, Zone::Type zone);
71 void Unsubscribe(const std::string& property, Zone::Type zone);
72 void Set(const std::string& property, picojson::object value, Zone::Type zone, double ret_id);
73 void Supported(const std::string& property, double ret_id);
74 bool AvailableForRetrieval(const std::string& objectName, const std::string& attName);
77 std::string FindProperty(const std::string& object_name, int zone, string &error_str);
79 static void SetupMainloop(void* data);
80 GMainLoop* main_loop_;
82 common::Instance* instance_;
84 std::vector<ObjectZone*> amb_objects_;
86 amb::super_ptr<GDBusProxy> manager_proxy_;
87 amb::super_ptr<GDBusConnection> dbus_connection_;
90 #endif // VEHICLE_VEHICLE_H_