-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnextstrategy.h
63 lines (52 loc) · 1.41 KB
/
nextstrategy.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#ifndef NEXTSTRATEGY
#define NEXTSTRATEGY
class CurrentMediaList;
class NextStrategy{
public:
virtual int next()=0;
virtual int prev()=0;
virtual int next_auto()=0;
virtual int prev_auto()=0;
void setCurrentList(CurrentMediaList *p_mList){list = p_mList;}
protected:
CurrentMediaList *list;
};
class LoopMode : public NextStrategy{
public:
int next();
int prev();
int next_auto();
int prev_auto();
};
class RandomMode : public NextStrategy{
public:
int next();
int prev();
int next_auto();
int prev_auto();
};
class LoopOneMode : public NextStrategy{
public:
int next();
int prev();
int next_auto();
int prev_auto();
};
class NextFactory{
static LoopMode *loopMode;
static RandomMode *randMode;
static LoopOneMode *loopOneMode;
public:
static NextStrategy* getLoopMode(CurrentMediaList *crt)
{loopMode->setCurrentList(crt);return loopMode;}
static NextStrategy* getRandomMode(CurrentMediaList *crt){randMode->setCurrentList(crt);return randMode;}
static NextStrategy* getLoopOneMode(CurrentMediaList *crt){loopOneMode->setCurrentList(crt);return loopOneMode;}
static void init(){
if (loopMode)
return;
loopMode = new LoopMode();
randMode = new RandomMode();
loopOneMode = new LoopOneMode();
}
};
#endif // NEXTSTRATEGY