SNode.C
Loading...
Searching...
No Matches
DescriptorEventPublisher.h
Go to the documentation of this file.
1/*
2 * SNode.C - a slim toolkit for network communication
3 * Copyright (C) Volker Christian <me@vchrist.at>
4 * 2020, 2021, 2022, 2023, 2024, 2025
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as published
8 * by the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef CORE_DESCRIPTOREVENTPUBLISHER_H
21#define CORE_DESCRIPTOREVENTPUBLISHER_H
22
23namespace core {
25} // namespace core
26
27namespace utils {
28 class Timeval;
29} // namespace utils
30
31#ifndef DOXYGEN_SHOULD_SKIP_THIS
32
33#include <list>
34#include <map>
35#include <string>
36
37#endif /* DOXYGEN_SHOULD_SKIP_THIS */
38
39namespace core {
40
42 public:
43 protected:
44 DescriptorEventPublisher(std::string name);
45
46 public:
48
49 virtual ~DescriptorEventPublisher();
50
53
54 void enable(DescriptorEventReceiver* descriptorEventReceiver);
55 void disable(DescriptorEventReceiver* descriptorEventReceiver);
56 void suspend(DescriptorEventReceiver* descriptorEventReceiver);
57 void resume(DescriptorEventReceiver* descriptorEventReceiver);
58
59 virtual void spanActiveEvents() = 0;
60 void checkTimedOutEvents(const utils::Timeval& currentTime);
61 void releaseDisabledEvents(const utils::Timeval& currentTime);
62
64 int maxFd() const;
65
66 utils::Timeval getNextTimeout(const utils::Timeval& currentTime) const;
67
68 void signal(int sigNum);
69 void disable();
70
71 const std::string& getName() const;
72
73 protected:
75 unsigned long eventCounter = 0;
76
77 private:
78 virtual void muxAdd(DescriptorEventReceiver* descriptorEventReceiver) = 0;
79 virtual void muxDel(int fd) = 0;
80 virtual void muxOn(DescriptorEventReceiver* descriptorEventReceiver) = 0;
81 virtual void muxOff(DescriptorEventReceiver* descriptorEventReceiver) = 0;
82
83 std::string name;
85 };
86
87} // namespace core
88
89#endif // CORE_DESCRIPTOREVENTPUBLISHER_H
virtual void muxAdd(DescriptorEventReceiver *descriptorEventReceiver)=0
utils::Timeval getNextTimeout(const utils::Timeval &currentTime) const
void checkTimedOutEvents(const utils::Timeval &currentTime)
virtual void muxDel(int fd)=0
DescriptorEventPublisher(const DescriptorEventPublisher &)=delete
virtual void muxOff(DescriptorEventReceiver *descriptorEventReceiver)=0
DescriptorEventPublisher & operator=(const DescriptorEventPublisher &)=delete
void releaseDisabledEvents(const utils::Timeval &currentTime)
virtual void muxOn(DescriptorEventReceiver *descriptorEventReceiver)=0
void disable(DescriptorEventReceiver *descriptorEventReceiver)
virtual void spanActiveEvents()=0
void enable(DescriptorEventReceiver *descriptorEventReceiver)
std::map< int, std::list< DescriptorEventReceiver * > > observedEventReceiverLists
void suspend(DescriptorEventReceiver *descriptorEventReceiver)
void resume(DescriptorEventReceiver *descriptorEventReceiver)
void setEnabled(const utils::Timeval &currentTime)
static Timeval currentTime()
Definition Timeval.cpp:54
Timeval & operator=(const Timeval &timeVal)
Definition Timeval.cpp:61