add support for listing satellites and providers
[enigma2.git] / lib / dvb / db.h
1 #ifndef __db_h
2 #define __db_h
3
4 #include <lib/base/eptrlist.h>
5 #include <lib/dvb/idvb.h>
6 #include <set>
7
8 class ServiceDescriptionSection;
9
10 class eDVBDB: public iDVBChannelList
11 {
12 DECLARE_REF(eDVBDB);
13         friend class eDVBDBQuery;
14         friend class eDVBDBBouquetQuery;
15         friend class eDVBDBSatellitesQuery;
16         friend class eDVBDBProvidersQuery;
17 private:
18         struct channel
19         {
20                 ePtr<iDVBFrontendParameters> m_frontendParameters;
21         };
22         
23         std::map<eDVBChannelID, channel> m_channels;
24         
25         std::map<eServiceReferenceDVB, ePtr<eDVBService> > m_services;
26         
27         std::map<std::string, eBouquet> m_bouquets;
28 public:
29         void load();
30         void save();
31
32         void loadBouquet(const char *path);
33         void loadBouquets();
34
35         eDVBDB();
36         virtual ~eDVBDB();
37         
38         RESULT addChannelToList(const eDVBChannelID &id, iDVBFrontendParameters *feparm);
39         RESULT removeChannel(const eDVBChannelID &id);
40
41         RESULT getChannelFrontendData(const eDVBChannelID &id, ePtr<iDVBFrontendParameters> &parm);
42         
43         RESULT addService(const eServiceReferenceDVB &service, eDVBService *service);
44         RESULT getService(const eServiceReferenceDVB &reference, ePtr<eDVBService> &service);
45         RESULT flush();
46
47         RESULT startQuery(ePtr<iDVBChannelListQuery> &query, eDVBChannelQuery *query, const eServiceReference &source);
48
49         RESULT getBouquet(const eServiceReference &ref, eBouquet* &bouquet);
50 };
51
52         // we have to add a possibility to invalidate here.
53 class eDVBDBQueryBase: public iDVBChannelListQuery
54 {
55 DECLARE_REF(eDVBDBQueryBase);
56 protected:
57         ePtr<eDVBDB> m_db;
58         ePtr<eDVBChannelQuery> m_query;
59         eServiceReference m_source;
60 public:
61         eDVBDBQueryBase(eDVBDB *db, const eServiceReference &source, eDVBChannelQuery *query);
62         virtual int compareLessEqual(const eServiceReferenceDVB &a, const eServiceReferenceDVB &b);
63 };
64
65 class eDVBDBQuery: public eDVBDBQueryBase
66 {
67         std::map<eServiceReferenceDVB, ePtr<eDVBService> >::iterator m_cursor;
68 public:
69         eDVBDBQuery(eDVBDB *db, const eServiceReference &source, eDVBChannelQuery *query);
70         RESULT getNextResult(eServiceReferenceDVB &ref);
71 };
72
73 class eDVBDBBouquetQuery: public eDVBDBQueryBase
74 {
75         std::list<eServiceReference>::iterator m_cursor;
76 public:
77         eDVBDBBouquetQuery(eDVBDB *db, const eServiceReference &source, eDVBChannelQuery *query);
78         RESULT getNextResult(eServiceReferenceDVB &ref);
79 };
80
81 class eDVBDBListQuery: public eDVBDBQueryBase
82 {
83 protected:
84         std::list<eServiceReferenceDVB> m_list;
85         std::list<eServiceReferenceDVB>::iterator m_cursor;
86 public:
87         eDVBDBListQuery(eDVBDB *db, const eServiceReference &source, eDVBChannelQuery *query);
88         RESULT getNextResult(eServiceReferenceDVB &ref);
89         int compareLessEqual(const eServiceReferenceDVB &a, const eServiceReferenceDVB &b);
90 };
91
92 class eDVBDBSatellitesQuery: public eDVBDBListQuery
93 {
94 public:
95         eDVBDBSatellitesQuery(eDVBDB *db, const eServiceReference &source, eDVBChannelQuery *query);
96 };
97
98 class eDVBDBProvidersQuery: public eDVBDBListQuery
99 {
100 public:
101         eDVBDBProvidersQuery(eDVBDB *db, const eServiceReference &source, eDVBChannelQuery *query);
102 };
103
104 #endif