after DECLARE_REF now all is private.. not public
[enigma2.git] / lib / dvb / db.h
1 #ifndef __db_h
2 #define __db_h
3
4 #ifndef SWIG
5 #include <lib/dvb/idvb.h>
6 #include <lib/base/eptrlist.h>
7 #include <set>
8 class ServiceDescriptionSection;
9 #endif
10
11 class eDVBDB: public iDVBChannelList
12 {
13         DECLARE_REF(eDVBDB);
14         static eDVBDB *instance;
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         PyObject *readSatellites(SWIG_PYOBJECT(ePyObject) sat_list, SWIG_PYOBJECT(ePyObject) sat_dict, SWIG_PYOBJECT(ePyObject) tp_dict);
42         PyObject *readTerrestrials(SWIG_PYOBJECT(ePyObject) ter_list, SWIG_PYOBJECT(ePyObject) tp_dict);
43         PyObject *readCables(SWIG_PYOBJECT(ePyObject) cab_list, SWIG_PYOBJECT(ePyObject) tp_dict);
44 #ifndef SWIG
45         RESULT removeFlags(unsigned int flagmask, eDVBChannelID chid, unsigned int orb_pos);
46         RESULT removeServices(eDVBChannelID chid, unsigned int orb_pos);
47
48         RESULT addChannelToList(const eDVBChannelID &id, iDVBFrontendParameters *feparm);
49         RESULT removeChannel(const eDVBChannelID &id);
50
51         RESULT getChannelFrontendData(const eDVBChannelID &id, ePtr<iDVBFrontendParameters> &parm);
52         
53         RESULT addService(const eServiceReferenceDVB &service, eDVBService *service);
54         RESULT getService(const eServiceReferenceDVB &reference, ePtr<eDVBService> &service);
55         RESULT flush();
56
57         RESULT startQuery(ePtr<iDVBChannelListQuery> &query, eDVBChannelQuery *query, const eServiceReference &source);
58
59         RESULT getBouquet(const eServiceReference &ref, eBouquet* &bouquet);
60 //////
61         void loadBouquet(const char *path);
62         eServiceReference searchReference(int tsid, int onid, int sid);
63         eDVBDB();
64         virtual ~eDVBDB();
65 #endif
66         void loadServicelist(const char *filename);
67         static eDVBDB *getInstance() { return instance; }
68         void reloadServicelist();
69         void saveServicelist();
70         void saveServicelist(const char *file);
71         void reloadBouquets();
72 };
73
74 #ifndef SWIG
75         // we have to add a possibility to invalidate here.
76 class eDVBDBQueryBase: public iDVBChannelListQuery
77 {
78         DECLARE_REF(eDVBDBQueryBase);
79 protected:
80         ePtr<eDVBDB> m_db;
81         ePtr<eDVBChannelQuery> m_query;
82         eServiceReference m_source;
83 public:
84         eDVBDBQueryBase(eDVBDB *db, const eServiceReference &source, eDVBChannelQuery *query);
85         virtual int compareLessEqual(const eServiceReferenceDVB &a, const eServiceReferenceDVB &b);
86 };
87
88 class eDVBDBQuery: public eDVBDBQueryBase
89 {
90         std::map<eServiceReferenceDVB, ePtr<eDVBService> >::iterator m_cursor;
91 public:
92         eDVBDBQuery(eDVBDB *db, const eServiceReference &source, eDVBChannelQuery *query);
93         RESULT getNextResult(eServiceReferenceDVB &ref);
94 };
95
96 class eDVBDBBouquetQuery: public eDVBDBQueryBase
97 {
98         std::list<eServiceReference>::iterator m_cursor;
99 public:
100         eDVBDBBouquetQuery(eDVBDB *db, const eServiceReference &source, eDVBChannelQuery *query);
101         RESULT getNextResult(eServiceReferenceDVB &ref);
102 };
103
104 class eDVBDBListQuery: public eDVBDBQueryBase
105 {
106 protected:
107         std::list<eServiceReferenceDVB> m_list;
108         std::list<eServiceReferenceDVB>::iterator m_cursor;
109 public:
110         eDVBDBListQuery(eDVBDB *db, const eServiceReference &source, eDVBChannelQuery *query);
111         RESULT getNextResult(eServiceReferenceDVB &ref);
112         int compareLessEqual(const eServiceReferenceDVB &a, const eServiceReferenceDVB &b);
113 };
114
115 class eDVBDBSatellitesQuery: public eDVBDBListQuery
116 {
117 public:
118         eDVBDBSatellitesQuery(eDVBDB *db, const eServiceReference &source, eDVBChannelQuery *query);
119 };
120
121 class eDVBDBProvidersQuery: public eDVBDBListQuery
122 {
123 public:
124         eDVBDBProvidersQuery(eDVBDB *db, const eServiceReference &source, eDVBChannelQuery *query);
125 };
126 #endif // SWIG
127
128 #endif