fixed up database logging
authorKevron Rees <tripzero.kev@gmail.com>
Sat, 4 May 2013 06:41:02 +0000 (23:41 -0700)
committerKevron Rees <tripzero.kev@gmail.com>
Sat, 4 May 2013 06:41:02 +0000 (23:41 -0700)
examples/databaseconfig
examples/storage
lib/vehicleproperty.h
plugins/database/databasesink.cpp
plugins/database/databasesink.h
plugins/obd2plugin/obd2source.cpp

index 23cde22..ceee3d2 100644 (file)
@@ -9,7 +9,8 @@
                {
                        "name" : "Database",
                        "path" : "/usr/lib/automotive-message-broker/databasesinkplugin.so",
-                       "properties" : "{ 'properties' : ['VehicleSpeed'] }"
+                       "properties" : "{ 'properties' : ['VehicleSpeed'] }",
+                       "startOnLoad" : "true"
                },
                {
                        "name" : "Example Sink",
index e01b877..e75b21b 100644 (file)
Binary files a/examples/storage and b/examples/storage differ
index 1e35733..e81b636 100644 (file)
@@ -271,12 +271,24 @@ enum AirflowDirection
        propertyType(valueType val) : baseClass(property, val) {} \
        };
 
+#define PROPERTYTYPE1(property, propertyType, baseClass, valueType) \
+       class propertyType : public baseClass { \
+       public: propertyType(): baseClass(#property) {} \
+       propertyType(valueType val) : baseClass(#property, val) {} \
+       };
+
 #define PROPERTYTYPEBASIC(property, valueType) \
        class property ## Type : public BasicPropertyType<valueType> { \
        public: property ## Type(): BasicPropertyType(property) {} \
        property ## Type(valueType val) : BasicPropertyType(property, val) {} \
        };
 
+#define PROPERTYTYPEBASIC1(property, valueType) \
+       class property ## Type : public BasicPropertyType<valueType> { \
+       public: property ## Type(): BasicPropertyType("property") {} \
+       property ## Type(valueType val) : BasicPropertyType("property", val) {} \
+       };
+
 #define PROPERTYTYPENOVAL(property, propertyType, baseClass) \
        class propertyType : public baseClass { \
        public: propertyType(): baseClass(property) {} \
index a762fb3..833ced6 100644 (file)
@@ -129,11 +129,10 @@ DatabaseSink::DatabaseSink(AbstractRoutingEngine *engine, map<std::string, std::
        mSupported.push_back(DatabaseLoggingProperty);
        mSupported.push_back(DatabasePlaybackProperty);
 
+       /// get supported:
 
        initDb();
 
-       /// get supported:
-
        vector<vector<string> > supportedStr = shared->db->select("SELECT DISTINCT key FROM "+tablename);
 
        for(int i=0; i < supportedStr.size(); i++)
@@ -142,6 +141,9 @@ DatabaseSink::DatabaseSink(AbstractRoutingEngine *engine, map<std::string, std::
                        mSupported.push_back(supportedStr[i][0]);
        }
 
+       delete shared;
+       shared = NULL;
+
        routingEngine->setSupported(supported(), this);
 
        if(config.find("startOnLoad")!= config.end())
@@ -344,7 +346,7 @@ void DatabaseSink::getPropertyAsync(AsyncPropertyReply *reply)
 
        if(reply->property == DatabaseFileProperty)
        {
-               StringPropertyType temp(databaseName);
+               DatabaseFilePropertyType temp(databaseName);
                reply->value = &temp;
 
                reply->success = true;
index 8177746..aa88e82 100644 (file)
@@ -179,6 +179,11 @@ private:
        uint playbackMultiplier;
 };
 
+PROPERTYTYPEBASIC1(DatabaseLogging, bool)
+PROPERTYTYPEBASIC1(DatabasePlayback, bool)
+PROPERTYTYPE1(DatabaseFile, DatabaseFilePropertyType, StringPropertyType, std::string)
+
+
 class DatabaseSinkManager: public AbstractSinkManager
 {
 public:
@@ -186,9 +191,9 @@ public:
        :AbstractSinkManager(engine, config)
        {
                new DatabaseSink(routingEngine, config);
-               VehicleProperty::registerProperty(DatabaseLoggingProperty, [](){return new BasicPropertyType<bool>(false);});
-               VehicleProperty::registerProperty(DatabasePlaybackProperty, [](){return new BasicPropertyType<bool>(false);});
-VehicleProperty::registerProperty(DatabaseFileProperty, [](){return new StringPropertyType("out.ogg");});
+               VehicleProperty::registerProperty(DatabaseLoggingProperty, [](){return new DatabaseLoggingType(false);});
+               VehicleProperty::registerProperty(DatabasePlaybackProperty, [](){return new DatabasePlaybackType(false);});
+               VehicleProperty::registerProperty(DatabaseFileProperty, [](){return new DatabaseFilePropertyType("storage");});
        }
 };
 
index 4b8c2eb..2531e4f 100644 (file)
@@ -548,7 +548,7 @@ void OBD2Source::setConfiguration(map<string, string> config)
 OBD2Source::OBD2Source(AbstractRoutingEngine *re, map<string, string> config)
        : AbstractSource(re, config)
 {
-       bool success = VehicleProperty::registerProperty(Obd2Connected,[](){ return new Obd2ConnectType(false); });
+       bool success = VehicleProperty::registerProperty(Obd2Connected,[](){ return new Obd2ConnectType(Obd2Connected,false); });
 
        if(!success)
        {