libzypp
17.22.0
abstracteventsource.cc
Go to the documentation of this file.
1
#include "
abstracteventsource.h
"
2
#include "
private/abstracteventsource_p.h
"
3
#include "
eventdispatcher.h
"
4
#include "
private/base_p.h
"
5
6
#include <
zypp/base/Exception.h
>
7
8
namespace
zyppng
{
9
10
AbstractEventSourcePrivate::AbstractEventSourcePrivate
()
11
{
12
auto
ev =
EventDispatcher::instance
();
13
if
( !ev )
14
ZYPP_THROW
(
zypp::Exception
(
"Creating event sources without a EventDispatcher instance is not supported"
) );
15
_ev
= ev;
16
}
17
18
AbstractEventSource::AbstractEventSource
()
19
:
Base
( * new
AbstractEventSourcePrivate
)
20
{ }
21
22
AbstractEventSource::AbstractEventSource
(
AbstractEventSourcePrivate
&dd )
23
:
Base
( dd )
24
{ }
25
26
AbstractEventSource::~AbstractEventSource
()
27
{
28
Z_D
();
29
auto
ev = d->_ev.lock();
30
//if ev is null , eventloop is shutting down
31
if
( ev )
32
ev->removeEventSource(
this
);
33
}
34
35
std::weak_ptr<EventDispatcher>
AbstractEventSource::eventDispatcher
()
const
36
{
37
return
d_func()->_ev;
38
}
39
40
void
AbstractEventSource::updateFdWatch
(
int
fd,
int
mode)
41
{
42
auto
ev = d_func()->_ev.lock();
43
44
//if ev is null we are shutting down
45
if
( !ev )
46
return
;
47
ev->updateEventSource(
this
, fd, mode );
48
}
49
50
void
AbstractEventSource::removeFdWatch
(
int
fd)
51
{
52
auto
ev = d_func()->_ev.lock();
53
54
//if ev is null we are shutting down
55
if
( !ev )
56
return
;
57
ev->removeEventSource(
this
, fd );
58
}
59
60
}
zyppng::AbstractEventSourcePrivate::_ev
std::weak_ptr< EventDispatcher > _ev
Definition:
abstracteventsource_p.h:28
zyppng::AbstractEventSourcePrivate
Definition:
abstracteventsource_p.h:22
eventdispatcher.h
zyppng::AbstractEventSource::eventDispatcher
std::weak_ptr< EventDispatcher > eventDispatcher() const
Definition:
abstracteventsource.cc:35
Z_D
#define Z_D()
Definition:
zyppglobal.h:44
zypp::Exception
Base class for Exception.
Definition:
Exception.h:145
zyppng::AbstractEventSource::removeFdWatch
void removeFdWatch(int fd)
Definition:
abstracteventsource.cc:50
zyppng::AbstractEventSource::~AbstractEventSource
virtual ~AbstractEventSource()
Definition:
abstracteventsource.cc:26
zyppng::AbstractEventSource::AbstractEventSource
AbstractEventSource()
Definition:
abstracteventsource.cc:18
ZYPP_THROW
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
Definition:
Exception.h:392
zyppng::Base
Definition:
base.h:32
Exception.h
base_p.h
zyppng::AbstractEventSource::updateFdWatch
void updateFdWatch(int fd, int mode)
Definition:
abstracteventsource.cc:40
abstracteventsource.h
zyppng::AbstractEventSourcePrivate::AbstractEventSourcePrivate
AbstractEventSourcePrivate()
Definition:
abstracteventsource.cc:10
abstracteventsource_p.h
zyppng
Definition:
abstracteventsource.cc:8
zyppng::EventDispatcher::instance
static std::shared_ptr< EventDispatcher > instance()
Definition:
eventdispatcher_glib.cc:472
zypp
zyppng
base
abstracteventsource.cc
Generated by
1.8.16