/home/greg/src/restcgi-test/src/method.h

00001 /*
00002 Copyright (c) 2009 zooml.com
00003 
00004 Permission is hereby granted, free of charge, to any person obtaining a copy
00005 of this software and associated documentation files (the "Software"), to deal
00006 in the Software without restriction, including without limitation the rights
00007 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00008 copies of the Software, and to permit persons to whom the Software is
00009 furnished to do so, subject to the following conditions:
00010 
00011 The above copyright notice and this permission notice shall be included in
00012 all copies or substantial portions of the Software.
00013 
00014 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00015 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00016 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00017 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00018 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00019 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
00020 THE SOFTWARE.
00021 */
00022 #ifndef restcgi_method_h
00023 #define restcgi_method_h
00024 #include "apidefs.h"
00025 #include "method_e.h"
00026 #include "hdr.h"
00027 #include "content.h"
00028 #include "status_code_e.h"
00029 #include <uripp/path.h>
00030 #include <uripp/query.h>
00031 #include <string>
00032 #include <boost/shared_ptr.hpp>
00033 namespace restcgi {
00034     class env;
00035     class endpoint;
00036     class icontent;
00037     class ocontent;
00065     class RESTCGI_API method {
00066     public:
00067         typedef boost::shared_ptr<method> pointer; 
00068         typedef boost::shared_ptr<const method> const_pointer; 
00069         typedef restcgi::env env_type; 
00070         typedef restcgi::endpoint endpoint_type; 
00071         typedef boost::shared_ptr<endpoint_type> endpoint_pointer; 
00072         typedef restcgi::icontent icontent_type; 
00073         typedef restcgi::ocontent ocontent_type; 
00074         typedef boost::shared_ptr<icontent_type> icontent_pointer; 
00075         typedef boost::shared_ptr<ocontent_type> ocontent_pointer; 
00076         typedef restcgi::request_hdr request_hdr_type; 
00077         typedef restcgi::response_hdr response_hdr_type; 
00078         typedef uripp::path uri_path_type; 
00079         typedef uripp::query uri_query_type; 
00080         virtual ~method();
00081         const method_e& e() const {return e_;} 
00082 
00086         const uri_path_type& uri_path() const {return uri_path_;}
00087         const uri_query_type& uri_query() const {return uri_query_;} 
00088         const request_hdr_type& request_hdr() const {return request_hdr_;} 
00089         icontent_pointer icontent() const {return icontent_;} 
00090         ocontent_pointer ocontent() const {return ocontent_;} 
00091 
00094         void respond(const status_code_e& sc = status_code_e::OK, const response_hdr_type& rh = response_hdr_type());
00099         ocontent_pointer respond(const content_hdr& ch, const status_code_e& sc = status_code_e::OK, const response_hdr_type& rh = response_hdr_type());
00100         bool responded() const {return responded_;} 
00101         const env_type& env() const; 
00102         endpoint_pointer endpoint() const {return endpoint_;} 
00103         static const char QP_REST_PUT[8]; 
00104         static const char QP_REST_DELETE[11]; 
00105     private:
00106         method(const method&); // inhibit
00107         method& operator =(const method&); // inhibit
00108         method(const method_e& e, const endpoint_pointer& ep);
00109         friend class endpoint;
00111         static pointer create(const endpoint_pointer& ep);
00112         void respond(const status_code_e& sc, const response_hdr_type& rh, const content_hdr& ch, bool has_content);
00113         static void respond(endpoint_pointer ep, const status_code_e& sc, const response_hdr_type& rh = response_hdr_type(), const content_hdr& ch = content_hdr());
00114         method_e e_;
00116         endpoint_pointer endpoint_;
00117         uri_path_type uri_path_;
00118         uri_query_type uri_query_;
00119         bool responded_;
00120         request_hdr_type request_hdr_;
00121         icontent_pointer icontent_;
00122         ocontent_pointer ocontent_;
00123     };
00124 }
00125 #endif

Generated on Fri May 15 11:27:12 2009 for restcgi by  doxygen 1.4.7