MythTV
master
mythtv
libs
libmythupnp
ssdpcache.h
Go to the documentation of this file.
1
// Program Name: ssdpcache.h
3
// Created : Jan. 8, 2007
4
//
5
// Purpose : SSDP Cache Declaration
6
//
7
// Copyright (c) 2007 David Blain <dblain@mythtv.org>
8
//
9
// Licensed under the GPL v2 or later, see LICENSE for details
10
//
12
13
#ifndef SSDPCLIENT_H
14
#define SSDPCLIENT_H
15
16
// Qt headers
17
#include <QObject>
18
#include <QMutex>
19
#include <QMap>
20
21
// MythTV headers
22
#include "
libmythbase/mythobservable.h
"
23
#include "
libmythbase/referencecounter.h
"
24
25
#include "
upnpdevice.h
"
26
#include "
upnpexp.h
"
27
29
using
EntryMap
= QMap< QString, DeviceLocation * >;
30
32
// QDict Implementation that uses RefCounted pointers
34
35
class
UPNP_PUBLIC
SSDPCacheEntries
:
public
ReferenceCounter
36
{
37
protected
:
39
~
SSDPCacheEntries
()
override
;
40
41
public
:
42
SSDPCacheEntries
();
43
44
void
Clear
(
void
);
45
uint
Count
(
void
)
const
46
{ QMutexLocker locker(&m_mutex);
return
m_mapEntries.size(); }
47
void
Insert(
const
QString &sUSN,
DeviceLocation
*pEntry);
48
void
Remove(
const
QString &sUSN);
49
uint
RemoveStale(
TaskTime
ttNow);
50
51
DeviceLocation
*Find(
const
QString &sUSN);
52
53
DeviceLocation
*GetFirst(
void
);
54
55
void
GetEntryMap(
EntryMap
&map);
56
57
QTextStream &OutputXML(QTextStream &os,
uint
*pnEntryCount =
nullptr
)
const
;
58
void
Dump(
uint
&nEntryCount)
const
;
59
60
static
QString GetNormalizedUSN(
const
QString &sUSN);
61
62
public
:
63
static
int
g_nAllocated
;
// Debugging only
64
65
protected
:
66
mutable
QMutex
m_mutex
;
67
EntryMap
m_mapEntries
;
68
};
69
71
using
SSDPCacheEntriesMap
= QMap< QString, SSDPCacheEntries * >;
72
75
//
76
// SSDPCache Class Definition - (Singleton)
77
//
80
81
class
UPNP_PUBLIC
SSDPCache
:
public
QObject,
82
public
MythObservable
83
{
84
Q_OBJECT
85
86
private
:
87
// Singleton instance used by all.
88
static
SSDPCache
*
g_pSSDPCache
;
89
QStringList
m_badUrlList
;
90
QStringList
m_goodUrlList
;
91
92
protected
:
93
94
mutable
QMutex
m_mutex
;
95
SSDPCacheEntriesMap
m_cache
;
96
97
void
NotifyAdd (
const
QString &sURI,
98
const
QString &sUSN,
99
const
QString &
sLocation
);
100
void
NotifyRemove(
const
QString &sURI,
const
QString &sUSN );
101
102
private
:
103
104
// ------------------------------------------------------------------
105
// Private so the singleton pattern can be enforced.
106
// ------------------------------------------------------------------
107
108
SSDPCache
();
109
Q_DISABLE_COPY(
SSDPCache
)
110
111
public
:
112
113
static
SSDPCache
* Instance();
114
115
~
SSDPCache
()
override
;
116
117
void
Lock
() { m_mutex.lock(); }
118
void
Unlock
() { m_mutex.unlock(); }
119
120
SSDPCacheEntriesMap::Iterator
Begin
() {
return
m_cache.begin(); }
121
SSDPCacheEntriesMap::Iterator
End
() {
return
m_cache.end(); }
122
123
int
Count
() {
return
m_cache.count(); }
124
void
Clear
();
125
void
Add (
const
QString &sURI,
126
const
QString &sUSN,
127
const
QString &
sLocation
,
128
std::chrono::seconds sExpiresInSecs );
129
130
void
Remove (
const
QString &sURI,
const
QString &sUSN );
131
int
RemoveStale( );
132
133
void
Dump (
void
);
134
135
QTextStream &OutputXML(QTextStream &os,
136
uint
*pnDevCount =
nullptr
,
137
uint
*pnEntryCount =
nullptr
)
const
;
138
139
SSDPCacheEntries
*Find(
const
QString &sURI );
140
DeviceLocation
*Find(
const
QString &sURI,
const
QString &sUSN );
141
};
142
143
#endif // SSDPCLIENT_H
SSDPCache::m_badUrlList
QStringList m_badUrlList
Definition:
ssdpcache.h:89
upnpdevice.h
TaskTime
std::chrono::microseconds TaskTime
Definition:
upnputil.h:31
SSDPCache::Lock
void Lock()
Definition:
ssdpcache.h:117
MythObservable
Superclass for making an object have a set of listeners.
Definition:
mythobservable.h:11
SSDPCache
Definition:
ssdpcache.h:81
DeviceLocation
Definition:
upnpdevice.h:210
SSDPCache::Begin
SSDPCacheEntriesMap::Iterator Begin()
Definition:
ssdpcache.h:120
SSDPCache::g_pSSDPCache
static SSDPCache * g_pSSDPCache
Definition:
ssdpcache.h:88
SSDPCacheEntries::m_mapEntries
EntryMap m_mapEntries
Definition:
ssdpcache.h:67
SSDPCache::m_cache
SSDPCacheEntriesMap m_cache
Definition:
ssdpcache.h:95
SSDPCache::Count
int Count()
Definition:
ssdpcache.h:123
EntryMap
QMap< QString, DeviceLocation * > EntryMap
Key == Unique Service Name (USN)
Definition:
ssdpcache.h:29
SSDPCache::Unlock
void Unlock()
Definition:
ssdpcache.h:118
SSDPCache::m_goodUrlList
QStringList m_goodUrlList
Definition:
ssdpcache.h:90
sLocation
static const QString sLocation
Definition:
mythcontext.cpp:66
SSDPCacheEntries
Definition:
ssdpcache.h:35
SSDPCache::m_mutex
QMutex m_mutex
Definition:
ssdpcache.h:94
referencecounter.h
SSDPCacheEntries::g_nAllocated
static int g_nAllocated
Definition:
ssdpcache.h:63
Clear
#define Clear(a)
Definition:
audiooutputopensles.cpp:54
UPNP_PUBLIC
#define UPNP_PUBLIC
Definition:
upnpexp.h:9
SSDPCacheEntries::m_mutex
QMutex m_mutex
Definition:
ssdpcache.h:66
SSDPCacheEntries::Count
uint Count(void) const
Definition:
ssdpcache.h:45
SSDPCache::End
SSDPCacheEntriesMap::Iterator End()
Definition:
ssdpcache.h:121
ReferenceCounter
General purpose reference counter.
Definition:
referencecounter.h:26
mythobservable.h
SSDPCacheEntriesMap
QMap< QString, SSDPCacheEntries * > SSDPCacheEntriesMap
Key == Service Type URI.
Definition:
ssdpcache.h:71
uint
unsigned int uint
Definition:
freesurround.h:24
upnpexp.h
Generated on Mon Jan 6 2025 03:16:55 for MythTV by
1.8.17