38 m_ttLastNotified = 0us;
39 m_sUUID = QUuid::createUuid().toString();
40 m_sUUID = m_sUUID.mid( 1, m_sUUID.length() - 2);
44 : m_qURL(url), m_nDuration( duration )
47 m_ttLastNotified = 0us;
48 m_sUUID = QUuid::createUuid().toString();
49 m_sUUID = m_sUUID.mid( 1, m_sUUID.length() - 2);
51 SetExpireTime( m_nDuration );
63 std::chrono::microseconds m_ttExpires {};
64 std::chrono::microseconds m_ttLastNotified {};
68 unsigned short m_nKey {0};
69 std::chrono::seconds m_nDuration {0s};
75 m_ttExpires = nowAsDuration<std::chrono::microseconds>() + secs;
95 std::chrono::microseconds m_ttLastChanged {};
100 : m_bNotify(bNotify), m_sName(
std::move(sName))
102 m_ttLastChanged = nowAsDuration<std::chrono::microseconds>();
136 return QString(
"%1" ).arg( m_value );
150 if ( m_value != value )
153 m_ttLastChanged = nowAsDuration<std::chrono::microseconds>();
170 using SVMap = QMap<QString, StateVariableBase*>;
179 for (
const auto *it : std::as_const(m_map))
188 if (pBase !=
nullptr)
189 m_map.insert(pBase->
m_sName, pBase);
194 bool SetValue(
const QString &sName,
const T& value )
196 SVMap::iterator it = m_map.find(sName);
197 if (it == m_map.end())
202 if (pVariable ==
nullptr)
205 if ( pVariable->GetValue() != value)
209 if (pVariable->m_bNotify)
222 SVMap::iterator it = m_map.find(sName);
223 if (it == m_map.end())
228 if (pVariable !=
nullptr)
234 uint BuildNotifyBody(QTextStream &ts, std::chrono::microseconds ttLastNotified)
const;
258 std::chrono::seconds m_nSubscriptionDuration {30min};
260 short m_nHoldCount {0};
266 void Notify ( )
override;
274 {
return m_sEventMethodName; }
277 Eventing (
const QString &sExtensionName,
278 QString sEventMethodName,
279 const QString &sSharePath );
282 QStringList GetBasePaths()
override;
284 bool ProcessRequest(
HTTPRequest *pRequest )
override;
286 short HoldEvents ( );
287 short ReleaseEvents ( );
289 void ExecutePostProcess( )
override;
QString m_sEventMethodName
QString GetServiceEventURL() override
Provides the URL of the event portion of the service.
Subscribers m_subscribers
virtual ~StateVariableBase()=default
StateVariableBase(QString sName, bool bNotify=false)
virtual QString ToString()=0
QString ToString() override
StateVariable(const QString &sName, bool bNotify=false)
StateVariable(const QString &sName, T value, bool bNotify=false)
void SetValue(const T &value)
bool SetValue(const QString &sName, const T &value)
T GetValue(const QString &sName)
void AddVariable(StateVariableBase *pBase)
virtual ~StateVariables()
QMap< QString, StateVariableBase * > SVMap
void SetExpireTime(std::chrono::seconds secs)
unsigned long IncrementKey()
SubscriberInfo(const QString &url, std::chrono::seconds duration)
Base class for services we offer to other UPnP devices.
T state_var_init(const T *)
QMap< QString, SubscriberInfo * > Subscribers