vdr  2.2.0
sources.h
Go to the documentation of this file.
1 /*
2  * sources.h: Source handling
3  *
4  * See the main source file 'vdr.c' for copyright information and
5  * how to reach the author.
6  *
7  * $Id: sources.h 3.3 2014/03/09 11:59:49 kls Exp $
8  */
9 
10 #ifndef __SOURCES_H
11 #define __SOURCES_H
12 
13 #include "config.h"
14 
15 class cSource : public cListObject {
16 public:
17  enum eSourceType {
18  stNone = 0x00000000,
19  stAtsc = ('A' << 24),
20  stCable = ('C' << 24),
21  stSat = ('S' << 24),
22  stTerr = ('T' << 24),
23  st_Mask = 0xFF000000,
24  st_Pos = 0x0000FFFF,
25  st_Any = 0x00000E10, // 3600 - special value indicating "any position"
26  };
27 private:
28  int code;
29  char *description;
30 public:
31  cSource(void);
32  cSource(char Source, const char *Description);
33  ~cSource();
34  int Code(void) const { return code; }
35  int Position(void) { return Position(code); }
44  const char *Description(void) const { return description; }
45  bool Parse(const char *s);
46  static bool Matches(int Code1, int Code2);
50  static int Position(int Code);
51  static char ToChar(int Code) { return (Code & st_Mask) >> 24; }
52  static cString ToString(int Code);
53  static int FromString(const char *s);
54  static int FromData(eSourceType SourceType, int Position = 0, bool East = false);
55  static bool IsAtsc(int Code) { return (Code & st_Mask) == stAtsc; }
56  static bool IsCable(int Code) { return (Code & st_Mask) == stCable; }
57  static bool IsSat(int Code) { return (Code & st_Mask) == stSat; }
58  static bool IsTerr(int Code) { return (Code & st_Mask) == stTerr; }
59  static bool IsType(int Code, char Source) { return int(Code & st_Mask) == (int(Source) << 24); }
60  };
61 
62 class cSources : public cConfig<cSource> {
63 public:
64  cSource *Get(int Code);
65  bool ContainsSourceType(char SourceType);
66  };
67 
68 extern cSources Sources;
69 
70 #endif //__SOURCES_H
static cString ToString(int Code)
Definition: sources.c:55
static char ToChar(int Code)
Definition: sources.h:51
static bool IsTerr(int Code)
Definition: sources.h:58
int Code(void) const
Definition: sources.h:34
bool Parse(const char *s)
Definition: sources.c:31
~cSource()
Definition: sources.c:26
int code
Definition: sources.h:28
static bool IsAtsc(int Code)
Definition: sources.h:55
static bool IsSat(int Code)
Definition: sources.h:57
eSourceType
Definition: sources.h:17
const char * Description(void) const
Definition: sources.h:44
static bool IsType(int Code, char Source)
Definition: sources.h:59
static int FromString(const char *s)
Definition: sources.c:68
static bool IsCable(int Code)
Definition: sources.h:56
static bool Matches(int Code1, int Code2)
Returns true if Code2 matches Code1.
Definition: sources.c:40
int Position(void)
Returns the orbital position of the satellite in case this is a DVB-S source (zero otherwise)...
Definition: sources.h:35
cSource(void)
Definition: sources.c:14
static int FromData(eSourceType SourceType, int Position=0, bool East=false)
Definition: sources.c:104
cSources Sources
Definition: sources.c:117
char * description
Definition: sources.h:29
Definition: tools.h:168