fix "Clearall before scan" handling
[enigma2.git] / lib / dvb / db.h
1 #ifndef __db_h
2 #define __db_h
3
4 #ifndef SWIG
5 #include <lib/base/eptrlist.h>
6 #include <lib/dvb/idvb.h>
7 #include <set>
8 class ServiceDescriptionSection;
9 #endif
10
11 class eDVBDB: public iDVBChannelList
12 {
13         static eDVBDB *instance;
14 DECLARE_REF(eDVBDB);
15         friend class eDVBDBQuery;
16         friend class eDVBDBBouquetQuery;
17         friend class eDVBDBSatellitesQuery;
18         friend class eDVBDBProvidersQuery;
19
20         struct channel
21         {
22                 ePtr<iDVBFrontendParameters> m_frontendParameters;
23         };
24         
25         std::map<eDVBChannelID, channel> m_channels;
26         
27         std::map<eServiceReferenceDVB, ePtr<eDVBService> > m_services;
28         
29         std::map<std::string, eBouquet> m_bouquets;
30 #ifdef SWIG
31         eDVBDB();
32         ~eDVBDB();
33 #endif
34 public:
35 // iDVBChannelList
36         RESULT removeFlags(unsigned int flagmask, int dvb_namespace=-1, int tsid=-1, int onid=-1, unsigned int orb_pos=0xFFFFFFFF);
37         RESULT removeServices(int dvb_namespace=-1, int tsid=-1, int onid=-1, unsigned int orb_pos=0xFFFFFFFF);
38         RESULT removeService(const eServiceReference &service);
39         RESULT addFlag(const eServiceReference &service, unsigned int flagmask);
40         RESULT removeFlag(const eServiceReference &service, unsigned int flagmask);
41 #ifndef SWIG
42         RESULT removeFlags(unsigned int flagmask, eDVBChannelID chid, unsigned int orb_pos);
43         RESULT removeServices(eDVBChannelID chid, unsigned int orb_pos);
44
45         RESULT addChannelToList(const eDVBChannelID &id, iDVBFrontendParameters *feparm);
46         RESULT removeChannel(const eDVBChannelID &id);
47
48         RESULT getChannelFrontendData(const eDVBChannelID &id, ePtr<iDVBFrontendParameters> &parm);
49         
50         RESULT addService(const eServiceReferenceDVB &service, eDVBService *service);
51         RESULT getService(const eServiceReferenceDVB &reference, ePtr<eDVBService> &service);
52         RESULT flush();
53
54         RESULT startQuery(ePtr<iDVBChannelListQuery> &query, eDVBChannelQuery *query, const eServiceReference &source);
55
56         RESULT getBouquet(const eServiceReference &ref, eBouquet* &bouquet);
57 //////
58         void saveServicelist();
59         void loadBouquet(const char *path);
60         eServiceReference searchReference(int tsid, int onid, int sid);
61         eDVBDB();
62         virtual ~eDVBDB();
63 #endif
64         static eDVBDB *getInstance() { return instance; }
65         void reloadServicelist();
66         void reloadBouquets();
67 };
68
69 #ifndef SWIG
70         // we have to add a possibility to invalidate here.
71 class eDVBDBQueryBase: public iDVBChannelListQuery
72 {
73 DECLARE_REF(eDVBDBQueryBase);
74 protected:
75         ePtr<eDVBDB> m_db;
76         ePtr<eDVBChannelQuery> m_query;
77         eServiceReference m_source;
78 public:
79         eDVBDBQueryBase(eDVBDB *db, const eServiceReference &source, eDVBChannelQuery *query);
80         virtual int compareLessEqual(const eServiceReferenceDVB &a, const eServiceReferenceDVB &b);
81 };
82
83 class eDVBDBQuery: public eDVBDBQueryBase
84 {
85         std::map<eServiceReferenceDVB, ePtr<eDVBService> >::iterator m_cursor;
86 public:
87         eDVBDBQuery(eDVBDB *db, const eServiceReference &source, eDVBChannelQuery *query);
88         RESULT getNextResult(eServiceReferenceDVB &ref);
89 };
90
91 class eDVBDBBouquetQuery: public eDVBDBQueryBase
92 {
93         std::list<eServiceReference>::iterator m_cursor;
94 public:
95         eDVBDBBouquetQuery(eDVBDB *db, const eServiceReference &source, eDVBChannelQuery *query);
96         RESULT getNextResult(eServiceReferenceDVB &ref);
97 };
98
99 class eDVBDBListQuery: public eDVBDBQueryBase
100 {
101 protected:
102         std::list<eServiceReferenceDVB> m_list;
103         std::list<eServiceReferenceDVB>::iterator m_cursor;
104 public:
105         eDVBDBListQuery(eDVBDB *db, const eServiceReference &source, eDVBChannelQuery *query);
106         RESULT getNextResult(eServiceReferenceDVB &ref);
107         int compareLessEqual(const eServiceReferenceDVB &a, const eServiceReferenceDVB &b);
108 };
109
110 class eDVBDBSatellitesQuery: public eDVBDBListQuery
111 {
112 public:
113         eDVBDBSatellitesQuery(eDVBDB *db, const eServiceReference &source, eDVBChannelQuery *query);
114 };
115
116 class eDVBDBProvidersQuery: public eDVBDBListQuery
117 {
118 public:
119         eDVBDBProvidersQuery(eDVBDB *db, const eServiceReference &source, eDVBChannelQuery *query);
120 };
121 #endif // SWIG
122
123 #endif