2 Copyright (C) 2012 Intel Corporation
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.
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.
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
23 #include "abstractsink.h"
24 #include "abstractsource.h"
25 #include "abstractroutingengine.h"
26 #include "asyncqueue.hpp"
28 #include <unordered_map>
29 #include <unordered_set>
32 class Core: public AbstractRoutingEngine
36 Core(std::map<std::string, std::string> config);
40 void registerSource(AbstractSource *src);
41 void updateSupported(PropertyList added, PropertyList removed, AbstractSource* source);
42 void updateProperty(AbstractPropertyType* value, const std::string &uuid);
46 void registerSink(AbstractSink *self);
47 void unregisterSink(AbstractSink *self);
48 AsyncPropertyReply* getPropertyAsync(AsyncPropertyRequest request);
49 void getRangePropertyAsync(AsyncRangePropertyRequest request);
50 AsyncPropertyReply * setProperty(AsyncSetPropertyRequest request);
51 uint subscribeToProperty(const VehicleProperty::Property &, AbstractRoutingEngine::PropertyChangedType, std::string pid="");
52 bool subscribeToProperty(const VehicleProperty::Property &, AbstractSink* self);
53 bool subscribeToProperty(const VehicleProperty::Property &, const std::string & sourceUuidFilter, AbstractSink *self);
54 bool subscribeToProperty(const VehicleProperty::Property &, const std::string & sourceUuidFilter, Zone::Type zoneFilter, AbstractSink *self);
55 bool unsubscribeToProperty(const VehicleProperty::Property &, AbstractSink* self);
56 void unsubscribeToProperty(uint handle);
57 PropertyList supported();
59 PropertyInfo getPropertyInfo(const VehicleProperty::Property &,const std::string &sourceUuid);
60 std::vector<std::string> sourcesForProperty(const VehicleProperty::Property & property);
63 Performance(): propertiesPerSecond(0), firedPropertiesPerSecond(0) {}
64 int propertiesPerSecond;
65 int firedPropertiesPerSecond;
68 void inspectSupported();
72 void handleAddSupported(const PropertyList& added, AbstractSource* source);
73 void handleRemoveSupported(const PropertyList& removed, AbstractSource* source);
74 AbstractSource* sourceForProperty(const VehicleProperty::Property& property, const std::string& sourceUuidFilter = "") const;
75 void updateProperty(AbstractPropertyType* value);
79 //typedef std::map< Zone::Type, AbstractPropertyType> ZonePropertyType;
81 // to support zone filtering replace VehicleProperty::Property with ZonePropertyType
82 std::multimap<AbstractSource*, VehicleProperty::Property> mMasterPropertyList;
84 std::unordered_set<AbstractSource*> mSources;
85 std::unordered_set<AbstractSink*> mSinks;
87 Performance performance;
89 // std::string here is AbstractSource::uuid()
90 typedef std::map<AbstractSink*, std::string> FilteredSourceSinkMap;
92 ///uint cbHandle, std::string uuid
93 typedef std::unordered_map<uint, std::string> FilteredSourceCbMap;
95 // to support zone filtering replace VehicleProperty::Property with ZonePropertyType
96 std::unordered_map<VehicleProperty::Property, FilteredSourceSinkMap > propertySinkMap;
97 std::unordered_map<VehicleProperty::Property, FilteredSourceCbMap> propertyCbMap;
98 std::unordered_map<uint, AbstractRoutingEngine::PropertyChangedType> handleCbMap;
100 amb::Queue<AbstractPropertyType*, amb::PropertyCompare> updatePropertyQueue;
101 amb::Queue<AbstractPropertyType*, amb::PropertyCompare> updatePropertyQueueHigh;
102 amb::Queue<AbstractPropertyType*, amb::PropertyCompare> updatePropertyQueueLow;
103 amb::AsyncQueueWatcher<AbstractPropertyType*, amb::PropertyCompare>* watcherPtr;
104 amb::AsyncQueueWatcher<AbstractPropertyType*, amb::PropertyCompare>* watcherPtrHigh;
105 amb::AsyncQueueWatcher<AbstractPropertyType*, amb::PropertyCompare>* watcherPtrLow;