Statistics
| Branch: | Tag: | Revision:

dvbd / scheduler.h @ bfdb7446

History | View | Annotate | Download (1.83 KB)

1
// -*- c++ -*-
2
/*
3
  Copyright 2003 John Knottenbelt
4
  
5
  This program is free software; you can redistribute it and/or modify
6
  it under the terms of the GNU General Public License as published by
7
  the Free Software Foundation; either version 2 of the License, or
8
  (at your option) any later version.
9
 
10
  This program is distributed in the hope that it will be useful,
11
  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
  GNU General Public License for more details.
14
 
15
  You should have received a copy of the GNU General Public License
16
  along with this program; if not, write to the Free Software
17
  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
18
*/
19

    
20
#if !defined __SCHEDULER_H
21
#define __SCHEDULER_H
22

    
23
#include <string>
24
#include <list>
25
#include "recording.h"
26
#include "select.h"
27
#include "dvbd.h"
28

    
29
class ConnectionManager;
30
class TunerManager;
31

    
32
class Scheduler : public Selectable {
33
public:
34
  Scheduler(const std::string &dbtime, TunerManager *tm, ConnectionManager *cm);
35
  virtual ~Scheduler();
36

    
37
  void add( Recording &r );
38
  bool remove(int job);
39

    
40
  virtual void addSelectFDs(Select &) const;
41
  virtual bool isReady(const Select &) const;
42

    
43
  void process();
44

    
45
  void checkOverlaps(StringList &interruptions) const;
46
  void getSchedule(StringList &s) const;
47

    
48
  bool getNextJobTime( time_t &time ) const;
49

    
50
private:
51
  typedef std::list<Recording> List;
52

    
53
  void startRecording(const Recording &);
54

    
55
  bool timeUntilNextRecording( long &tv_sec, long &tv_usec ) const;
56
  bool overlaps(const List &l, const Recording &r) const;
57
  void checkOverlappingBlock(const List &l, StringList &interruptions) const;
58

    
59
  void writeDB() const;
60
  void readDB();
61

    
62
  int lastJob;
63
  List recordings;
64
  TunerManager *tm;
65
  ConnectionManager *cm;
66
  std::string dbfile;
67
};
68

    
69
#endif // __SCHEDULER_H