ChipMaster's trial hacks on C++CMS starting with v1.2.1. Not sure I'll follow on with the v2 since it looks to be breaking and mostly frivolous.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

80 lines
1.8 KiB

  1. #ifndef CPPCMS_APPLICATION_H
  2. #define CPPCMS_APPLICATION_H
  3. #include "worker_thread.h"
  4. #include "manager.h"
  5. namespace cppcms {
  6. struct application {
  7. // Data
  8. worker_thread &worker;
  9. url_parser &url;
  10. manager const &app;
  11. Cgicc *&cgi;
  12. CgiEnvironment const *&env;
  13. cache_iface &cache;
  14. ostream &cout;
  15. boost::signal<void()> &on_start;
  16. boost::signal<void()> &on_end;
  17. // Construction
  18. application(worker_thread &w);
  19. virtual ~application();
  20. // API
  21. void set_header(HTTPHeader *h) { worker.set_header(h); }
  22. void add_header(string s) { worker.add_header(s); }
  23. void set_cookie(cgicc::HTTPCookie const &c) { worker.set_cookie(c); }
  24. HTTPHeader &header() { return worker.header(); }
  25. void set_lang() { worker.set_lang(); }
  26. void set_lang(string const &s) { worker.set_lang(s) ; }
  27. void use_template(string s="") { worker.use_template(s); }
  28. void render(string n,base_content &c) { worker.render(n,c); }
  29. void render(string t,string n,base_content &c) { worker.render(t,n,c); }
  30. void render(string n,base_content &c,ostream &o) { worker.render(n,c,o); }
  31. void render(string t,string n,base_content &c,ostream &o) { worker.render(t,n,c,o); }
  32. virtual void on_404();
  33. inline char const *gettext(char const *s) { return worker.gettext(s); };
  34. inline char const *ngettext(char const *s,char const *p,int n) { return worker.ngettext(s,p,n); }
  35. transtext::trans const *domain_gettext(string const &d) { return worker.domain_gettext(d); }
  36. virtual void main();
  37. };
  38. template<typename T>
  39. class application_worker : public worker_thread {
  40. T app;
  41. public:
  42. application_worker(manager const &m) :
  43. worker_thread(m),
  44. app(*this)
  45. {
  46. }
  47. virtual void main()
  48. {
  49. app.main();
  50. }
  51. };
  52. template<typename T>
  53. class application_factory : public simple_factory<application_worker<T> >
  54. {
  55. };
  56. }
  57. #endif