{
"name" : "Database",
"path" : "/usr/lib/automotive-message-broker/databasesinkplugin.so",
- "properties" : "{ 'properties' : ['VehicleSpeed','EngineSpeed'] }"
+ "properties" : "{ 'properties' : ['VehicleSpeed','EngineSpeed'] }",
+ "startOnLoad" : "true"
}
],
"sinks": [
#include <list>
#include "timestamp.h"
#include <debugout.h>
+#include <boost/algorithm/string.hpp>
+
namespace Zone {
enum Type {
None = 0,
{
return g_variant_get_int32(v);
}
+
+ static std::string stringize(std::string v)
+ {
+ return v;
+ }
};
template <>
{
return g_variant_get_double(v);
}
+ static std::string stringize(std::string v)
+ {
+ return v;
+ }
};
template <>
{
return g_variant_get_uint16(v);
}
+ static std::string stringize(std::string v)
+ {
+ return v;
+ }
};
template <>
{
return g_variant_get_int16(v);
}
+ static std::string stringize(std::string v)
+ {
+ return v;
+ }
};
template <>
{
return g_variant_get_byte(v);
}
+ static std::string stringize(std::string v)
+ {
+ return v;
+ }
};
template <>
{
return g_variant_get_uint32(v);
}
+ static std::string stringize(std::string v)
+ {
+ return v;
+ }
};
template <>
{
return g_variant_get_int64(v);
}
+ static std::string stringize(std::string v)
+ {
+ return v;
+ }
};
template <>
{
g_variant_get_uint64(v);
}
+ static std::string stringize(std::string v)
+ {
+ return v;
+ }
};
template <>
{
return g_variant_get_boolean(v);
}
+ static std::string stringize(std::string v)
+ {
+ boost::algorithm::to_lower(v);
+ return v == "true" ? "1":"0";
+ }
};
template <class N>
void serialize(std::string val, typename std::enable_if<!std::is_enum<N>::value, N>::type* = 0)
{
- std::stringstream stream(val);
+ std::stringstream stream(GVS<T>::stringize(val));
N someTemp;
stream>>someTemp;
setValue(someTemp);
#define PROPERTYTYPEBASIC1(property, valueType) \
class property ## Type : public BasicPropertyType<valueType> { \
- public: property ## Type(): BasicPropertyType("property") {} \
- property ## Type(valueType val) : BasicPropertyType("property", val) {} \
+ public: property ## Type(): BasicPropertyType( #property) {} \
+ property ## Type(valueType val) : BasicPropertyType(#property, val) {} \
};
#define PROPERTYTYPENOVAL(property, propertyType, baseClass) \
mValue->fromString(json.toStdString());
}
+
+
else
- mValue->fromString(v.toString().toStdString());
+ {
+ QString tempVal = v.toString();
+ mValue->fromString(tempVal.toStdString());
+ }
AsyncSetPropertyRequest request;
request.property = mValue->name;
engine->subscribeToProperty(*itr,this);
}
- mSupported.push_back(DatabaseFileProperty);
- mSupported.push_back(DatabaseLoggingProperty);
- mSupported.push_back(DatabasePlaybackProperty);
+ mSupported.push_back(DatabaseFile);
+ mSupported.push_back(DatabaseLogging);
+ mSupported.push_back(DatabasePlayback);
routingEngine->setSupported(supported(), this);
void DatabaseSink::setPlayback(bool v)
{
AsyncSetPropertyRequest request;
- request.property = DatabasePlaybackProperty;
+ request.property = DatabasePlayback;
request.value = new DatabasePlaybackType(v);
setProperty(request);
void DatabaseSink::setLogging(bool b)
{
AsyncSetPropertyRequest request;
- request.property = DatabaseLoggingProperty;
+ request.property = DatabaseLogging;
request.value = new DatabaseLoggingType(b);
setProperty(request);
{
reply->success = false;
- if(reply->property == DatabaseFileProperty)
+ if(reply->property == DatabaseFile)
{
- DatabaseFilePropertyType temp(databaseName);
+ DatabaseFileType temp(databaseName);
reply->value = &temp;
reply->success = true;
return;
}
- else if(reply->property == DatabaseLoggingProperty)
+ else if(reply->property == DatabaseLogging)
{
- BasicPropertyType<bool> temp = shared;
+ DatabaseLoggingType temp = shared;
reply->value = &temp;
reply->success = true;
return;
}
- else if(reply->property == DatabasePlaybackProperty)
+ else if(reply->property == DatabasePlayback)
{
- BasicPropertyType<bool> temp = playback;
+ DatabasePlaybackType temp = playback;
reply->value = &temp;
reply->success = true;
reply->completed(reply);
AsyncPropertyReply* reply = new AsyncPropertyReply(request);
reply->success = false;
- if(request.property == DatabaseLoggingProperty)
+ if(request.property == DatabaseLogging)
{
if(request.value->value<bool>())
{
setPlayback(false);
startDb();
reply->success = true;
- BasicPropertyType<bool> temp(true);
- routingEngine->updateProperty(DatabaseLoggingProperty,&temp,uuid());
+ DatabaseLoggingType temp(true);
+ routingEngine->updateProperty(DatabaseLogging,&temp,uuid());
}
else
{
stopDb();
reply->success = true;
- BasicPropertyType<bool> temp(false);
- routingEngine->updateProperty(DatabaseLoggingProperty,&temp,uuid());
+ DatabaseLoggingType temp(false);
+ routingEngine->updateProperty(DatabaseLogging,&temp,uuid());
}
}
- else if(request.property == DatabaseFileProperty)
+ else if(request.property == DatabaseFile)
{
std::string fname = request.value->toString();
databaseName = fname;
- StringPropertyType temp(databaseName);
+ DatabaseFileType temp(databaseName);
- routingEngine->updateProperty(DatabaseFileProperty,&temp,uuid());
+ routingEngine->updateProperty(DatabaseFile,&temp,uuid());
reply->success = true;
}
- else if( request.property == DatabasePlaybackProperty)
+ else if( request.property == DatabasePlayback)
{
if(request.value->value<bool>())
{
setLogging(false);
startPlayback();
- BasicPropertyType<bool> temp(playback);
+ DatabasePlaybackType temp(playback);
- routingEngine->updateProperty(DatabasePlaybackProperty,&temp,uuid());
+ routingEngine->updateProperty(DatabasePlayback,&temp,uuid());
}
else
{
playback = false;
- BasicPropertyType<bool> temp(playback);
+ DatabasePlaybackType temp(playback);
- routingEngine->updateProperty(DatabasePlaybackProperty, &temp, uuid());
+ routingEngine->updateProperty(DatabasePlayback, &temp, uuid());
}
reply->success = true;
#include <functional>
-#define DatabaseLoggingProperty "DatabaseLogging"
-#define DatabasePlaybackProperty "DatabasePlayback"
-#define DatabaseFileProperty "DatabaseFile"
+const std::string DatabaseLogging = "DatabaseLogging";
+const std::string DatabasePlayback = "DatabasePlayback";
+const std::string DatabaseFile = "DatabaseFile";
template <typename T>
class Queue
uint playbackMultiplier;
};
-PROPERTYTYPEBASIC1(DatabaseLogging, bool)
-PROPERTYTYPEBASIC1(DatabasePlayback, bool)
-PROPERTYTYPE1(DatabaseFile, DatabaseFilePropertyType, StringPropertyType, std::string)
+PROPERTYTYPEBASIC(DatabaseLogging, bool)
+PROPERTYTYPEBASIC(DatabasePlayback, bool)
+PROPERTYTYPE(DatabaseFile, DatabaseFileType, StringPropertyType, std::string)
class DatabaseSinkManager: public AbstractSinkManager
:AbstractSinkManager(engine, config)
{
new DatabaseSink(routingEngine, config);
- VehicleProperty::registerProperty(DatabaseLoggingProperty, [](){return new DatabaseLoggingType(false);});
- VehicleProperty::registerProperty(DatabasePlaybackProperty, [](){return new DatabasePlaybackType(false);});
- VehicleProperty::registerProperty(DatabaseFileProperty, [](){return new DatabaseFilePropertyType("storage");});
+ VehicleProperty::registerProperty(DatabaseLogging, [](){return new DatabaseLoggingType(false);});
+ VehicleProperty::registerProperty(DatabasePlayback, [](){return new DatabasePlaybackType(false);});
+ VehicleProperty::registerProperty(DatabaseFile, [](){return new DatabaseFileType("storage");});
}
};