summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/sdeventplus/source/child.cpp5
-rw-r--r--src/sdeventplus/source/child.hpp6
-rw-r--r--src/sdeventplus/source/event.cpp5
-rw-r--r--src/sdeventplus/source/event.hpp6
-rw-r--r--src/sdeventplus/source/io.cpp5
-rw-r--r--src/sdeventplus/source/io.hpp6
-rw-r--r--src/sdeventplus/source/signal.cpp5
-rw-r--r--src/sdeventplus/source/signal.hpp6
-rw-r--r--src/sdeventplus/source/time.cpp6
-rw-r--r--src/sdeventplus/source/time.hpp6
10 files changed, 56 insertions, 0 deletions
diff --git a/src/sdeventplus/source/child.cpp b/src/sdeventplus/source/child.cpp
index cda067b..b549473 100644
--- a/src/sdeventplus/source/child.cpp
+++ b/src/sdeventplus/source/child.cpp
@@ -14,6 +14,11 @@ Child::Child(const Event& event, pid_t pid, int options, Callback&& callback) :
{
}
+void Child::set_callback(Callback&& callback)
+{
+ this->callback = std::move(callback);
+}
+
pid_t Child::get_pid() const
{
pid_t pid;
diff --git a/src/sdeventplus/source/child.hpp b/src/sdeventplus/source/child.hpp
index 3a9857f..ed147d6 100644
--- a/src/sdeventplus/source/child.hpp
+++ b/src/sdeventplus/source/child.hpp
@@ -31,6 +31,12 @@ class Child : public Base
*/
Child(const Event& event, pid_t pid, int options, Callback&& callback);
+ /** @brief Sets the callback
+ *
+ * @param[in] callback - The function executed on event dispatch
+ */
+ void set_callback(Callback&& callback);
+
/** @brief Gets the pid of the child process being watched
*
* @return The child pid
diff --git a/src/sdeventplus/source/event.cpp b/src/sdeventplus/source/event.cpp
index 12d4d2b..c73f16c 100644
--- a/src/sdeventplus/source/event.cpp
+++ b/src/sdeventplus/source/event.cpp
@@ -7,6 +7,11 @@ namespace sdeventplus
namespace source
{
+void EventBase::set_callback(Callback&& callback)
+{
+ this->callback = std::move(callback);
+}
+
EventBase::EventBase(const char* name, CreateFunc create, const Event& event,
Callback&& callback) :
Base(event, create_source(name, create, event), std::false_type()),
diff --git a/src/sdeventplus/source/event.hpp b/src/sdeventplus/source/event.hpp
index cc23209..c384364 100644
--- a/src/sdeventplus/source/event.hpp
+++ b/src/sdeventplus/source/event.hpp
@@ -21,6 +21,12 @@ class EventBase : public Base
public:
using Callback = std::function<void(EventBase& source)>;
+ /** @brief Sets the callback
+ *
+ * @param[in] callback - The function executed on event dispatch
+ */
+ void set_callback(Callback&& callback);
+
protected:
using CreateFunc = decltype(&internal::SdEvent::sd_event_add_exit);
diff --git a/src/sdeventplus/source/io.cpp b/src/sdeventplus/source/io.cpp
index a325f91..49583d0 100644
--- a/src/sdeventplus/source/io.cpp
+++ b/src/sdeventplus/source/io.cpp
@@ -13,6 +13,11 @@ IO::IO(const Event& event, int fd, uint32_t events, Callback&& callback) :
{
}
+void IO::set_callback(Callback&& callback)
+{
+ this->callback = std::move(callback);
+}
+
int IO::get_fd() const
{
int r = event.getSdEvent()->sd_event_source_get_io_fd(source.get());
diff --git a/src/sdeventplus/source/io.hpp b/src/sdeventplus/source/io.hpp
index 61e9681..b35500e 100644
--- a/src/sdeventplus/source/io.hpp
+++ b/src/sdeventplus/source/io.hpp
@@ -32,6 +32,12 @@ class IO : public Base
*/
IO(const Event& event, int fd, uint32_t events, Callback&& callback);
+ /** @brief Sets the callback
+ *
+ * @param[in] callback - The function executed on event dispatch
+ */
+ void set_callback(Callback&& callback);
+
/** @brief Gets the file descriptor tied to the source
*
* @throws SdEventError for underlying sd_event errors
diff --git a/src/sdeventplus/source/signal.cpp b/src/sdeventplus/source/signal.cpp
index 1df3a29..98b1a05 100644
--- a/src/sdeventplus/source/signal.cpp
+++ b/src/sdeventplus/source/signal.cpp
@@ -14,6 +14,11 @@ Signal::Signal(const Event& event, int sig, Callback&& callback) :
{
}
+void Signal::set_callback(Callback&& callback)
+{
+ this->callback = std::move(callback);
+}
+
int Signal::get_signal() const
{
int r = event.getSdEvent()->sd_event_source_get_signal(source.get());
diff --git a/src/sdeventplus/source/signal.hpp b/src/sdeventplus/source/signal.hpp
index d5d9b5a..f62db44 100644
--- a/src/sdeventplus/source/signal.hpp
+++ b/src/sdeventplus/source/signal.hpp
@@ -33,6 +33,12 @@ class Signal : public Base
*/
Signal(const Event& event, int sig, Callback&& callback);
+ /** @brief Sets the callback
+ *
+ * @param[in] callback - The function executed on event dispatch
+ */
+ void set_callback(Callback&& callback);
+
/** @brief Gets the signum watched by the source
*
* @throws SdEventError for underlying sd_event errors
diff --git a/src/sdeventplus/source/time.cpp b/src/sdeventplus/source/time.cpp
index 1a24604..bbc3295 100644
--- a/src/sdeventplus/source/time.cpp
+++ b/src/sdeventplus/source/time.cpp
@@ -20,6 +20,12 @@ Time<Id>::Time(const Event& event, TimePoint time, Accuracy accuracy,
}
template <ClockId Id>
+void Time<Id>::set_callback(Callback&& callback)
+{
+ this->callback = std::move(callback);
+}
+
+template <ClockId Id>
typename Time<Id>::TimePoint Time<Id>::get_time() const
{
uint64_t usec;
diff --git a/src/sdeventplus/source/time.hpp b/src/sdeventplus/source/time.hpp
index c43de7a..ef79803 100644
--- a/src/sdeventplus/source/time.hpp
+++ b/src/sdeventplus/source/time.hpp
@@ -40,6 +40,12 @@ class Time : public Base
Time(const Event& event, TimePoint time, Accuracy accuracy,
Callback&& callback);
+ /** @brief Sets the callback
+ *
+ * @param[in] callback - The function executed on event dispatch
+ */
+ void set_callback(Callback&& callback);
+
/** @brief Gets the absolute time when the time source expires
*
* @throws SdEventError for underlying sd_event errors
OpenPOWER on IntegriCloud