diff options
Diffstat (limited to 'lib/dvb')
| -rw-r--r-- | lib/dvb/db.cpp | 44 | ||||
| -rw-r--r-- | lib/dvb/db.h | 2 | ||||
| -rw-r--r-- | lib/dvb/idvb.h | 9 |
3 files changed, 51 insertions, 4 deletions
diff --git a/lib/dvb/db.cpp b/lib/dvb/db.cpp index 70d512c1..a9329f18 100644 --- a/lib/dvb/db.cpp +++ b/lib/dvb/db.cpp @@ -10,6 +10,48 @@ DEFINE_REF(eDVBService); +// the following three methodes are declared in idvb.h +RESULT eBouquet::addService(const eServiceReference &ref) +{ + list::iterator it = + std::find(m_services.begin(), m_services.end(), ref); + if ( it != m_services.end() ) + return -1; + m_services.push_back(ref); + return 0; +} + +RESULT eBouquet::removeService(const eServiceReference &ref) +{ + list::iterator it = + std::find(m_services.begin(), m_services.end(), ref); + if ( it == m_services.end() ) + return -1; + m_services.erase(it); + return 0; +} + +RESULT eBouquet::moveService(const eServiceReference &ref, unsigned int pos) +{ + if ( pos < 0 || pos >= m_services.size() ) + return -1; + list::iterator source=m_services.end(); + list::iterator dest=m_services.end(); + for (list::iterator it(m_services.begin()); it != m_services.end(); ++it) + { + if (dest == m_services.end() && !pos--) + dest = it; + if (*it == ref) + source = it; + if (dest != m_services.end() && source != m_services.end()) + break; + } + if (dest == m_services.end() || source == m_services.end() || source == dest) + return -1; + std::iter_swap(source,dest); + return 0; +} + eDVBService::eDVBService() { } @@ -507,7 +549,7 @@ RESULT eDVBDB::getService(const eServiceReferenceDVB &reference, ePtr<eDVBServic return 0; } -RESULT eDVBDB::getBouquet(const eServiceReference &ref, const eBouquet* &bouquet) +RESULT eDVBDB::getBouquet(const eServiceReference &ref, eBouquet* &bouquet) { std::string str = ref.path; if (str.empty()) diff --git a/lib/dvb/db.h b/lib/dvb/db.h index 265c5970..a7350e78 100644 --- a/lib/dvb/db.h +++ b/lib/dvb/db.h @@ -45,7 +45,7 @@ public: RESULT startQuery(ePtr<iDVBChannelListQuery> &query, eDVBChannelQuery *query, const eServiceReference &source); - RESULT getBouquet(const eServiceReference &ref, const eBouquet* &bouquet); + RESULT getBouquet(const eServiceReference &ref, eBouquet* &bouquet); }; // we have to add a possibility to invalidate here. diff --git a/lib/dvb/idvb.h b/lib/dvb/idvb.h index de481d7f..6b657119 100644 --- a/lib/dvb/idvb.h +++ b/lib/dvb/idvb.h @@ -19,7 +19,12 @@ struct eBouquet { std::string m_bouquet_name; std::string m_path; - std::list<eServiceReference> m_services; + typedef std::list<eServiceReference> list; + list m_services; +// the following three methods are implemented in db.cpp + RESULT addService(const eServiceReference &); + RESULT removeService(const eServiceReference &); + RESULT moveService(const eServiceReference &, unsigned int); }; // bitte KEINE operator int() definieren, sonst bringt das ganze nix! @@ -262,7 +267,7 @@ public: virtual RESULT addService(const eServiceReferenceDVB &service, eDVBService *service)=0; virtual RESULT getService(const eServiceReferenceDVB &reference, ePtr<eDVBService> &service)=0; - virtual RESULT getBouquet(const eServiceReference &ref, const eBouquet* &bouquet)=0; + virtual RESULT getBouquet(const eServiceReference &ref, eBouquet* &bouquet)=0; virtual RESULT startQuery(ePtr<iDVBChannelListQuery> &query, eDVBChannelQuery *query, const eServiceReference &source)=0; }; |
