base_content.h
//
// Copyright (C) 2008-2012 Artyom Beilis (Tonkikh) <artyomtnk@yahoo.com>
//
// See accompanying file COPYING.TXT file for licensing details.
//
#ifndef CPPCMS_BASE_CONTENT_H
#define CPPCMS_BASE_CONTENT_H
#include <cppcms/defs.h>
#include <booster/copy_ptr.h>
namespace cppcms {
class application;
class CPPCMS_API base_content {
public:
base_content();
base_content(base_content const &);
base_content const &operator=(base_content const &);
virtual ~base_content();
application &app();
void app(application &app);
void reset_app();
bool has_app();
class app_guard {
app_guard(app_guard const &);
void operator=(app_guard const &);
public:
app_guard(base_content &c,application &a) : p_(0)
{
if(!c.has_app()) {
p_=&c;
c.app(a);
}
}
app_guard(base_content &c,base_content &parent) : p_(0)
{
if(!c.has_app() && parent.has_app()) {
p_ = &c;
c.app(parent.app());
}
}
~app_guard()
{
if(p_) {
p_->reset_app();
p_ = 0;
}
}
private:
base_content *p_;
};
private:
struct _data;
booster::copy_ptr<_data> d;
application *app_;
};
}
#endif
cppcms::base_content::has_app
bool has_app()
cppcms::base_content::app_guard
Special guard class that allows setting and resetting content's rendeding according to the specific s...
Definition: base_content.h:56
cppcms::base_content::app_guard::~app_guard
~app_guard()
Definition: base_content.h:86
cppcms::base_content::app_guard::app_guard
app_guard(base_content &c, base_content &parent)
Definition: base_content.h:76
booster::copy_ptr< _data >
cppcms::base_content
This is a simple polymorphic class that every content for templates rendering should be derided from ...
Definition: base_content.h:23
cppcms::application
application class is the base class for all user created applications.
Definition: application.h:81
cppcms::base_content::app_guard::app_guard
app_guard(base_content &c, application &a)
Definition: base_content.h:64
cppcms::base_content::app
application & app()