blob: 60de0814c4a2e8d85408fd1b827beca3ba4b2d96 (
plain)
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
|
#pragma once
#include <Exceptions.h>
#include <Task.h>
namespace Balau {
class Exit : public GeneralException {
public:
Exit(int code = -1) : GeneralException(), m_code(code) { String s; s.set("Application exitting with code = %i", code); setMsg(s.strdup()); }
int getCode() { return m_code; }
private:
int m_code;
};
class MainTask : public Task {
public:
MainTask() : m_stopTaskManOnExit(true) { }
virtual ~MainTask();
virtual const char * getName() const;
virtual void Do();
void stopTaskManOnExit(bool v) { m_stopTaskManOnExit = v; }
private:
bool m_stopTaskManOnExit;
};
class Main {
public:
enum Status {
UNKNOWN = 0,
STARTING,
RUNNING,
STOPPING,
STOPPED,
};
Main() : m_status(UNKNOWN) { IAssert(s_application == NULL, "There can't be two main apps"); s_application = this; }
static Status getStatus() { return s_application->m_status; }
int bootstrap(int _argc, char ** _argv);
static bool hasMain() { return s_application; }
protected:
int argc;
char ** argv;
char ** enve;
private:
Status m_status;
static Main * s_application;
};
};
|