service.h
//
// Copyright (C) 2008-2012 Artyom Beilis (Tonkikh) <artyomtnk@yahoo.com>
//
// See accompanying file COPYING.TXT file for licensing details.
//
#ifndef CPPCMS_SERVICE_H
#define CPPCMS_SERVICE_H
#include <cppcms/defs.h>
#include <booster/noncopyable.h>
#include <booster/hold_ptr.h>
#include <booster/function.h>
#include <locale>
#include <memory>
#include <cppcms/locale_fwd.h>
#include <cppcms/json.h>
namespace booster {
namespace aio {
class io_service;
}
}
namespace cppcms {
namespace impl {
struct cached_settings;
class service;
namespace cgi {
class acceptor;
}
}
class applications_pool;
class thread_pool;
class session_pool;
class cache_pool;
class forwarder;
namespace json {
class value;
}
namespace views {
class manager;
}
class CPPCMS_API service : public booster::noncopyable
{
public:
static json::value load_settings(int argc,char *argv[]);
service(json::value const &v);
service(int argc,char *argv[]);
~service();
void run();
void shutdown();
json::value const &settings();
cppcms::applications_pool &applications_pool();
cppcms::thread_pool &thread_pool();
cppcms::session_pool &session_pool();
cppcms::views::manager &views_pool();
cppcms::cache_pool &cache_pool();
cppcms::forwarder &forwarder();
locale::generator const &generator();
std::locale locale();
std::locale locale(std::string const &name);
booster::aio::io_service &get_io_service();
void post(booster::function<void()> const &handler);
void after_fork(booster::function<void()> const &handler);
int threads_no();
int procs_no();
int process_id();
// internal functions never call it directly
cppcms::impl::service &impl();
impl::cached_settings const &cached_settings();
private:
void setup();
std::auto_ptr<cppcms::impl::cgi::acceptor> setup_acceptor(json::value const &,int,int shift=0);
void stop();
void start_acceptor(bool after_fork=false);
void setup_exit_handling();
bool prefork();
void run_prepare();
void after_fork_exec();
void run_acceptor();
void run_event_loop();
#ifdef CPPCMS_WIN32
void run_win_console();
#endif
#ifdef CPPCMS_WIN_NATIVE
void win_service_prepare();
void win_service_exec();
void run_win_service();
#endif
booster::hold_ptr<impl::service> impl_;
};
} //
#endif
cppcms::views::manager
This class controls the views used my application it knows to load them dynamically and reload if nee...
Definition: views_pool.h:173
cppcms::json::value
This class is central representation of json objects.
Definition: json.h:142
booster::hold_ptr
a smart pointer similar to std::auto_ptr but it is non-copyable and underlying object has same constn...
Definition: hold_ptr.h:18
cppcms::service
This class represent the central event loop of the CppCMS applications.
Definition: service.h:59
cppcms::thread_pool
This class provides an access to the thread pool where all CppCMS synchronous applications are execut...
Definition: thread_pool.h:29
cppcms::session_pool
This class provides an access to session management backends an allow customization.
Definition: session_pool.h:32
booster::function
Definition: function.h:16
booster::locale::generator
the major class used for locale generation
Definition: generator.h:74
cppcms::applications_pool
Application pool is the central class that holds user created applications.
Definition: applications_pool.h:41
booster::locale::conv::stop
Stop conversion and throw conversion_error.
Definition: encoding_errors.h:56
booster::aio::io_service
this is the central event loop that dispatches all requests.
Definition: io_service.h:37
booster::noncopyable
This class makes impossible to copy any class derived from this one.
Definition: noncopyable.h:15
cppcms::forwarder
Class responsble for automaticall forwarding of HTTP/CGI requests to other hosts over SCGI...
Definition: forwarder.h:31