00001 #ifndef restcgi_rest_h 00002 #define restcgi_rest_h 00003 #include "apidefs.h" 00004 #include "ctmpl.h" 00005 #include <map> 00006 #include <boost/shared_ptr.hpp> 00062 namespace restcgi { 00063 class method; 00064 class resource; 00128 class RESTCGI_API rest { 00129 public: 00130 typedef restcgi::method method_type; 00131 typedef boost::shared_ptr<method_type> method_pointer; 00132 typedef restcgi::resource resource_type; 00133 typedef boost::shared_ptr<resource_type> resource_pointer; 00134 typedef std::map<std::string, resource_pointer> vhosts_resources_type; 00135 rest(); 00136 virtual ~rest(); 00142 void process(method_pointer m, resource_pointer root, const sc_ctmpls& sccts = sc_ctmpls()); 00147 void process(method_pointer m, const vhosts_resources_type& vhrs); 00148 method_pointer method() const {return method_;} 00149 resource_pointer root() const {return root_;} 00150 resource_pointer resource() const {return resource_;} 00151 static bool special_case(method_pointer m); 00152 static resource_pointer locate(method_pointer m, resource_pointer& r); 00153 static void apply(method_pointer m, resource_pointer r); 00154 static void on_exception(method_pointer m, const sc_ctmpls& sccts); 00155 protected: 00159 virtual bool special_case(); 00169 virtual resource_pointer locate(resource_pointer& r); 00175 virtual void apply(); 00182 virtual void on_exception(const sc_ctmpls& sccts); 00183 private: 00184 method_pointer method_; 00185 resource_pointer root_; 00186 resource_pointer resource_; 00187 }; 00188 } 00189 #endif