Statistics
| Branch: | Tag: | Revision:

dvbd / src / faketunermanager.cpp @ 904d298f

History | View | Annotate | Download (2.04 KB)

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

    
19
#include "faketunermanager.h"
20
#include "faketuner.h"
21

    
22
FakeTunerManager::FakeTunerManager(const TunerManager &tm)
23
{
24
  std::map<const Tuner *, Tuner *> subst;
25

    
26
  // Convert the tuner list
27

    
28
  for (TunerList::const_iterator i = tm.tuners.begin(); i != tm.tuners.end(); i++) {
29
    Tuner *oldTuner = *i;
30
    FakeTuner *fakeTuner = new FakeTuner(*oldTuner);
31

    
32
    tuners.push_back(fakeTuner);
33
    subst[oldTuner] = fakeTuner;
34
  }
35

    
36
  // Convert the type tuner map
37

    
38
  for (TypeTunerMap::const_iterator i = tm.typeTunerMap.begin(); i != tm.typeTunerMap.end(); i++) {
39
    const std::string &type = i->first;
40
    const TunerList *oldTunerList = i->second;
41

    
42
    TunerList *fakeTunerList = new TunerList;
43
    for (TunerList::const_iterator j = oldTunerList->begin(); j != oldTunerList->end(); j++) {
44
      Tuner *oldTuner = *j;
45
      fakeTunerList->push_back(subst[oldTuner]);
46
    }
47

    
48
    typeTunerMap[type] = fakeTunerList;
49
  }
50

    
51
  // Convert the tuner channel map
52

    
53
  for (TunerChannelMap::const_iterator i = tm.tunerChannelMap.begin(); i != tm.tunerChannelMap.end(); i++) {
54
    const Tuner *oldTuner = i->first;
55
    ChannelMap *cm = i->second;
56

    
57
    // NB channel map is aliased here
58
    // So we shouldn't delete it.
59
    // (Possibilities are:
60
    //    - ref count on channel maps
61
    //    - copy the channel map)
62

    
63
    tunerChannelMap[subst[oldTuner]] = cm;
64
  }
65
}