#include "core.h"
#include <functional>
#include "listplusplus.h"
+#include "debugout.h"
using namespace std::placeholders;
}
+Core::~Core()
+{
+
+}
+
+
void Core::setSupported(PropertyList supported, AbstractSource* source)
{
mSources.push_back(source);
/// iterate through subscribed properties and resubscribe. This catches newly supported properties in the process.
- for(unordered_map<VehicleProperty::Property, SinkList>::iterator itr = propertySinkMap.begin(); itr != propertySinkMap.end(); itr++)
+ for(map<VehicleProperty::Property, SinkList>::iterator itr = propertySinkMap.begin(); itr != propertySinkMap.end(); itr++)
{
VehicleProperty::Property property = (*itr).first;
void Core::subscribeToProperty(VehicleProperty::Property property, AbstractSink* self)
{
+ if(propertySinkMap.find(property) == propertySinkMap.end())
+ {
+ DebugOut()<<__FUNCTION__<<"property not supported: "<<VehicleProperty::name(property);
+ return;
+ }
+
SinkList list = propertySinkMap[property];
if(!ListPlusPlus<AbstractSink*>(&list).contains(self))
{
list.push_back(self);
}
+
+
}
void Core::unsubscribeToProperty(VehicleProperty::Property , AbstractSink* self)
#include "abstractsource.h"
#include "abstractroutingengine.h"
-#include <unordered_map>
+#include <map>
class Core: public AbstractRoutingEngine
{
-
+
public:
Core();
void subscribeToProperty(VehicleProperty::Property, AbstractSink* self);
void unsubscribeToProperty(VehicleProperty::Property, AbstractSink* self);
+protected:
+ ~Core();
+
private:
PropertyList mMasterPropertyList;
SourceList mSources;
SinkList mSinks;
- unordered_map<VehicleProperty::Property, SinkList> propertySinkMap;
+ std::map<VehicleProperty::Property, SinkList> propertySinkMap;
};
#include "vehicleproperty.h"
+using namespace std;
+
VehicleProperty::VehicleProperty()
{
#include <string>
#include <list>
-using namespace std;
+
class VehicleProperty
{
public:
+
VehicleProperty();
EngineSpeed
};
- static string name(Property prop);
- static Property value(string name);
+ static std::string name(Property prop);
+ static Property value(std::string name);
};
-typedef list<VehicleProperty::Property> PropertyList;
+typedef std::list<VehicleProperty::Property> PropertyList;
#endif // VEHICLEPROPERTY_H