Core::~Core()
{
-
+ for(auto itr = mSinks.begin(); itr != mSinks.end(); itr++)
+ {
+ AbstractSink* sink = *itr;
+ delete sink;
+ }
}
void unsubscribeToProperty(VehicleProperty::Property, AbstractSink* self);
PropertyList supported() { return mMasterPropertyList; }
-protected:
~Core();
private:
GlibMainLoop::~GlibMainLoop()
{
g_main_loop_quit(mainLoop);
- exit(0);
+ //exit(0);
}
int GlibMainLoop::exec()
VehicleProperty::factory();
- PluginLoader loader(config, new Core(), argc, argv);
+ Core routingEngine;
+
+ PluginLoader loader(config, &routingEngine , argc, argv);
if(!loader.sources().size())
{
PluginLoader::~PluginLoader()
{
- for(auto itr = mSinks.begin(); itr != mSinks.end(); itr++)
- {
- delete *itr;
- }
-
- for(auto itr = mSources.begin(); itr != mSources.end(); itr++)
- {
- delete *itr;
- }
}
SinkList PluginLoader::sinks()
#include "abstractroutingengine.h"
+
+
+AbstractRoutingEngine::~AbstractRoutingEngine()
+{
+}
class AbstractRoutingEngine
{
public:
+ virtual ~AbstractRoutingEngine();
+
virtual void setSupported(PropertyList supported, AbstractSource* source) = 0;
virtual void updateSupported(PropertyList added, PropertyList removed) = 0;
virtual void updateProperty(VehicleProperty::Property property, AbstractPropertyType* value, std::string uuid) = 0;
virtual void subscribeToProperty(VehicleProperty::Property, AbstractSink* self) = 0;
virtual void unsubscribeToProperty(VehicleProperty::Property, AbstractSink* self) = 0;
virtual PropertyList supported() = 0;
-
};
#endif // ABSTRACTROUTINGENGINE_H
AbstractSink::~AbstractSink()
{
- routingEngine->unregisterSink(this);
+ //routingEngine->unregisterSink(this);
}
void AbstractSink::setConfiguration(map<string, string> config)
if(config.find("databaseFile") != config.end())
{
- databaseName = config["databaseFile"];
+ setDatabaseFileName(config["databaseFile"]);
}
if(config.find("properties") != config.end())
mSupported.push_back(DatabaseLoggingProperty);
mSupported.push_back(DatabasePlaybackProperty);
- /// get supported:
-
- initDb();
-
- vector<vector<string> > supportedStr = shared->db->select("SELECT DISTINCT key FROM "+tablename);
-
- for(int i=0; i < supportedStr.size(); i++)
- {
- if(!ListPlusPlus<VehicleProperty::Property>(&mSupported).contains(supportedStr[i][0]))
- mSupported.push_back(supportedStr[i][0]);
- }
-
- delete shared;
- shared = NULL;
-
routingEngine->setSupported(supported(), this);
if(config.find("startOnLoad")!= config.end())
{
- AsyncSetPropertyRequest request;
- request.property = DatabaseLoggingProperty;
- request.value = new DatabaseLoggingType(true);
-
- setProperty(request);
+ setLogging(true);
}
if(config.find("playbackMultiplier")!= config.end())
if(config.find("playbackOnLoad")!= config.end())
{
- AsyncSetPropertyRequest request;
- request.property = DatabasePlaybackProperty;
- request.value = new DatabasePlaybackType(true);
-
- setProperty(request);
+ setPlayback(true);
}
setProperty(request);
}
+void DatabaseSink::setDatabaseFileName(string filename)
+{
+ databaseName = filename;
+
+ initDb();
+
+ vector<vector<string> > supportedStr = shared->db->select("SELECT DISTINCT key FROM "+tablename);
+
+ for(int i=0; i < supportedStr.size(); i++)
+ {
+ if(!ListPlusPlus<VehicleProperty::Property>(&mSupported).contains(supportedStr[i][0]))
+ mSupported.push_back(supportedStr[i][0]);
+ }
+
+ delete shared;
+ shared = NULL;
+
+ routingEngine->setSupported(mSupported, this);
+}
+
void DatabaseSink::propertyChanged(VehicleProperty::Property property, AbstractPropertyType *value, std::string uuid)
{
if(!shared)
void initDb();
void setPlayback(bool v);
void setLogging(bool b);
+ void setDatabaseFileName(std::string filename);
private:
PropertyList mSubscriptions;