event: Constify sdevent
diff --git a/src/sdeventplus/event.cpp b/src/sdeventplus/event.cpp
index 897f549..e8e8d19 100644
--- a/src/sdeventplus/event.cpp
+++ b/src/sdeventplus/event.cpp
@@ -3,24 +3,26 @@
#include <sdeventplus/exception.hpp>
#include <sdeventplus/internal/sdevent.hpp>
#include <systemd/sd-event.h>
+#include <type_traits>
namespace sdeventplus
{
-Event::Event(sd_event* event, internal::SdEvent* sdevent) :
+Event::Event(sd_event* event, const internal::SdEvent* sdevent) :
sdevent(sdevent), event(event, &internal::SdEvent::sd_event_ref,
&internal::SdEvent::sd_event_unref, sdevent)
{
}
-Event::Event(sd_event* event, std::false_type, internal::SdEvent* sdevent) :
+Event::Event(sd_event* event, std::false_type,
+ const internal::SdEvent* sdevent) :
sdevent(sdevent),
event(event, &internal::SdEvent::sd_event_ref,
&internal::SdEvent::sd_event_unref, std::false_type(), sdevent)
{
}
-Event Event::get_new(internal::SdEvent* sdevent)
+Event Event::get_new(const internal::SdEvent* sdevent)
{
sd_event* event = nullptr;
int r = sdevent->sd_event_new(&event);
@@ -31,7 +33,7 @@
return Event(event, std::false_type(), sdevent);
}
-Event Event::get_default(internal::SdEvent* sdevent)
+Event Event::get_default(const internal::SdEvent* sdevent)
{
sd_event* event = nullptr;
int r = sdevent->sd_event_default(&event);
diff --git a/src/sdeventplus/event.hpp b/src/sdeventplus/event.hpp
index f55e9fa..e7c007f 100644
--- a/src/sdeventplus/event.hpp
+++ b/src/sdeventplus/event.hpp
@@ -11,19 +11,21 @@
{
public:
Event(sd_event* event,
- internal::SdEvent* sdevent = &internal::sdevent_impl);
+ const internal::SdEvent* sdevent = &internal::sdevent_impl);
Event(sd_event* event, std::false_type,
- internal::SdEvent* sdevent = &internal::sdevent_impl);
- static Event get_new(internal::SdEvent* sdevent = &internal::sdevent_impl);
+ const internal::SdEvent* sdevent = &internal::sdevent_impl);
+
static Event
- get_default(internal::SdEvent* sdevent = &internal::sdevent_impl);
+ get_new(const internal::SdEvent* sdevent = &internal::sdevent_impl);
+ static Event
+ get_default(const internal::SdEvent* sdevent = &internal::sdevent_impl);
int loop();
int get_watchdog();
int set_watchdog(int b);
private:
- internal::SdEvent* sdevent;
+ const internal::SdEvent* sdevent;
internal::SdRef<sd_event> event;
};