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
64
65
66
67
68
|
#include <stdio.h>
#include <lib/base/init.h>
#include <lib/base/eerror.h>
int eInit::rl=-1;
std::list<std::pair<int,eAutoInit*> > *eInit::cl;
void eInit::add(int trl, eAutoInit *c)
{
if (!cl)
cl=new std::list<std::pair<int,eAutoInit*> >;
cl->push_back(std::pair<int,eAutoInit*>(trl, c));
if (rl>=trl)
c->initNow();
}
void eInit::remove(int trl, eAutoInit *c)
{
if (!cl)
return;
cl->remove(std::pair<int,eAutoInit*>(trl, c));
if (rl>=trl)
c->closeNow();
}
eInit::eInit()
{
}
eInit::~eInit()
{
setRunlevel(-1);
delete cl;
cl=0;
}
void eInit::setRunlevel(int nrl)
{
while (nrl>rl)
{
rl++;
for (std::list<std::pair<int,eAutoInit*> >::iterator i(cl->begin()); i!=cl->end(); ++i)
{
if ((*i).first == rl)
{
eDebug("+ (%d) %s", rl, (*i).second->getDescription());
(*i).second->initNow();
}
}
}
while (nrl<rl)
{
for (std::list<std::pair<int,eAutoInit*> >::iterator i(cl->begin()); i!=cl->end(); ++i)
if ((*i).first == rl)
{
eDebug("- (%d) %s", rl, (*i).second->getDescription());
(*i).second->closeNow();
}
rl--;
}
eDebug("reached rl %d", rl);
}
eAutoInit::~eAutoInit()
{
}
|