From 0b7843f79981ff1ccf7fdcd2ee0a55a1679e670d Mon Sep 17 00:00:00 2001 From: Artyom Beilis Date: Fri, 7 May 2010 15:47:07 +0000 Subject: [PATCH] Replaced function,hold_ptr,clone_ptr,copy_ptr with booster ones --- CMakeLists.txt | 6 -- application.h | 4 +- applications_pool.h | 4 +- base_view.h | 4 +- cache_interface.h | 4 +- cache_pool.h | 4 +- cgi_api.cpp | 4 +- cgi_api.h | 10 +-- clone_ptr.h | 77 -------------------- connection_forwarder.h | 2 +- copy_ptr.h | 82 ---------------------- filters.h | 22 +++--- form.h | 38 +++++----- function.h | 163 ------------------------------------------- hold_ptr.h | 63 ----------------- http_client.cpp | 2 +- http_client.h | 4 +- http_context.cpp | 2 +- http_context.h | 10 +-- http_cookie.h | 4 +- http_file.h | 4 +- http_request.h | 4 +- http_response.h | 4 +- json.h | 4 +- logger.h | 8 +-- regex.h | 6 +- rpc_json.h | 9 +-- service.cpp | 4 +- service.h | 10 +-- service_impl.h | 2 +- session_cookies.h | 4 +- session_dual.h | 4 +- session_interface.h | 4 +- session_pool.h | 4 +- session_posix_file_storage.h | 4 +- session_sid.h | 4 +- session_win32_file_storage.h | 4 +- tcp_cache_server.h | 4 +- tests/function_test.cpp | 89 ----------------------- thread_pool.cpp | 8 +-- thread_pool.h | 8 +-- urandom.h | 4 +- url_dispatcher.h | 16 ++--- views_pool.h | 2 +- 44 files changed, 122 insertions(+), 601 deletions(-) delete mode 100644 clone_ptr.h delete mode 100644 copy_ptr.h delete mode 100644 function.h delete mode 100644 hold_ptr.h delete mode 100644 tests/function_test.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 82f7046..1a5f76a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -341,16 +341,13 @@ set(CPPCMS_PUBLIC_HEADERS base_view.h cache_interface.h cache_pool.h - clone_ptr.h # connection_forwarder.h - copy_ptr.h cppcms_error.h cstdint.h defs.h encoding.h filters.h form.h - hold_ptr.h http_context.h http_cookie.h http_file.h @@ -377,7 +374,6 @@ set(CPPCMS_PUBLIC_HEADERS util.h view.h views_pool.h - function.h ${CMAKE_CURRENT_BINARY_DIR}/config.h ) @@ -676,7 +672,6 @@ set(ALL_TESTS cache_backend_test json_test base64_test - function_test forwarder_test jsonrpc_test ) @@ -752,7 +747,6 @@ add_test(encryptor_test encryptor_test) add_test(storage_test storage_test) add_test(json_test json_test) add_test(cache_backend_test cache_backend_test) -add_test(function_test function_test) add_test(form_test form_test "-c" "${CNF}/form_test.js" diff --git a/application.h b/application.h index 08d9f87..c5cb28a 100644 --- a/application.h +++ b/application.h @@ -22,7 +22,7 @@ #include "defs.h" #include "noncopyable.h" #include "atomic_counter.h" -#include "hold_ptr.h" +#include #include "intrusive_ptr.h" #include @@ -274,7 +274,7 @@ namespace cppcms { struct data; // future use - util::hold_ptr d; + booster::hold_ptr d; application *parent_; application *root_; diff --git a/applications_pool.h b/applications_pool.h index 51a58c8..1a00818 100644 --- a/applications_pool.h +++ b/applications_pool.h @@ -21,7 +21,7 @@ #include "defs.h" #include "noncopyable.h" -#include "hold_ptr.h" +#include #include "intrusive_ptr.h" #include @@ -150,7 +150,7 @@ namespace cppcms { std::string script_name(); bool matched(basic_app_data &data,std::string script_name,std::string path_info,std::string &matched); service *srv_; - util::hold_ptr d; + booster::hold_ptr d; }; namespace details { diff --git a/base_view.h b/base_view.h index 8f99f72..6d0e8bf 100644 --- a/base_view.h +++ b/base_view.h @@ -28,7 +28,7 @@ #include #include -#include "hold_ptr.h" +#include #include "base_content.h" #include "noncopyable.h" #include "config.h" @@ -59,7 +59,7 @@ protected: private: struct data; - util::hold_ptr d; + booster::hold_ptr d; }; diff --git a/cache_interface.h b/cache_interface.h index 0973406..9d8eac0 100644 --- a/cache_interface.h +++ b/cache_interface.h @@ -25,7 +25,7 @@ #include "defs.h" #include "noncopyable.h" #include "intrusive_ptr.h" -#include "hold_ptr.h" +#include #include "cstdint.h" namespace cppcms { @@ -266,7 +266,7 @@ namespace cppcms { bool notriggers); struct data; - util::hold_ptr d; + booster::hold_ptr d; http::context *context_; std::set triggers_; intrusive_ptr cache_module_; diff --git a/cache_pool.h b/cache_pool.h index 0d7ead2..499e5dc 100644 --- a/cache_pool.h +++ b/cache_pool.h @@ -22,7 +22,7 @@ #include "defs.h" #include "noncopyable.h" #include "intrusive_ptr.h" -#include "hold_ptr.h" +#include namespace cppcms { namespace json { class value; } @@ -35,7 +35,7 @@ namespace cppcms { intrusive_ptr get(); private: struct data; - util::hold_ptr d; + booster::hold_ptr d; }; } diff --git a/cgi_api.cpp b/cgi_api.cpp index 58085e2..b78d1f1 100644 --- a/cgi_api.cpp +++ b/cgi_api.cpp @@ -256,12 +256,12 @@ intrusive_ptr connection::self() } void connection::async_prepare_request( http::request &request, - function const &h) + booster::function const &h) { async_read_headers(boost::bind(&connection::load_content,self(),_1,&request,h)); } -void connection::aync_wait_for_close_by_peer(function const &on_eof) +void connection::aync_wait_for_close_by_peer(booster::function const &on_eof) { async_read_eof(boost::bind(&connection::handle_eof,self(),on_eof)); } diff --git a/cgi_api.h b/cgi_api.h index bc1124a..c93d603 100644 --- a/cgi_api.h +++ b/cgi_api.h @@ -24,7 +24,7 @@ #include "intrusive_ptr.h" #include #include -#include "function.h" +#include #include "config.h" #include @@ -43,10 +43,10 @@ namespace cppcms { namespace impl { namespace cgi { - typedef function handler; - typedef function io_handler; - typedef function callback; - typedef function ehandler; + typedef booster::function handler; + typedef booster::function io_handler; + typedef booster::function callback; + typedef booster::function ehandler; class acceptor : public util::noncopyable { public: diff --git a/clone_ptr.h b/clone_ptr.h deleted file mode 100644 index b226f72..0000000 --- a/clone_ptr.h +++ /dev/null @@ -1,77 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) 2008-2010 Artyom Beilis (Tonkikh) -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with this program. If not, see . -// -/////////////////////////////////////////////////////////////////////////////// -#ifndef CPPCMS_UTIL_CLONE_PTR_H -#define CPPCMS_UTIL_CLONE_PTR_H - -namespace cppcms { namespace util { - - - /// - /// \brief a smart pointer similar to std::auto_ptr but it clones (by calling T::clone()) - /// underlying object on copy instead of moving its ownership. - /// - template - class clone_ptr { - T *ptr_; - public: - clone_ptr() : ptr_(0) {} - clone_ptr(T *v) : ptr_(v) {} - clone_ptr(clone_ptr const &other) : ptr_(0) - { - if(other.ptr_) - ptr_=other.ptr_->clone(); - } - clone_ptr const &operator=(clone_ptr const &other) - { - if(this != &other) { - if(ptr_) { - delete ptr_; - ptr_=0; - } - if(other.ptr_) { - ptr_=other.ptr_->clone(); - } - } - return *this; - } - ~clone_ptr() { - if(ptr_) delete ptr_; - } - - T *get() const { return ptr_; } - T &operator *() const { return *ptr_; } - T *operator->() const { return ptr_; } - - T *release() { T *tmp=ptr_; ptr_=0; return tmp; } - void reset(T *p=0) - { - if(ptr_) delete ptr_; - ptr_=p; - } - void swap(clone_ptr &other) - { - T *tmp=other.ptr_; - other.ptr_=ptr_; - ptr_=tmp; - } - }; - -}} // cppcms::util - -#endif diff --git a/connection_forwarder.h b/connection_forwarder.h index 7a99afb..e6d51f1 100644 --- a/connection_forwarder.h +++ b/connection_forwarder.h @@ -31,7 +31,7 @@ namespace cppcms { private: struct data; - util::hold_ptr d; + booster::hold_ptr d; std::string ip_; int port_; }; diff --git a/copy_ptr.h b/copy_ptr.h deleted file mode 100644 index 3f952d2..0000000 --- a/copy_ptr.h +++ /dev/null @@ -1,82 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) 2008-2010 Artyom Beilis (Tonkikh) -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with this program. If not, see . -// -/////////////////////////////////////////////////////////////////////////////// -#ifndef CPPCMS_UTIL_COPY_PTR_H -#define CPPCMS_UTIL_COPY_PTR_H - -namespace cppcms { namespace util { - - /// - /// \brief a smart pointer similar to std::auto_ptr but it copies - /// underlying object on pointer copy instead of moving its ownership. - /// - /// Note: Underlying object has same constness as the pointer itself (not like in ordinary pointer). - /// - /// Don't use it with polymorphic classes. Prefer clone_ptr instead. - /// - template - class copy_ptr { - T *ptr_; - public: - copy_ptr() : ptr_(0) {} - copy_ptr(T *v) : ptr_(v) {} - copy_ptr(copy_ptr const &other) : - ptr_(other.ptr_ ? new T(*other.ptr_) : 0) - { - } - copy_ptr const &operator=(copy_ptr const &other) - { - if(this != &other) { - if(ptr_) { - delete ptr_; - ptr_=0; - } - if(other.ptr_) { - ptr_=new T(*other.ptr_); - } - } - return *this; - } - ~copy_ptr() { - if(ptr_) delete ptr_; - } - - T const *get() const { return ptr_; } - T *get() { return ptr_; } - - T const &operator *() const { return *ptr_; } - T &operator *() { return *ptr_; } - T const *operator->() const { return ptr_; } - T *operator->() { return ptr_; } - T *release() { T *tmp=ptr_; ptr_=0; return tmp; } - void reset(T *p=0) - { - if(ptr_) delete ptr_; - ptr_=p; - } - void swap(copy_ptr &other) - { - T *tmp=other.ptr_; - other.ptr_=ptr_; - ptr_=tmp; - } - }; - -}} // cppcms::util - -#endif diff --git a/filters.h b/filters.h index e5bdae7..fa66804 100644 --- a/filters.h +++ b/filters.h @@ -25,7 +25,7 @@ #include #include #include "defs.h" -#include "copy_ptr.h" +#include #include "localization.h" namespace cppcms { @@ -133,7 +133,7 @@ namespace cppcms { private: streamable obj_; struct data; - util::copy_ptr d; + booster::copy_ptr d; }; inline std::ostream &operator<<(std::ostream &out,to_upper const &obj) @@ -160,7 +160,7 @@ namespace cppcms { private: streamable obj_; struct data; - util::copy_ptr d; + booster::copy_ptr d; }; inline std::ostream &operator<<(std::ostream &out,to_lower const &obj) @@ -189,7 +189,7 @@ namespace cppcms { private: streamable obj_; struct data; - util::copy_ptr d; + booster::copy_ptr d; }; inline std::ostream &operator<<(std::ostream &out,to_title const &obj) @@ -218,7 +218,7 @@ namespace cppcms { private: streamable obj_; struct data; - util::copy_ptr d; + booster::copy_ptr d; }; inline std::ostream &operator<<(std::ostream &out,escape const &obj) @@ -246,7 +246,7 @@ namespace cppcms { private: streamable obj_; struct data; - util::copy_ptr d; + booster::copy_ptr d; }; inline std::ostream &operator<<(std::ostream &out,urlencode const &obj) @@ -273,7 +273,7 @@ namespace cppcms { private: streamable obj_; struct data; - util::copy_ptr d; + booster::copy_ptr d; }; inline std::ostream &operator<<(std::ostream &out,base64_urlencode const &obj) @@ -300,7 +300,7 @@ namespace cppcms { private: streamable obj_; struct data; - util::copy_ptr d; + booster::copy_ptr d; @@ -331,7 +331,7 @@ namespace cppcms { private: struct data; double time_; - util::copy_ptr d; + booster::copy_ptr d; }; inline std::ostream &operator<<(std::ostream &out,date const &obj) @@ -357,7 +357,7 @@ namespace cppcms { private: struct data; double time_; - util::copy_ptr d; + booster::copy_ptr d; }; inline std::ostream &operator<<(std::ostream &out,time const &obj) @@ -382,7 +382,7 @@ namespace cppcms { private: struct data; double time_; - util::copy_ptr d; + booster::copy_ptr d; }; inline std::ostream &operator<<(std::ostream &out,datetime const &obj) diff --git a/form.h b/form.h index 5148de9..2767976 100644 --- a/form.h +++ b/form.h @@ -33,7 +33,7 @@ #include "http_context.h" #include "http_request.h" #include "http_response.h" -#include "copy_ptr.h" +#include #include "cppcms_error.h" #include "util.h" #include "regex.h" @@ -96,7 +96,7 @@ namespace cppcms { uint32_t reserved_1; uint32_t reserved_2; struct data; - util::hold_ptr d; + booster::hold_ptr d; }; @@ -331,7 +331,7 @@ namespace cppcms { form *current_; unsigned offset_; struct data; - util::copy_ptr d; + booster::copy_ptr d; }; @@ -354,7 +354,7 @@ namespace cppcms { typedef std::pair widget_type; std::vector elements_; form *parent_; - util::hold_ptr d; + booster::hold_ptr d; }; @@ -607,7 +607,7 @@ namespace cppcms { uint32_t reserverd_ : 25; struct data; - util::hold_ptr d; + booster::hold_ptr d; }; /// @@ -702,7 +702,7 @@ namespace cppcms { bool validate_charset_; size_t code_points_; struct data; - util::hold_ptr d; + booster::hold_ptr d; }; class CPPCMS_API base_html_input : virtual public base_widget { @@ -715,7 +715,7 @@ namespace cppcms { virtual void render_value(form_context &context) = 0; private: struct data; - util::hold_ptr d; + booster::hold_ptr d; std::string type_; }; @@ -757,7 +757,7 @@ namespace cppcms { private: int size_; struct data; - util::hold_ptr d; + booster::hold_ptr d; }; class CPPCMS_API textarea : public base_text @@ -789,7 +789,7 @@ namespace cppcms { int rows_,cols_; struct data; - util::hold_ptr d; + booster::hold_ptr d; }; @@ -972,7 +972,7 @@ namespace cppcms { virtual bool validate(); private: struct data; - util::hold_ptr d; + booster::hold_ptr d; password *password_to_check_; }; @@ -1000,7 +1000,7 @@ namespace cppcms { private: util::regex const *expression_; struct data; - util::hold_ptr d; + booster::hold_ptr d; }; /// @@ -1016,7 +1016,7 @@ namespace cppcms { private: static util::regex const email_expression_; struct data; - util::hold_ptr d; + booster::hold_ptr d; }; /// @@ -1058,7 +1058,7 @@ namespace cppcms { virtual void load(http::context &context); private: struct data; - util::hold_ptr d; + booster::hold_ptr d; std::string identification_; bool value_; }; @@ -1141,7 +1141,7 @@ namespace cppcms { virtual void clear(); private: struct data; - util::hold_ptr d; + booster::hold_ptr d; struct element { element(); @@ -1200,14 +1200,14 @@ namespace cppcms { private: struct data; - util::copy_ptr d; + booster::copy_ptr d; }; std::vector elements_; private: struct data; - util::hold_ptr d; + booster::hold_ptr d; int selected_; int default_selected_; @@ -1223,7 +1223,7 @@ namespace cppcms { virtual void render_input(form_context &context); private: struct data; - util::hold_ptr d; + booster::hold_ptr d; }; class CPPCMS_API radio : public select_base { @@ -1239,7 +1239,7 @@ namespace cppcms { uint32_t reserved_ : 31; struct data; - util::hold_ptr d; + booster::hold_ptr d; }; @@ -1267,7 +1267,7 @@ namespace cppcms { virtual void load(http::context &context); private: struct data; - util::hold_ptr d; + booster::hold_ptr d; bool pressed_; locale::message value_; }; diff --git a/function.h b/function.h deleted file mode 100644 index f67fddf..0000000 --- a/function.h +++ /dev/null @@ -1,163 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) 2008-2010 Artyom Beilis (Tonkikh) -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with this program. If not, see . -// -/////////////////////////////////////////////////////////////////////////////// -#ifndef CPPCMS_FUNCTION_H -#define CPPCMS_FUNCTION_H - -#include "cppcms_error.h" -#include "clone_ptr.h" - -namespace cppcms { - template - class function; - - class bad_function_call : public cppcms_error { - public: - bad_function_call() : - cppcms_error("cppcms::bad_function_call") - { - } - }; - - #define CPPCMS_FUNCTION \ - template \ - class function \ - { \ - public: \ - typedef Result result_type; \ - struct callable { \ - virtual Result call(CPPCMS_TYPE_PARAMS) =0; \ - virtual callable *clone() const = 0; \ - virtual ~callable(){} \ - }; \ - \ - template \ - struct callable_impl : public callable { \ - F func; \ - callable_impl(F f) : func(f){} \ - virtual R call(CPPCMS_TYPE_PARAMS) \ - { return func(CPPCMS_CALL_PARAMS); } \ - virtual callable *clone() const \ - { return new callable_impl(func); } \ - }; \ - template \ - struct callable_impl : public callable { \ - F func; \ - callable_impl(F f) : func(f){} \ - virtual void call(CPPCMS_TYPE_PARAMS) \ - { func(CPPCMS_CALL_PARAMS); } \ - virtual callable *clone() const \ - { return new callable_impl(func); } \ - }; \ - function(){} \ - template \ - function(F func) : call_ptr(new callable_impl(func)) \ - {} \ - function(function const &other) : call_ptr(other.call_ptr) {} \ - function const &operator=(function const &other) \ - { \ - if(this != &other) { call_ptr=other.call_ptr; } \ - return *this; \ - } \ - Result operator()(CPPCMS_TYPE_PARAMS) const \ - { \ - if(!call_ptr.get()) throw bad_function_call(); \ - return call_ptr->call(CPPCMS_CALL_PARAMS); \ - } \ - bool empty() const { return call_ptr.get()==0; } \ - void swap(function &other) { call_ptr.swap(other.call_ptr); } \ - private: \ - util::clone_ptr call_ptr; \ - }; \ - - #define CPPCMS_TEMPLATE_PARAMS - #define CPPCMS_TYPE_PARAMS - #define CPPCMS_CALL_PARAMS - CPPCMS_FUNCTION - #undef CPPCMS_TEMPLATE_PARAMS - #undef CPPCMS_TYPE_PARAMS - #undef CPPCMS_CALL_PARAMS - - #define CPPCMS_TEMPLATE_PARAMS ,typename P1 - #define CPPCMS_TYPE_PARAMS P1 a1 - #define CPPCMS_CALL_PARAMS a1 - CPPCMS_FUNCTION - #undef CPPCMS_TEMPLATE_PARAMS - #undef CPPCMS_TYPE_PARAMS - #undef CPPCMS_CALL_PARAMS - - #define CPPCMS_TEMPLATE_PARAMS ,typename P1,typename P2 - #define CPPCMS_TYPE_PARAMS P1 a1,P2 a2 - #define CPPCMS_CALL_PARAMS a1,a2 - CPPCMS_FUNCTION - #undef CPPCMS_TEMPLATE_PARAMS - #undef CPPCMS_TYPE_PARAMS - #undef CPPCMS_CALL_PARAMS - - #define CPPCMS_TEMPLATE_PARAMS ,typename P1,typename P2,typename P3 - #define CPPCMS_TYPE_PARAMS P1 a1,P2 a2,P3 a3 - #define CPPCMS_CALL_PARAMS a1,a2,a3 - CPPCMS_FUNCTION - #undef CPPCMS_TEMPLATE_PARAMS - #undef CPPCMS_TYPE_PARAMS - #undef CPPCMS_CALL_PARAMS - - #define CPPCMS_TEMPLATE_PARAMS ,typename P1,typename P2,typename P3,typename P4 - #define CPPCMS_TYPE_PARAMS P1 a1,P2 a2,P3 a3,P4 a4 - #define CPPCMS_CALL_PARAMS a1,a2,a3,a4 - CPPCMS_FUNCTION - #undef CPPCMS_TEMPLATE_PARAMS - #undef CPPCMS_TYPE_PARAMS - #undef CPPCMS_CALL_PARAMS - - #define CPPCMS_TEMPLATE_PARAMS ,typename P1,typename P2,typename P3,typename P4,typename P5 - #define CPPCMS_TYPE_PARAMS P1 a1,P2 a2,P3 a3,P4 a4,P5 a5 - #define CPPCMS_CALL_PARAMS a1,a2,a3,a4,a5 - CPPCMS_FUNCTION - #undef CPPCMS_TEMPLATE_PARAMS - #undef CPPCMS_TYPE_PARAMS - #undef CPPCMS_CALL_PARAMS - - #define CPPCMS_TEMPLATE_PARAMS ,typename P1,typename P2,typename P3,typename P4,typename P5,typename P6 - #define CPPCMS_TYPE_PARAMS P1 a1,P2 a2,P3 a3,P4 a4,P5 a5,P6 a6 - #define CPPCMS_CALL_PARAMS a1,a2,a3,a4,a5,a6 - CPPCMS_FUNCTION - #undef CPPCMS_TEMPLATE_PARAMS - #undef CPPCMS_TYPE_PARAMS - #undef CPPCMS_CALL_PARAMS - #define CPPCMS_TEMPLATE_PARAMS ,typename P1,typename P2,typename P3,typename P4,typename P5,typename P6,typename P7 - #define CPPCMS_TYPE_PARAMS P1 a1,P2 a2,P3 a3,P4 a4,P5 a5,P6 a6,P7 a7 - #define CPPCMS_CALL_PARAMS a1,a2,a3,a4,a5,a6,a7 - CPPCMS_FUNCTION - #undef CPPCMS_TEMPLATE_PARAMS - #undef CPPCMS_TYPE_PARAMS - #undef CPPCMS_CALL_PARAMS - #define CPPCMS_TEMPLATE_PARAMS ,typename P1,typename P2,typename P3,typename P4,typename P5,typename P6,typename P7,typename P8 - #define CPPCMS_TYPE_PARAMS P1 a1,P2 a2,P3 a3,P4 a4,P5 a5,P6 a6,P7 a7,P8 a8 - #define CPPCMS_CALL_PARAMS a1,a2,a3,a4,a5,a6,a7,a8 - CPPCMS_FUNCTION - #undef CPPCMS_TEMPLATE_PARAMS - #undef CPPCMS_TYPE_PARAMS - #undef CPPCMS_CALL_PARAMS - - #undef CPPCMS_FUNCTION - -} // cppcms - - -#endif diff --git a/hold_ptr.h b/hold_ptr.h deleted file mode 100644 index 1badca3..0000000 --- a/hold_ptr.h +++ /dev/null @@ -1,63 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) 2008-2010 Artyom Beilis (Tonkikh) -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with this program. If not, see . -// -/////////////////////////////////////////////////////////////////////////////// -#ifndef CPPCMS_UTIL_HOLD_PTR_H -#define CPPCMS_UTIL_HOLD_PTR_H - -namespace cppcms { namespace util { - - /// - /// \brief a smart pointer similar to std::auto_ptr but it is non-copyable and - /// underlying object has same constness as the pointer itself (not like in ordinary pointer). - /// - template - class hold_ptr { - T *ptr_; - hold_ptr(hold_ptr const &other); // non copyable - hold_ptr const &operator=(hold_ptr const &other); // non assignable - public: - hold_ptr() : ptr_(0) {} - hold_ptr(T *v) : ptr_(v) {} - ~hold_ptr() - { - if(ptr_) delete ptr_; - } - - T const *get() const { return ptr_; } - T *get() { return ptr_; } - - T const &operator *() const { return *ptr_; } - T &operator *() { return *ptr_; } - T const *operator->() const { return ptr_; } - T *operator->() { return ptr_; } - T *release() { T *tmp=ptr_; ptr_=0; return tmp; } - void reset(T *p=0) - { - if(ptr_) delete ptr_; - ptr_=p; - } - void swap(hold_ptr &other) - { - T *tmp=other.ptr_; - other.ptr_=ptr_; - ptr_=tmp; - } - }; -} } // cppcms::util; - -#endif diff --git a/http_client.cpp b/http_client.cpp index 893b06f..addc685 100644 --- a/http_client.cpp +++ b/http_client.cpp @@ -37,7 +37,7 @@ namespace cppcms { std::string response; std::vector > response_headers; - void async_transfer(function const &handler); + void async_transfer(booster::function const &handler); /// /// Reset the object to initial state for reuse @@ -128,7 +128,7 @@ namespace cppcms { void check(); - util::hold_ptr impl_; + booster::hold_ptr impl_; }; } diff --git a/http_context.cpp b/http_context.cpp index 0aa36e0..3dc9bf0 100644 --- a/http_context.cpp +++ b/http_context.cpp @@ -185,7 +185,7 @@ context::~context() { } -void context::async_on_peer_reset(function const &h) +void context::async_on_peer_reset(booster::function const &h) { // For some wired can't go without bind on SunCC conn_->aync_wait_for_close_by_peer(boost::bind(h)); diff --git a/http_context.h b/http_context.h index a33eadf..c5a9b7f 100644 --- a/http_context.h +++ b/http_context.h @@ -20,10 +20,10 @@ #define CPPCMS_HTTP_CONTEXT_H #include "defs.h" -#include "hold_ptr.h" +#include #include "intrusive_ptr.h" #include "refcounted.h" -#include "function.h" +#include #include namespace cppcms { @@ -136,7 +136,7 @@ namespace cppcms { operation_aborted ///< Asynchronous operation was canceled } complition_type; - typedef function handler; + typedef booster::function handler; /// /// Send all pending output data to the client and @@ -165,7 +165,7 @@ namespace cppcms { /// 2. If async_flush_output fails, this does not mean that /// this handler would be called as well, so you need to check both /// - void async_on_peer_reset(function const &h); + void async_on_peer_reset(booster::function const &h); private: void on_request_ready(bool error); static void dispatch(intrusive_ptr app,std::string url,bool syncronous); @@ -173,7 +173,7 @@ namespace cppcms { intrusive_ptr self(); struct data; - util::hold_ptr d; + booster::hold_ptr d; intrusive_ptr conn_; }; diff --git a/http_cookie.h b/http_cookie.h index 265a740..34d4095 100644 --- a/http_cookie.h +++ b/http_cookie.h @@ -20,7 +20,7 @@ #define CPPCMS_HTTP_COOKIE_H #include "defs.h" -#include "copy_ptr.h" +#include #include #include @@ -131,7 +131,7 @@ private: void write(std::ostream &) const; // for future use struct data; - util::copy_ptr d; + booster::copy_ptr d; // real members std::string name_; diff --git a/http_file.h b/http_file.h index 3b4b86a..61e8d20 100644 --- a/http_file.h +++ b/http_file.h @@ -20,7 +20,7 @@ #define CPPCMS_HTTP_FILE_H #include "defs.h" -#include "hold_ptr.h" +#include #include "noncopyable.h" #include #include @@ -51,7 +51,7 @@ namespace cppcms { namespace http { uint32_t reserverd_ : 31; struct impl_data; // for future use - util::hold_ptr d; + booster::hold_ptr d; friend class request; }; diff --git a/http_request.h b/http_request.h index 8fec3bd..6cca39e 100644 --- a/http_request.h +++ b/http_request.h @@ -21,7 +21,7 @@ #include "defs.h" #include "noncopyable.h" -#include "hold_ptr.h" +#include #include #include @@ -126,7 +126,7 @@ namespace http { form_type post_; files_type files_; cookies_type cookies_; - util::hold_ptr d; + booster::hold_ptr d; impl::cgi::connection *conn_; }; diff --git a/http_response.h b/http_response.h index 759da02..e1c44c5 100644 --- a/http_response.h +++ b/http_response.h @@ -21,7 +21,7 @@ #include "defs.h" #include "noncopyable.h" -#include "hold_ptr.h" +#include #include #include @@ -167,7 +167,7 @@ namespace http { std::string get_async_chunk(); struct data; - util::hold_ptr d; + booster::hold_ptr d; context &context_; std::ostream *stream_; diff --git a/json.h b/json.h index 3453c74..a0cfa81 100644 --- a/json.h +++ b/json.h @@ -20,7 +20,7 @@ #define CPPCMS_JSON_H #include "defs.h" -#include "copy_ptr.h" +#include #include #include @@ -261,7 +261,7 @@ namespace json { d.swap(other.d); } private: - util::copy_ptr d; + booster::copy_ptr d; } d; friend struct copyable; diff --git a/logger.h b/logger.h index d031b29..623b155 100644 --- a/logger.h +++ b/logger.h @@ -23,8 +23,8 @@ #include #include -#include "copy_ptr.h" -#include "hold_ptr.h" +#include +#include #include "noncopyable.h" namespace cppcms { @@ -56,7 +56,7 @@ namespace cppcms { char const *module_; logger *log_; struct data; - util::copy_ptr d; + booster::copy_ptr d; std::auto_ptr output_; }; @@ -85,7 +85,7 @@ namespace cppcms { private: static void init(std::auto_ptr &logger_ref); struct data; - util::hold_ptr d; + booster::hold_ptr d; }; diff --git a/regex.h b/regex.h index d5744c9..0e631c2 100644 --- a/regex.h +++ b/regex.h @@ -21,7 +21,7 @@ #include "defs.h" #include "noncopyable.h" -#include "hold_ptr.h" +#include #include namespace cppcms { namespace util { @@ -64,7 +64,7 @@ namespace cppcms { namespace util { private: struct data; - hold_ptr d; + booster::hold_ptr d; }; /// @@ -85,7 +85,7 @@ namespace cppcms { namespace util { private: friend class regex; struct data; - hold_ptr d; + booster::hold_ptr d; }; }} // cppcms::util diff --git a/rpc_json.h b/rpc_json.h index fe797b8..b4e8d68 100644 --- a/rpc_json.h +++ b/rpc_json.h @@ -22,8 +22,9 @@ #include "application.h" #include "refcounted.h" #include "intrusive_ptr.h" -#include "function.h" +#include #include "json.h" +#include "cppcms_error.h" namespace cppcms { namespace rpc { @@ -109,7 +110,7 @@ namespace rpc { bool notification_; struct data; - util::hold_ptr d; + booster::hold_ptr d; }; /// @@ -129,7 +130,7 @@ namespace rpc { /// /// Generic type of JSON-RPC method /// - typedef function method_type; + typedef booster::function method_type; /// /// Bind method JSON-RPC method with name \a name @@ -202,7 +203,7 @@ namespace rpc { std::string smd_; struct data; - util::hold_ptr d; + booster::hold_ptr d; }; diff --git a/service.cpp b/service.cpp index ad4bde0..0279398 100644 --- a/service.cpp +++ b/service.cpp @@ -303,7 +303,7 @@ void service::shutdown() #endif } -void service::after_fork(function const &cb) +void service::after_fork(booster::function const &cb) { impl_->on_fork_.push_back(cb); } @@ -596,7 +596,7 @@ cppcms::impl::service &service::impl() return *impl_; } -void service::post(function const &handler) +void service::post(booster::function const &handler) { impl_->get_io_service().post(handler); } diff --git a/service.h b/service.h index 13842d9..96bc5ac 100644 --- a/service.h +++ b/service.h @@ -21,8 +21,8 @@ #include "defs.h" #include "noncopyable.h" -#include "hold_ptr.h" -#include "function.h" +#include +#include #include namespace booster { @@ -75,8 +75,8 @@ namespace cppcms { cppcms::impl::service &impl(); - void post(function const &handler); - void after_fork(function const &handler); + void post(booster::function const &handler); + void after_fork(booster::function const &handler); int threads_no(); int procs_no(); @@ -89,7 +89,7 @@ namespace cppcms { void start_acceptor(); void setup_exit_handling(); bool prefork(); - util::hold_ptr impl_; + booster::hold_ptr impl_; }; } // diff --git a/service_impl.h b/service_impl.h index ecd5e43..4eb925c 100644 --- a/service_impl.h +++ b/service_impl.h @@ -68,7 +68,7 @@ namespace impl { std::auto_ptr session_pool_; std::locale default_locale_; - std::vector > on_fork_; + std::vector > on_fork_; int id_; diff --git a/session_cookies.h b/session_cookies.h index 703d5b4..a020da7 100644 --- a/session_cookies.h +++ b/session_cookies.h @@ -19,7 +19,7 @@ #ifndef CPPCMS_SESSION_COOKIES_H #define CPPCMS_SESSION_COOKIES_H #include "session_api.h" -#include "hold_ptr.h" +#include #include "noncopyable.h" #include #include @@ -49,7 +49,7 @@ namespace sessions { virtual void clear(session_interface &); private: struct data; - util::hold_ptr d; + booster::hold_ptr d; std::auto_ptr encryptor_; }; diff --git a/session_dual.h b/session_dual.h index f229e06..aeb5025 100644 --- a/session_dual.h +++ b/session_dual.h @@ -21,7 +21,7 @@ #include "session_api.h" #include "defs.h" -#include "hold_ptr.h" +#include #include "intrusive_ptr.h" #include @@ -44,7 +44,7 @@ public: virtual void clear(session_interface &); private: struct data; - util::hold_ptr d; + booster::hold_ptr d; intrusive_ptr client_; intrusive_ptr server_; size_t data_size_limit_; diff --git a/session_interface.h b/session_interface.h index 19272de..3e34ed3 100644 --- a/session_interface.h +++ b/session_interface.h @@ -21,7 +21,7 @@ #include "defs.h" #include "noncopyable.h" -#include "hold_ptr.h" +#include #include "intrusive_ptr.h" #include "cstdint.h" #include @@ -139,7 +139,7 @@ private: intrusive_ptr storage_; struct data; - util::hold_ptr d; // for future use + booster::hold_ptr d; // for future use int cookie_age(); time_t session_age(); diff --git a/session_pool.h b/session_pool.h index c68f4bc..cf3fb1f 100644 --- a/session_pool.h +++ b/session_pool.h @@ -21,7 +21,7 @@ #include "defs.h" #include "intrusive_ptr.h" -#include "hold_ptr.h" +#include #include "session_api.h" #include @@ -64,7 +64,7 @@ namespace cppcms { friend struct sid_factory; friend class gc_job; - util::hold_ptr d; + booster::hold_ptr d; std::auto_ptr backend_; std::auto_ptr encryptor_; diff --git a/session_posix_file_storage.h b/session_posix_file_storage.h index de8e53b..639b7a8 100644 --- a/session_posix_file_storage.h +++ b/session_posix_file_storage.h @@ -21,7 +21,7 @@ #include "defs.h" #include "session_storage.h" -#include "hold_ptr.h" +#include #include #include @@ -54,7 +54,7 @@ namespace sessions { // members - util::hold_ptr d; + booster::hold_ptr d; void *memory_; std::string path_; diff --git a/session_sid.h b/session_sid.h index ef1ea69..5ee86a4 100644 --- a/session_sid.h +++ b/session_sid.h @@ -21,7 +21,7 @@ #include "session_api.h" #include "defs.h" -#include "hold_ptr.h" +#include #include "intrusive_ptr.h" #include "session_storage.h" @@ -43,7 +43,7 @@ namespace sessions { std::string key(std::string sid); struct data; - util::hold_ptr d; + booster::hold_ptr d; intrusive_ptr storage_; }; diff --git a/session_win32_file_storage.h b/session_win32_file_storage.h index ae12536..de44ac8 100644 --- a/session_win32_file_storage.h +++ b/session_win32_file_storage.h @@ -21,7 +21,7 @@ #include "defs.h" #include "session_storage.h" -#include "hold_ptr.h" +#include #include @@ -50,7 +50,7 @@ namespace sessions { // members - util::hold_ptr d; + booster::hold_ptr d; std::string path_; // friends diff --git a/tcp_cache_server.h b/tcp_cache_server.h index da62971..5b6b49b 100644 --- a/tcp_cache_server.h +++ b/tcp_cache_server.h @@ -23,7 +23,7 @@ #include "base_cache.h" #include "noncopyable.h" #include "intrusive_ptr.h" -#include "hold_ptr.h" +#include namespace cppcms { namespace impl { @@ -37,7 +37,7 @@ private: class session; class server; struct data; - util::hold_ptr d; + booster::hold_ptr d; }; } // impl diff --git a/tests/function_test.cpp b/tests/function_test.cpp deleted file mode 100644 index 09d06a1..0000000 --- a/tests/function_test.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) 2008-2010 Artyom Beilis (Tonkikh) -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with this program. If not, see . -// -/////////////////////////////////////////////////////////////////////////////// -#include "function.h" -#include "test.h" -#include - -bool foov_called; -void foov() { - foov_called=true; -} -bool fooi_called; -int fooi() -{ - fooi_called=true; - return 10; -} -bool fooid_called; - -int fooid(double const &v) -{ - TEST(v==10.0); - fooid_called = true; - return 0; -} - -int fooii(int &x) -{ - return x++; -} - -void reset() -{ - foov_called = fooi_called = fooid_called = false; -} - - -int main() -{ - using cppcms::function; - try { - reset(); - function f=foov; - f(); - TEST(foov_called); - f=fooi; - f(); - TEST(fooi_called); - function fi=fooi; - TEST(fi()==10); - TEST(!fi.empty()); - function fvi; - TEST(fvi.empty()); - try { - fvi(10); - throw std::runtime_error("Not throws!"); - } - catch(cppcms::bad_function_call const &e) {} - fvi=fooid; - TEST(!fvi.empty()); - fvi(10); - TEST(fooid_called); - int x=2; - TEST(function(fooii)(x)==2); - TEST(x==3); - } - catch(std::exception const &e) - { - std::cout << "Fail"<< e.what() << std::endl; - return 1; - } - std::cout << "Ok" << std::endl; - return 0; -} diff --git a/thread_pool.cpp b/thread_pool.cpp index 693ace1..2ed925f 100644 --- a/thread_pool.cpp +++ b/thread_pool.cpp @@ -52,7 +52,7 @@ namespace impl { } return false; } - int post(function const &job) + int post(booster::function const &job) { booster::unique_lock lock(mutex_); int id=job_id_++; @@ -109,7 +109,7 @@ namespace impl { void worker() { for(;;) { - function job; + booster::function job; { booster::unique_lock lock(mutex_); @@ -135,7 +135,7 @@ namespace impl { bool shut_down_; int job_id_; - typedef std::list > > queue_type; + typedef std::list > > queue_type; queue_type queue_; std::vector > workers_; @@ -150,7 +150,7 @@ thread_pool::thread_pool(int n) : { } -int thread_pool::post(function const &job) +int thread_pool::post(booster::function const &job) { return impl_->post(job); } diff --git a/thread_pool.h b/thread_pool.h index 697a6da..cc17818 100644 --- a/thread_pool.h +++ b/thread_pool.h @@ -21,8 +21,8 @@ #include "defs.h" #include "noncopyable.h" -#include "function.h" -#include "hold_ptr.h" +#include +#include namespace cppcms { @@ -33,7 +33,7 @@ namespace cppcms { class CPPCMS_API thread_pool : public util::noncopyable { public: - int post(function const &job); + int post(booster::function const &job); bool cancel(int id); thread_pool(int threads); void stop(); @@ -41,7 +41,7 @@ namespace cppcms { private: - util::hold_ptr impl_; + booster::hold_ptr impl_; }; diff --git a/urandom.h b/urandom.h index 3dda78a..d7b4a87 100644 --- a/urandom.h +++ b/urandom.h @@ -20,7 +20,7 @@ #define CPPCMS_URANDOM_H #include "defs.h" -#include "hold_ptr.h" +#include #include "noncopyable.h" namespace cppcms { @@ -33,7 +33,7 @@ namespace cppcms { private: struct data; - util::hold_ptr d; + booster::hold_ptr d; }; diff --git a/url_dispatcher.h b/url_dispatcher.h index e37f1ca..b725557 100644 --- a/url_dispatcher.h +++ b/url_dispatcher.h @@ -21,8 +21,8 @@ #include "noncopyable.h" #include "defs.h" -#include "function.h" -#include "hold_ptr.h" +#include +#include #include "mem_bind.h" #include #include @@ -54,11 +54,11 @@ namespace cppcms { class CPPCMS_API url_dispatcher : public util::noncopyable { public: // Handlers - typedef function handler; - typedef function handler1; - typedef function handler2; - typedef function handler3; - typedef function handler4; + typedef booster::function handler; + typedef booster::function handler1; + typedef booster::function handler2; + typedef booster::function handler3; + typedef booster::function handler4; /// /// Assign \a handler to pattern \a regex thus if URL that matches @@ -160,7 +160,7 @@ namespace cppcms { void mount(std::string match,application &app,int part); struct data; - util::hold_ptr d; + booster::hold_ptr d; }; } // cppcms diff --git a/views_pool.h b/views_pool.h index dd4946c..b2a8373 100644 --- a/views_pool.h +++ b/views_pool.h @@ -65,7 +65,7 @@ namespace cppcms { struct data; struct skin; - util::hold_ptr d; + booster::hold_ptr d; }; }