summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Delbeke <olivier.delbeke@awtce.be>2015-04-08 17:29:14 +0200
committerOlivier Delbeke <olivier.delbeke@gmail.com>2015-04-15 20:15:41 +0200
commitfe610d9b3b1b569f7c9772733ddb0cc6e75532bf (patch)
treeae13c8115b3e031a014a9b564f8e7d2052bb93eb
parent7d26c469f4ccc3387ba8eaf37ad8108c8ae72686 (diff)
downloadautomotive-message-broker-fe610d9b3b1b569f7c9772733ddb0cc6e75532bf.tar.gz
Using AmbPlugin instead of AbstractSink for the chrony plugin
-rw-r--r--plugins/chrony/chrony.cpp22
-rw-r--r--plugins/chrony/chrony.h12
2 files changed, 20 insertions, 14 deletions
diff --git a/plugins/chrony/chrony.cpp b/plugins/chrony/chrony.cpp
index 0674427e..8f122487 100644
--- a/plugins/chrony/chrony.cpp
+++ b/plugins/chrony/chrony.cpp
@@ -1,5 +1,6 @@
/*
Copyright (C) 2012 Intel Corporation
+ Copyright (C) 2015 AWTC Europe
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -18,6 +19,7 @@
#include "chrony.h"
+#include "ambplugin.h"
#include "abstractroutingengine.h"
#include "debugout.h"
#include "listplusplus.h"
@@ -29,17 +31,21 @@
#include <sys/time.h>
#include <math.h>
-#define GPSTIME "GpsTime"
-
extern "C" void create(AbstractRoutingEngine* routingEngine, map<string, string> config)
{
- new ChronySink(routingEngine, config);
+ auto plugin = new AmbPlugin<ChronySink>(routingEngine, config);
+ plugin->init();
+}
+
+ChronySink::ChronySink(AbstractRoutingEngine* re, const std::map<std::string, std::string>& config, AbstractSource& parent)
+ :AmbPluginImpl(re, config, parent)
+{
+ supportedChanged(re->supported());
}
-ChronySink::ChronySink(AbstractRoutingEngine* engine, map<string, string> config): AbstractSink(engine, config)
+void ChronySink::init()
{
- routingEngine->subscribeToProperty(GPSTIME, this);
- supportedChanged(engine->supported());
+ routingEngine->subscribeToProperty("GpsTime", &source);
}
PropertyList ChronySink::subscriptions()
@@ -79,7 +85,3 @@ void ChronySink::propertyChanged(AbstractPropertyType *value)
close(sockfd);
}
-const string ChronySink::uuid()
-{
- return "35324592-db72-11e4-b432-0022684a4a24";
-}
diff --git a/plugins/chrony/chrony.h b/plugins/chrony/chrony.h
index aca57a3a..25da7e06 100644
--- a/plugins/chrony/chrony.h
+++ b/plugins/chrony/chrony.h
@@ -1,5 +1,6 @@
/*
Copyright (C) 2012 Intel Corporation
+ Copyright (C) 2015 AWTC Europe
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -20,7 +21,7 @@
#ifndef CHRONYSINK_H
#define CHRONYSINK_H
-#include "abstractsink.h"
+#include "ambpluginimpl.h"
#define CHRONYD_SOCKET "/tmp/chrony.gps.sock"
@@ -33,15 +34,18 @@ struct chrony_sock_sample {
int magic;
};
-class ChronySink : public AbstractSink
+class ChronySink : public AmbPluginImpl
{
public:
- ChronySink(AbstractRoutingEngine* engine, map<string, string> config);
+ ChronySink(AbstractRoutingEngine* re, const std::map<std::string, std::string>& config, AbstractSource& parent);
+ ~ChronySink() { };
+ const std::string uuid() const { return "35324592-db72-11e4-b432-0022684a4a24"; }
+ virtual void init();
virtual PropertyList subscriptions();
virtual void supportedChanged(const PropertyList & supportedProperties);
virtual void propertyChanged( AbstractPropertyType* value);
- virtual const std::string uuid();
+
};
#endif // CHRONYSINK_H