10a816c5dSWilliam A. Kennington III #pragma once
20a816c5dSWilliam A. Kennington III 
365db863eSWilliam A. Kennington III #include <cstdint>
448c42751SWilliam A. Kennington III #include <functional>
5715c72f8SWilliam A. Kennington III #include <sdeventplus/event.hpp>
60a816c5dSWilliam A. Kennington III #include <sdeventplus/internal/sdref.hpp>
70a816c5dSWilliam A. Kennington III #include <systemd/sd-bus.h>
80a816c5dSWilliam A. Kennington III #include <type_traits>
90a816c5dSWilliam A. Kennington III 
100a816c5dSWilliam A. Kennington III namespace sdeventplus
110a816c5dSWilliam A. Kennington III {
120a816c5dSWilliam A. Kennington III namespace source
130a816c5dSWilliam A. Kennington III {
140a816c5dSWilliam A. Kennington III 
150a816c5dSWilliam A. Kennington III class Base
160a816c5dSWilliam A. Kennington III {
170a816c5dSWilliam A. Kennington III   public:
1848c42751SWilliam A. Kennington III     using Callback = std::function<void(Base& source)>;
1948c42751SWilliam A. Kennington III 
2065db863eSWilliam A. Kennington III     virtual ~Base();
2165db863eSWilliam A. Kennington III 
220a816c5dSWilliam A. Kennington III     // We don't want to allow any kind of slicing.
230a816c5dSWilliam A. Kennington III     Base(const Base& source) = delete;
240a816c5dSWilliam A. Kennington III     Base& operator=(const Base& source) = delete;
250a816c5dSWilliam A. Kennington III     Base(Base&& source) = delete;
260a816c5dSWilliam A. Kennington III     Base& operator=(Base&& source) = delete;
270a816c5dSWilliam A. Kennington III 
2848c42751SWilliam A. Kennington III     int prepareCallback();
2948c42751SWilliam A. Kennington III 
30*4863b96bSWilliam A. Kennington III     sd_event_source* get() const;
31715c72f8SWilliam A. Kennington III     const Event& get_event() const;
32715c72f8SWilliam A. Kennington III 
33d9fd9815SWilliam A. Kennington III     const char* get_description() const;
34d9fd9815SWilliam A. Kennington III     void set_description(const char* description) const;
3548c42751SWilliam A. Kennington III     void set_prepare(Callback&& callback);
36d9fd9815SWilliam A. Kennington III     int get_pending() const;
37d9fd9815SWilliam A. Kennington III     int64_t get_priority() const;
38d9fd9815SWilliam A. Kennington III     void set_priority(int64_t priority) const;
39d9fd9815SWilliam A. Kennington III     int get_enabled() const;
40d9fd9815SWilliam A. Kennington III     void set_enabled(int enabled) const;
4165db863eSWilliam A. Kennington III 
420a816c5dSWilliam A. Kennington III   protected:
43715c72f8SWilliam A. Kennington III     const Event event;
4465db863eSWilliam A. Kennington III     const internal::SdRef<sd_event_source> source;
450a816c5dSWilliam A. Kennington III 
460a816c5dSWilliam A. Kennington III     // Base sources cannot be directly constructed.
47715c72f8SWilliam A. Kennington III     Base(const Event& event, sd_event_source* source);
48715c72f8SWilliam A. Kennington III     Base(const Event& event, sd_event_source* source, std::false_type);
4948c42751SWilliam A. Kennington III 
5048c42751SWilliam A. Kennington III   private:
5148c42751SWilliam A. Kennington III     Callback prepare;
520a816c5dSWilliam A. Kennington III };
530a816c5dSWilliam A. Kennington III 
540a816c5dSWilliam A. Kennington III } // namespace source
550a816c5dSWilliam A. Kennington III } // namespace sdeventplus
56