#include <CGIApplication.h>
Inheritance diagram for ClearSilver::CGIApplication:

Public Types | |
Pointer types | |
|
typedef boost::shared_ptr< CGIApplication > | Ptr |
Public Member Functions | |
| void | operator() () |
| CGI application entry point. | |
Constructors and assignment operators | |
| CGIApplication () | |
| Default constructor. | |
| CGIApplication (const char *) | |
| Construct from the name of an HDF file. | |
| CGIApplication (const std::string &) | |
| Construct from the name of an HDF file. | |
| CGIApplication (const ClearSilver::HDF &) | |
| Construct from an existing HDF dataset. | |
| CGIApplication (const ClearSilver::CGI &) | |
| Construct from an existing CGI environment. | |
| CGIApplication (const CGIApplication &) | |
| Copy constructor. | |
| virtual | ~CGIApplication () throw () |
| Destructor. | |
| CGIApplication & | operator= (const CGIApplication &) |
| Assignment operator. | |
| CGIApplication & | operator= (const CGI &) |
| Replace the contained CGI object. | |
| void | swap (CGIApplication &) throw () |
| Swap contents with another object. | |
Access to ClearSilver data structures | |
| CGI | cgi () const |
| ClearSilver CGI data structure. | |
| HDF | hdf () |
| ClearSilver HDF dataset. | |
Static Public Member Functions | |
| static bool & | debug () |
| Access the debug flag. | |
Protected Member Functions | |
CGI application hooks | |
Derived classes are expected to provide their own implementations of these methods. The CGI application provided by the default version of these methods is a NOP. | |
| virtual void | initialize () |
| Initial setup of data structures. | |
| virtual bool | authenticate ()=0 |
| Verify authentication of query. | |
| virtual void | execute () |
| Execute main CGI program. | |
| virtual void | display () |
| Display CGI output. | |
| virtual void | execute_unauthenticated () |
| Execute the CGI program after authentication fails. | |
| virtual void | display_unauthenticated () |
| Display CGI output in absence of authentication. | |
| virtual void | terminate () |
| Final cleanup of data structures. | |
| virtual void | handle_exception (const std::string &) |
| Handle exceptions appropriately. | |
The class provides a template for constructing CGI applications. The function call operator (operator ()) provides the underlying CGI application logic, while the protected CGI application hooks provide means for derived classes to provide application-specific code.
By providing the core of an algorithm with suitable hooks for derived classes to modify specific elements, this class follows the Template Method pattern described in the following reference.
Definition at line 73 of file CGIApplication.h.
|
|
Verify authentication of query. This method is called prior to executing the execute() and display() CGI application hooks. Only if this method returns true will the other two methods (display() and execute()) be called. Otherwise, the unauthenticated versions of these methods will be called. Thus, derived classes can implement CGI authentication by overriding this method appropriately. Because of the security implications associated with this method, no default implementatin is provided and derived classes are forced to explicitly (rather than implicitly and perhaps mistakenly) establish their own authentication policy. As a convenience, the CGIApplicationUnauthenticated class, which is derived from CGIApplication, provides an implementation of this method that always returns true. Thus, concrete CGI application classes that need no authentication should derive directly from CGIApplicationUnauthenticated rather than from CGIApplication. Implemented in ClearSilver::CGIApplicationAuthenticated, and ClearSilver::CGIApplicationUnauthenticated. Referenced by operator()(). |
|
|
Access the debug flag. If the debug flag is true, syslog(3) messages with priority LOG_DEBUG will be logged. Definition at line 299 of file CGIApplication.cc. Referenced by display(), display_unauthenticated(), operator()(), and operator=(). |
|
|
Display CGI output. This is the main output method for a CGI application. It is expected to only create output, not modify data structures or satisfy requests. By default, this method takes the name of the ClearSilver template from the HDF dataset associated with the CGIApplication. The value of the following HDF variables are searched in order:
Definition at line 232 of file CGIApplication.cc. References cgi(), debug(), ClearSilver::CGI::display(), ClearSilver::HDF::find(), hdf(), and ClearSilver::ConstHDFNode::value(). Referenced by operator()(). |
|
|
Display CGI output in absence of authentication. This method is analogous to display() when authentication was unsuccessful (i.e., when authenticate() returns false). By default, this method takes the name of the ClearSilver template from the HDF dataset associated with the CGIApplication. The value of the following HDF variables are searched in order:
Reimplemented in ClearSilver::CGIApplicationUnauthenticated. Definition at line 261 of file CGIApplication.cc. References cgi(), debug(), ClearSilver::CGI::display(), ClearSilver::HDF::find(), hdf(), and ClearSilver::ConstHDFNode::value(). Referenced by operator()(). |
|
|
Execute main CGI program. This is the main execution path for CGI applications. It is expected that this method will perform the following operations.
Definition at line 229 of file CGIApplication.cc. Referenced by operator()(). |
|
|
Execute the CGI program after authentication fails. This method is analogous to execute() when authentication was unsuccessful (i.e., when authenticate() returns false). Reimplemented in ClearSilver::CGIApplicationUnauthenticated. Definition at line 258 of file CGIApplication.cc. Referenced by operator()(). |
|
|
Handle exceptions appropriately. This method allows CGI applications to handle the messages generated by exceptions. Be default, a message is rethrown as a ClearSilverException object. Referenced by operator()(). |
|
|
CGI application entry point. This method is the main entry point for CGI applications. Essentially, it executes the following application logic.
initialize (); if (authenticate ()) { execute (); display (); } else { execute_unauthenticated (); display_unauthenticated (); } terminate (); Definition at line 147 of file CGIApplication.cc. References authenticate(), std::basic_string< _CharT, _Traits, _Alloc >::c_str(), debug(), display(), display_unauthenticated(), execute(), execute_unauthenticated(), handle_exception(), ClearSilver::CGI::hdf(), initialize(), terminate(), std::runtime_error::what(), std::logic_error::what(), and ClearSilver::ClearSilverException::what(). |
|
|
Final cleanup of data structures. This method is responsible for returning the HDF data structure to the state it was in prior to handling a request. The CGI data structures will automatically be removed from the dataset (see HDFNode::remove_cgi()); however, any other modifications made during the request processing must be reversed here. Definition at line 288 of file CGIApplication.cc. Referenced by operator()(). |
1.4.5