application.h
//
// Copyright (C) 2008-2012 Artyom Beilis (Tonkikh) <artyomtnk@yahoo.com>
//
// See accompanying file COPYING.TXT file for licensing details.
//
#ifndef CPPCMS_APPLICATION_H
#define CPPCMS_APPLICATION_H
#include <cppcms/defs.h>
#include <booster/noncopyable.h>
#include <booster/hold_ptr.h>
#include <booster/atomic_counter.h>
#include <booster/intrusive_ptr.h>
#include <booster/shared_ptr.h>
#include <string>
namespace cppcms {
class application;
}
namespace booster {
void CPPCMS_API intrusive_ptr_add_ref(cppcms::application *p);
void CPPCMS_API intrusive_ptr_release(cppcms::application *p);
}
namespace cppcms {
class service;
class url_dispatcher;
class url_mapper;
class applications_pool;
class application;
class base_content;
class cache_interface;
class session_interface;
namespace http {
class request;
class response;
class context;
}
namespace json {
class value;
}
namespace filters {
class streamable;
}
class CPPCMS_API application : public booster::noncopyable {
public:
application(cppcms::service &srv);
virtual ~application();
cppcms::service &service();
json::value const &settings();
http::context &context();
http::request &request();
http::response &response();
url_dispatcher &dispatcher();
url_mapper &mapper();
cache_interface &cache();
session_interface &session();
void render(std::string template_name,base_content &content);
void render(std::string skin,std::string template_name,base_content &content);
void render(std::string template_name,std::ostream &out,base_content &content);
void render(std::string skin,std::string template_name,std::ostream &out,base_content &content);
void add(application &app);
void add(application &app,std::string const &regex,int part);
void add(application &app,std::string const &name,std::string const &url,std::string const &regex,int part);
void add(application &app,std::string const &name,std::string const &url);
void attach(application *app);
void attach(application *app,std::string const &regex,int part);
void attach(application *app,std::string const &name,std::string const &url);
void attach(application *app,std::string const &name,std::string const &url,std::string const &regex,int part);
application *parent();
application *root();
booster::shared_ptr<http::context> release_context();
booster::shared_ptr<http::context> get_context();
void assign_context(booster::shared_ptr<http::context> conn);
bool is_asynchronous();
virtual void main(std::string url);
virtual void init();
virtual void clear();
std::string translate(char const *context,char const *message);
std::string translate(char const *message);
std::string translate(char const *context,char const *single,char const *plural,int n);
std::string translate(char const *single,char const *plural,int n);
std::string url(std::string const &key);
std::string url(std::string const &key,
filters::streamable const &p1);
std::string url(std::string const &key,
filters::streamable const &p1,
filters::streamable const &p2);
std::string url(std::string const &key,
filters::streamable const &p1,
filters::streamable const &p2,
filters::streamable const &p3);
std::string url(std::string const &key,
filters::streamable const &p1,
filters::streamable const &p2,
filters::streamable const &p3,
filters::streamable const &p4);
std::string url(std::string const &key,
filters::streamable const &p1,
filters::streamable const &p2,
filters::streamable const &p3,
filters::streamable const &p4,
filters::streamable const &p5);
std::string url(std::string const &key,
filters::streamable const &p1,
filters::streamable const &p2,
filters::streamable const &p3,
filters::streamable const &p4,
filters::streamable const &p5,
filters::streamable const &p6);
private:
void recycle();
void parent(application *parent);
void pool_id(int id);
int pool_id();
struct _data; // future use
booster::hold_ptr<_data> d;
application *parent_;
application *root_;
booster::atomic_counter refs_;
friend class applications_pool;
friend void booster::intrusive_ptr_add_ref(application *p);
friend void booster::intrusive_ptr_release(application *p);
};
} // cppcms
#endif
cppcms::json::value
This class is central representation of json objects.
Definition: json.h:142
booster::hold_ptr< _data >
cppcms::service
This class represent the central event loop of the CppCMS applications.
Definition: service.h:59
cppcms::session_interface
This class provides an access to an application for session management.
Definition: session_interface.h:69
booster::locale::translate
basic_message< CharType > translate(CharType const *msg)
Translate a message, msg is not copied.
Definition: message.h:530
cppcms::http::context
context is a central class that holds all specific connection related information. It encapsulates CGI request and response, cache, session and locale information
Definition: http_context.h:45
cppcms::base_content
This is a simple polymorphic class that every content for templates rendering should be derided from ...
Definition: base_content.h:23
booster::shared_ptr< http::context >
cppcms::url_mapper
class for mapping URLs - the opposite of dispatch
Definition: url_mapper.h:149
cppcms::http::response
this class represents all HTTP/CGI response related API, generation of output content and HTTP header...
Definition: http_response.h:31
cppcms::application
application class is the base class for all user created applications.
Definition: application.h:81
cppcms::cache_interface
This class is the major gateway of the application to CppCMS caching abilities. Any access too cache ...
Definition: cache_interface.h:137
booster::locale::message
basic_message< char > message
Definition: message.h:494
cppcms::applications_pool
Application pool is the central class that holds user created applications.
Definition: applications_pool.h:41
cppcms::url_dispatcher
This class is used to glue between member function of application class and urls. ...
Definition: url_dispatcher.h:45
cppcms::filters::streamable
A special proxy object for writing any object to a std::ostream.
Definition: filters.h:34
booster::atomic_counter
Atomic counter is a class that allows perform counting in thread safe way.
Definition: atomic_counter.h:33
booster::noncopyable
This class makes impossible to copy any class derived from this one.
Definition: noncopyable.h:15
cppcms::http::request
This class represents all information related to the HTTP/CGI request.
Definition: http_request.h:34