10a816c5dSWilliam A. Kennington III #pragma once 20a816c5dSWilliam A. Kennington III 365db863eSWilliam A. Kennington III #include <cstdint> 4*48c42751SWilliam A. Kennington III #include <functional> 50a816c5dSWilliam A. Kennington III #include <sdeventplus/internal/sdevent.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: 18*48c42751SWilliam A. Kennington III using Callback = std::function<void(Base& source)>; 19*48c42751SWilliam 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 28*48c42751SWilliam A. Kennington III int prepareCallback(); 29*48c42751SWilliam A. Kennington III 3065db863eSWilliam A. Kennington III const char* get_description(); 3165db863eSWilliam A. Kennington III void set_description(const char* description); 32*48c42751SWilliam A. Kennington III void set_prepare(Callback&& callback); 3365db863eSWilliam A. Kennington III int get_pending(); 3465db863eSWilliam A. Kennington III int64_t get_priority(); 3565db863eSWilliam A. Kennington III void set_priority(int64_t priority); 3665db863eSWilliam A. Kennington III int get_enabled(); 3765db863eSWilliam A. Kennington III void set_enabled(int enabled); 3865db863eSWilliam A. Kennington III 390a816c5dSWilliam A. Kennington III protected: 4065db863eSWilliam A. Kennington III const internal::SdEvent* const sdevent; 4165db863eSWilliam A. Kennington III const internal::SdRef<sd_event_source> source; 420a816c5dSWilliam A. Kennington III 430a816c5dSWilliam A. Kennington III // Base sources cannot be directly constructed. 440a816c5dSWilliam A. Kennington III Base(sd_event_source* source, 450a816c5dSWilliam A. Kennington III internal::SdEvent* sdevent = &internal::sdevent_impl); 460a816c5dSWilliam A. Kennington III Base(sd_event_source* source, std::false_type, 470a816c5dSWilliam A. Kennington III internal::SdEvent* sdevent = &internal::sdevent_impl); 48*48c42751SWilliam A. Kennington III 49*48c42751SWilliam A. Kennington III private: 50*48c42751SWilliam A. Kennington III Callback prepare; 510a816c5dSWilliam A. Kennington III }; 520a816c5dSWilliam A. Kennington III 530a816c5dSWilliam A. Kennington III } // namespace source 540a816c5dSWilliam A. Kennington III } // namespace sdeventplus 55