rotor fix
[enigma2.git] / lib / dvb / db.h
index 7e31a22dceabac2465f235ef4664d2fe59f06e4a..bf39df18c2b755af8e140e77145b783c61a447aa 100644 (file)
@@ -1,22 +1,23 @@
 #ifndef __db_h
 #define __db_h
 
+#ifndef SWIG
+#include <lib/base/eptrlist.h>
 #include <lib/dvb/idvb.h>
 #include <set>
-
-class ServiceDescriptionTable;
-
-struct eDVBBouquet
-{
-       std::vector<eServiceReferenceDVB> m_services;
-       int lookupService(eServiceReferenceDVB &ref);
-};
+class ServiceDescriptionSection;
+#endif
 
 class eDVBDB: public iDVBChannelList
 {
+       static eDVBDB *instance;
 DECLARE_REF(eDVBDB);
        friend class eDVBDBQuery;
-private:
+       friend class eDVBDBBouquetQuery;
+       friend class eDVBDBSatellitesQuery;
+       friend class eDVBDBProvidersQuery;
+
+
        struct channel
        {
                ePtr<iDVBFrontendParameters> m_frontendParameters;
@@ -26,11 +27,14 @@ private:
        
        std::map<eServiceReferenceDVB, ePtr<eDVBService> > m_services;
        
-       std::map<eServiceReference, eDVBBouquet> m_bouquets;
-public:
+       std::map<std::string, eBouquet> m_bouquets;
+#ifdef SWIG
        eDVBDB();
-       virtual ~eDVBDB();
-       
+       ~eDVBDB();
+#endif
+public:
+#ifndef SWIG
+// iDVBChannelList
        RESULT addChannelToList(const eDVBChannelID &id, iDVBFrontendParameters *feparm);
        RESULT removeChannel(const eDVBChannelID &id);
 
@@ -38,22 +42,74 @@ public:
        
        RESULT addService(const eServiceReferenceDVB &service, eDVBService *service);
        RESULT getService(const eServiceReferenceDVB &reference, ePtr<eDVBService> &service);
-       
-       RESULT startQuery(ePtr<iDVBChannelListQuery> &query, eDVBChannelQuery *query);
+       RESULT flush();
+
+       RESULT startQuery(ePtr<iDVBChannelListQuery> &query, eDVBChannelQuery *query, const eServiceReference &source);
+
+       RESULT getBouquet(const eServiceReference &ref, eBouquet* &bouquet);
+//////
+       void saveServicelist();
+       void loadBouquet(const char *path);
+       eDVBDB();
+       virtual ~eDVBDB();
+#endif
+       static eDVBDB *getInstance() { return instance; }
+       void reloadServicelist();
+       void reloadBouquets();
 };
 
+#ifndef SWIG
        // we have to add a possibility to invalidate here.
-class eDVBDBQuery: public iDVBChannelListQuery
+class eDVBDBQueryBase: public iDVBChannelListQuery
 {
-DECLARE_REF(eDVBDBQuery);
-private:
-       std::map<eServiceReferenceDVB, ePtr<eDVBService> >::iterator m_cursor;
+DECLARE_REF(eDVBDBQueryBase);
+protected:
        ePtr<eDVBDB> m_db;
        ePtr<eDVBChannelQuery> m_query;
-       eServiceReferenceDVB m_source;
+       eServiceReference m_source;
+public:
+       eDVBDBQueryBase(eDVBDB *db, const eServiceReference &source, eDVBChannelQuery *query);
+       virtual int compareLessEqual(const eServiceReferenceDVB &a, const eServiceReferenceDVB &b);
+};
+
+class eDVBDBQuery: public eDVBDBQueryBase
+{
+       std::map<eServiceReferenceDVB, ePtr<eDVBService> >::iterator m_cursor;
+public:
+       eDVBDBQuery(eDVBDB *db, const eServiceReference &source, eDVBChannelQuery *query);
+       RESULT getNextResult(eServiceReferenceDVB &ref);
+};
+
+class eDVBDBBouquetQuery: public eDVBDBQueryBase
+{
+       std::list<eServiceReference>::iterator m_cursor;
+public:
+       eDVBDBBouquetQuery(eDVBDB *db, const eServiceReference &source, eDVBChannelQuery *query);
+       RESULT getNextResult(eServiceReferenceDVB &ref);
+};
+
+class eDVBDBListQuery: public eDVBDBQueryBase
+{
+protected:
+       std::list<eServiceReferenceDVB> m_list;
+       std::list<eServiceReferenceDVB>::iterator m_cursor;
+public:
+       eDVBDBListQuery(eDVBDB *db, const eServiceReference &source, eDVBChannelQuery *query);
+       RESULT getNextResult(eServiceReferenceDVB &ref);
+       int compareLessEqual(const eServiceReferenceDVB &a, const eServiceReferenceDVB &b);
+};
+
+class eDVBDBSatellitesQuery: public eDVBDBListQuery
+{
+public:
+       eDVBDBSatellitesQuery(eDVBDB *db, const eServiceReference &source, eDVBChannelQuery *query);
+};
+
+class eDVBDBProvidersQuery: public eDVBDBListQuery
+{
 public:
-       eDVBDBQuery(eDVBDB *db, const eServiceReferenceDVB &source, eDVBChannelQuery *query);
-       virtual RESULT getNextResult(eServiceReferenceDVB &ref);
+       eDVBDBProvidersQuery(eDVBDB *db, const eServiceReference &source, eDVBChannelQuery *query);
 };
+#endif // SWIG
 
 #endif