[SCM] kodi-pvr-hts/master: factor out "id" to the Entity base class and expose it only through get/set
tiber-guest at users.alioth.debian.org
tiber-guest at users.alioth.debian.org
Wed Mar 2 23:01:43 UTC 2016
The following commit has been merged in the master branch:
commit 7771442c34a13bcc2b9dd0a8af17842d4b1e7214
Author: Sam Stenvall <neggelandia at gmail.com>
Date: Sat Jul 25 19:00:09 2015 +0300
factor out "id" to the Entity base class and expose it only through get/set
diff --git a/src/AutoRecordings.cpp b/src/AutoRecordings.cpp
index 1886580..0ae37ee 100644
--- a/src/AutoRecordings.cpp
+++ b/src/AutoRecordings.cpp
@@ -65,7 +65,7 @@ void AutoRecordings::GetAutorecTimers(std::vector<PVR_TIMER> &timers)
PVR_TIMER tmr;
memset(&tmr, 0, sizeof(tmr));
- tmr.iClientIndex = tit->second.GetIntId();
+ tmr.iClientIndex = tit->second.GetId();
tmr.iClientChannelUid = (tit->second.GetChannel() > 0) ? tit->second.GetChannel() : -1;
tmr.startTime = tit->second.GetStart();
tmr.endTime = tit->second.GetStop();
@@ -128,7 +128,7 @@ const std::string AutoRecordings::GetTimerStringIdFromIntId(unsigned int intId)
{
for (auto tit = m_autoRecordings.begin(); tit != m_autoRecordings.end(); ++tit)
{
- if (tit->second.GetIntId() == intId)
+ if (tit->second.GetId() == intId)
return tit->second.GetStringId();
}
tvherror("Autorec: Unable to obtain string id for int id %d", intId);
@@ -140,7 +140,7 @@ const unsigned int AutoRecordings::GetTimerIntIdFromStringId(const std::string &
for (auto tit = m_autoRecordings.begin(); tit != m_autoRecordings.end(); ++tit)
{
if (tit->second.GetStringId() == strId)
- return tit->second.GetIntId();
+ return tit->second.GetId();
}
tvherror("Autorec: Unable to obtain int id for string id %s", strId.c_str());
return 0;
@@ -269,7 +269,7 @@ PVR_ERROR AutoRecordings::SendAutorecDelete(const PVR_TIMER &timer)
std::string strId;
for (auto tit = m_autoRecordings.begin(); tit != m_autoRecordings.end(); ++tit)
{
- if (tit->second.GetIntId() == timer.iClientIndex)
+ if (tit->second.GetId() == timer.iClientIndex)
{
strId = tit->second.GetStringId();
break;
diff --git a/src/TimeRecordings.cpp b/src/TimeRecordings.cpp
index 861ab3b..9abf157 100644
--- a/src/TimeRecordings.cpp
+++ b/src/TimeRecordings.cpp
@@ -65,7 +65,7 @@ void TimeRecordings::GetTimerecTimers(std::vector<PVR_TIMER> &timers)
PVR_TIMER tmr;
memset(&tmr, 0, sizeof(tmr));
- tmr.iClientIndex = tit->second.GetIntId();
+ tmr.iClientIndex = tit->second.GetId();
tmr.iClientChannelUid = (tit->second.GetChannel() > 0) ? tit->second.GetChannel() : -1;
tmr.startTime = tit->second.GetStart();
tmr.endTime = tit->second.GetStop();
@@ -104,7 +104,7 @@ const std::string TimeRecordings::GetTimerStringIdFromIntId(unsigned int intId)
{
for (auto tit = m_timeRecordings.begin(); tit != m_timeRecordings.end(); ++tit)
{
- if (tit->second.GetIntId() == intId)
+ if (tit->second.GetId() == intId)
return tit->second.GetStringId();
}
tvherror("Timerec: Unable to obtain string id for int id %d", intId);
@@ -116,7 +116,7 @@ const unsigned int TimeRecordings::GetTimerIntIdFromStringId(const std::string &
for (auto tit = m_timeRecordings.begin(); tit != m_timeRecordings.end(); ++tit)
{
if (tit->second.GetStringId() == strId)
- return tit->second.GetIntId();
+ return tit->second.GetId();
}
tvherror("Timerec: Unable to obtain int id for string id %s", strId.c_str());
return 0;
@@ -189,7 +189,7 @@ PVR_ERROR TimeRecordings::SendTimerecDelete(const PVR_TIMER &timer)
std::string strId;
for (auto tit = m_timeRecordings.begin(); tit != m_timeRecordings.end(); ++tit)
{
- if (tit->second.GetIntId() == timer.iClientIndex)
+ if (tit->second.GetId() == timer.iClientIndex)
{
strId = tit->second.GetStringId();
break;
diff --git a/src/Tvheadend.cpp b/src/Tvheadend.cpp
index b6959f4..f221709 100644
--- a/src/Tvheadend.cpp
+++ b/src/Tvheadend.cpp
@@ -203,7 +203,7 @@ PVR_ERROR CTvheadend::GetTagMembers
memset(&gm, 0, sizeof(PVR_CHANNEL_GROUP_MEMBER));
strncpy(
gm.strGroupName, group.strGroupName, sizeof(gm.strGroupName) - 1);
- gm.iChannelUniqueId = cit->second.id;
+ gm.iChannelUniqueId = cit->second.GetId();
gm.iChannelNumber = cit->second.num;
gms.push_back(gm);
}
@@ -253,7 +253,7 @@ PVR_ERROR CTvheadend::GetChannels ( ADDON_HANDLE handle, bool radio )
PVR_CHANNEL chn;
memset(&chn, 0 , sizeof(PVR_CHANNEL));
- chn.iUniqueId = channel.id;
+ chn.iUniqueId = channel.GetId();
chn.bIsRadio = channel.radio;
chn.iChannelNumber = channel.num;
chn.iSubChannelNumber = channel.numMinor;
@@ -380,7 +380,7 @@ PVR_ERROR CTvheadend::GetRecordings ( ADDON_HANDLE handle )
}
/* ID */
- snprintf(buf, sizeof(buf), "%i", recording.id);
+ snprintf(buf, sizeof(buf), "%i", recording.GetId());
strncpy(rec.strRecordingId, buf, sizeof(rec.strRecordingId) - 1);
/* Title */
@@ -777,7 +777,7 @@ bool CTvheadend::CreateTimer ( const Recording &tvhTmr, PVR_TIMER &tmr )
{
memset(&tmr, 0, sizeof(tmr));
- tmr.iClientIndex = tvhTmr.id;
+ tmr.iClientIndex = tvhTmr.GetId();
tmr.iClientChannelUid = (tvhTmr.channel > 0) ? tvhTmr.channel : -1;
tmr.startTime = static_cast<time_t>(tvhTmr.start);
tmr.endTime = static_cast<time_t>(tvhTmr.stop);
@@ -1042,7 +1042,7 @@ void CTvheadend::TransferEvent
/* Build */
EPG_TAG epg;
memset(&epg, 0, sizeof(EPG_TAG));
- epg.iUniqueBroadcastId = event.id;
+ epg.iUniqueBroadcastId = event.GetId();
epg.strTitle = event.title.c_str();
epg.iChannelNumber = event.channel;
epg.startTime = event.start;
@@ -1537,7 +1537,7 @@ void CTvheadend::ParseChannelAddOrUpdate ( htsmsg_t *msg, bool bAdd )
/* Locate channel object */
Channel &channel = m_channels[u32];
- channel.id = u32;
+ channel.SetId(u32);
channel.SetDirty(false);
/* Channel name */
@@ -1611,7 +1611,7 @@ void CTvheadend::ParseChannelAddOrUpdate ( htsmsg_t *msg, bool bAdd )
/* Update Kodi */
if (update) {
tvhdebug("channel update id:%u, name:%s",
- channel.id, channel.name.c_str());
+ channel.GetId(), channel.name.c_str());
if (m_asyncState.GetState() > ASYNC_CHN)
TriggerChannelUpdate();
}
@@ -1671,7 +1671,7 @@ void CTvheadend::ParseRecordingAddOrUpdate ( htsmsg_t *msg, bool bAdd )
/* Get entry */
Recording &rec = m_recordings[id];
- rec.id = id;
+ rec.SetId(id);
rec.SetDirty(false);
UPDATE(rec.start, start);
UPDATE(rec.stop, stop);
@@ -1816,7 +1816,7 @@ void CTvheadend::ParseRecordingAddOrUpdate ( htsmsg_t *msg, bool bAdd )
std::string error = rec.error.empty() ? "none" : rec.error;
tvhdebug("recording id:%d, state:%s, title:%s, desc:%s, error:%s",
- rec.id, state, rec.title.c_str(), rec.description.c_str(),
+ rec.GetId(), state, rec.title.c_str(), rec.description.c_str(),
error.c_str());
if (m_asyncState.GetState() > ASYNC_DVR)
@@ -1882,7 +1882,7 @@ bool CTvheadend::ParseEvent ( htsmsg_t *msg, bool bAdd, Event &evt )
return false;
}
- evt.id = id;
+ evt.SetId(id);
evt.channel = channel;
evt.start = (time_t)start;
evt.stop = (time_t)stop;
@@ -1921,11 +1921,11 @@ bool CTvheadend::ParseEvent ( htsmsg_t *msg, bool bAdd, Event &evt )
m_recordings.cend(),
[evt](const RecordingMapEntry &entry)
{
- return entry.second.eventId == evt.id;
+ return entry.second.eventId == evt.GetId();
});
if (rit != m_recordings.cend())
- evt.recordingId = evt.id;
+ evt.recordingId = evt.GetId();
return true;
}
@@ -1941,9 +1941,9 @@ void CTvheadend::ParseEventAddOrUpdate ( htsmsg_t *msg, bool bAdd )
/* Get event handle */
Schedule &sched = m_schedules[tmp.channel];
- Event &evt = sched.events[tmp.id];
+ Event &evt = sched.events[tmp.GetId()];
sched.channel = tmp.channel;
- evt.id = tmp.id;
+ evt.SetId(tmp.GetId());
evt.SetDirty(false);
/* Store */
@@ -1969,7 +1969,7 @@ void CTvheadend::ParseEventAddOrUpdate ( htsmsg_t *msg, bool bAdd )
if (update)
{
tvhtrace("event id:%d channel:%d start:%d stop:%d title:%s desc:%s",
- evt.id, evt.channel, (int)evt.start, (int)evt.stop,
+ evt.GetId(), evt.channel, (int)evt.start, (int)evt.stop,
evt.title.c_str(), evt.desc.c_str());
if (m_asyncState.GetState() > ASYNC_EPG)
@@ -2054,7 +2054,7 @@ void CTvheadend::PredictiveTune( uint32_t fromChannelId, uint32_t toChannelId )
const Channel &channel = entry.second;
if (toNum + 1 == channel.num)
- TuneOnOldest(channel.id);
+ TuneOnOldest(channel.GetId());
}
}
else if (fromNum - 1 == toNum)
@@ -2065,7 +2065,7 @@ void CTvheadend::PredictiveTune( uint32_t fromChannelId, uint32_t toChannelId )
const Channel &channel = entry.second;
if (toNum - 1 == channel.num)
- TuneOnOldest(channel.id);
+ TuneOnOldest(channel.GetId());
}
}
}
diff --git a/src/tvheadend/entity/Channel.h b/src/tvheadend/entity/Channel.h
index 3ed7676..9a70197 100644
--- a/src/tvheadend/entity/Channel.h
+++ b/src/tvheadend/entity/Channel.h
@@ -42,7 +42,6 @@ namespace tvheadend
{
public:
Channel() :
- id(0),
num(0),
numMinor(0),
radio(false),
@@ -55,7 +54,6 @@ namespace tvheadend
return num < right.num;
}
- uint32_t id;
uint32_t num;
uint32_t numMinor;
bool radio;
diff --git a/src/tvheadend/entity/Entity.h b/src/tvheadend/entity/Entity.h
index 677faca..5c624b4 100644
--- a/src/tvheadend/entity/Entity.h
+++ b/src/tvheadend/entity/Entity.h
@@ -21,18 +21,20 @@
*
*/
+#include <cstdint>
+
namespace tvheadend
{
namespace entity
{
/**
- * Abstract entity. An entity can be dirty or clean
+ * Abstract entity. An entity can be dirty or clean and has a numeric ID.
*/
class Entity
{
public:
- Entity() : m_dirty(false) {};
+ Entity() : m_dirty(false), m_id(0) {};
virtual ~Entity() = default;
/**
@@ -52,6 +54,26 @@ namespace tvheadend
m_dirty = dirty;
}
+ /**
+ * @return the entity ID
+ */
+ uint32_t GetId() const
+ {
+ return m_id;
+ }
+
+ /**
+ * Sets the entity ID
+ * @param id
+ */
+ void SetId(uint32_t id)
+ {
+ m_id = id;
+ }
+
+ protected:
+ uint32_t m_id;
+
private:
bool m_dirty;
};
diff --git a/src/tvheadend/entity/Event.h b/src/tvheadend/entity/Event.h
index 86efe14..478f5e1 100644
--- a/src/tvheadend/entity/Event.h
+++ b/src/tvheadend/entity/Event.h
@@ -41,7 +41,6 @@ namespace tvheadend
{
public:
Event() :
- id(0),
next(0),
channel(0),
content(0),
@@ -57,7 +56,6 @@ namespace tvheadend
{
}
- uint32_t id;
uint32_t next;
uint32_t channel;
uint32_t content;
diff --git a/src/tvheadend/entity/Recording.h b/src/tvheadend/entity/Recording.h
index f7eb147..5d6beb6 100644
--- a/src/tvheadend/entity/Recording.h
+++ b/src/tvheadend/entity/Recording.h
@@ -42,7 +42,6 @@ namespace tvheadend
{
public:
Recording() :
- id(0),
channel(0),
eventId(0),
start(0),
@@ -68,7 +67,6 @@ namespace tvheadend
state == PVR_TIMER_STATE_RECORDING;
}
- uint32_t id;
uint32_t channel;
uint32_t eventId;
int64_t start;
diff --git a/src/tvheadend/entity/RecordingBase.cpp b/src/tvheadend/entity/RecordingBase.cpp
index 3002212..fe80e34 100644
--- a/src/tvheadend/entity/RecordingBase.cpp
+++ b/src/tvheadend/entity/RecordingBase.cpp
@@ -24,20 +24,19 @@
using namespace tvheadend::entity;
RecordingBase::RecordingBase(const std::string &id /*= ""*/) :
- m_iId(GetNextIntId()),
- m_id(id),
+ m_sid(id),
m_enabled(0),
m_daysOfWeek(0),
m_retention(0),
m_priority(0),
m_channel(0)
{
+ m_id = GetNextIntId();
}
bool RecordingBase::operator==(const RecordingBase &right)
{
- return m_iId == right.m_iId &&
- m_id == right.m_id &&
+ return m_id == right.m_id &&
m_enabled == right.m_enabled &&
m_daysOfWeek == right.m_daysOfWeek &&
m_retention == right.m_retention &&
@@ -55,19 +54,14 @@ bool RecordingBase::operator!=(const RecordingBase &right)
return !(*this == right);
}
-unsigned int RecordingBase::GetIntId() const
-{
- return m_iId;
-}
-
std::string RecordingBase::GetStringId() const
{
- return m_id;
+ return m_sid;
}
void RecordingBase::SetStringId(const std::string &id)
{
- m_id = id;
+ m_sid = id;
}
bool RecordingBase::IsEnabled() const
diff --git a/src/tvheadend/entity/RecordingBase.h b/src/tvheadend/entity/RecordingBase.h
index 94f4be8..8ce3c8e 100644
--- a/src/tvheadend/entity/RecordingBase.h
+++ b/src/tvheadend/entity/RecordingBase.h
@@ -38,8 +38,6 @@ namespace tvheadend
bool operator!=(const RecordingBase &right);
public:
- unsigned int GetIntId() const;
-
std::string GetStringId() const;
void SetStringId(const std::string &id);
@@ -76,9 +74,7 @@ namespace tvheadend
private:
static int GetNextIntId();
- const unsigned int m_iId;
-
- std::string m_id; // ID (string!) of dvr[Time|Auto]recEntry.
+ std::string m_sid; // ID (string!) of dvr[Time|Auto]recEntry.
uint32_t m_enabled; // If [time|auto]rec entry is enabled (activated).
uint32_t m_daysOfWeek; // Bitmask - Days of week (0x01 = Monday, 0x40 = Sunday, 0x7f = Whole Week, 0 = Not set).
uint32_t m_retention; // Retention time (in days).
diff --git a/src/tvheadend/entity/Tag.cpp b/src/tvheadend/entity/Tag.cpp
index 747c181..8017a22 100644
--- a/src/tvheadend/entity/Tag.cpp
+++ b/src/tvheadend/entity/Tag.cpp
@@ -26,8 +26,7 @@
using namespace tvheadend::entity;
-Tag::Tag(uint32_t id /*= 0*/) :
-m_id(id),
+Tag::Tag() :
m_index(0)
{
}
@@ -46,11 +45,6 @@ bool Tag::operator!=(const Tag &right)
return !(*this == right);
}
-uint32_t Tag::GetId() const
-{
- return m_id;
-}
-
uint32_t Tag::GetIndex() const
{
return m_index;
diff --git a/src/tvheadend/entity/Tag.h b/src/tvheadend/entity/Tag.h
index 8951703..54fa380 100644
--- a/src/tvheadend/entity/Tag.h
+++ b/src/tvheadend/entity/Tag.h
@@ -41,13 +41,11 @@ namespace tvheadend
class Tag : public Entity
{
public:
- Tag(uint32_t id = 0);
+ Tag();
bool operator==(const Tag &right);
bool operator!=(const Tag &right);
- uint32_t GetId() const;
-
uint32_t GetIndex() const;
void SetIndex(uint32_t index);
@@ -62,7 +60,6 @@ namespace tvheadend
bool ContainsChannelType(bool bRadio) const;
private:
- uint32_t m_id;
uint32_t m_index;
std::string m_name;
std::string m_icon;
--
kodi-pvr-hts packaging
More information about the pkg-multimedia-commits
mailing list