Menu

[r539]: / framework / trunk / application.h  Maximize  Restore  History

Download this file

81 lines (58 with data), 1.8 kB

 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
69
70
71
72
73
74
75
76
77
78
#ifndef CPPCMS_APPLICATION_H
#define CPPCMS_APPLICATION_H
#include "worker_thread.h"
#include "manager.h"
namespace cppcms {
struct application {
// Data
worker_thread &worker;
url_parser &url;
manager const &app;
Cgicc *&cgi;
CgiEnvironment const *&env;
cgicc_connection *&cgi_conn;
cache_iface &cache;
ostream &cout;
boost::signal<void()> &on_start;
boost::signal<void()> &on_end;
// Construction
application(worker_thread &w);
virtual ~application();
// API
void set_header(HTTPHeader *h) { worker.set_header(h); }
void add_header(string s) { worker.add_header(s); }
void set_cookie(cgicc::HTTPCookie const &c) { worker.set_cookie(c); }
HTTPHeader &header() { return worker.header(); }
void set_lang() { worker.set_lang(); }
void set_lang(string const &s) { worker.set_lang(s) ; }
void use_template(string s="") { worker.use_template(s); }
void render(string n,base_content &c) { worker.render(n,c); }
void render(string t,string n,base_content &c) { worker.render(t,n,c); }
void render(string n,base_content &c,ostream &o) { worker.render(n,c,o); }
void render(string t,string n,base_content &c,ostream &o) { worker.render(t,n,c,o); }
virtual void on_404();
inline char const *gettext(char const *s) { return worker.gettext(s); };
inline char const *ngettext(char const *s,char const *p,int n) { return worker.ngettext(s,p,n); }
transtext::trans const *domain_gettext(string const &d) { return worker.domain_gettext(d); }
virtual void main();
};
template<typename T>
class application_worker : public worker_thread {
T app;
public:
application_worker(manager const &m) :
worker_thread(m),
app(*this)
{
}
virtual void main()
{
app.main();
}
};
template<typename T>
class application_factory : public simple_factory<application_worker<T> >
{
};
}
#endif
MongoDB Logo MongoDB