connection_wrapper.h

Go to the documentation of this file.
00001 #ifndef _SIGX_CONNECTION_HPP_
00002 #define _SIGX_CONNECTION_HPP_
00003 
00004 /*
00005  * Copyright 2006 Klaus Triendl
00006  *
00007  * This library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Library General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2 of the License, or (at your option) any later version.
00011  *
00012  * This library is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00015  * Library General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Library General Public
00018  * License along with this library; if not, write to the Free 
00019  * Software Foundation, 51 Franklin Street, Fifth Floor, 
00020  * Boston, MA 02110-1301, USA.
00021 */
00022 
00023 #include <tr1/memory>   // std::tr1::shared_ptr
00024 #include <sigxconfig.h>
00025 #include <sigx/fwddecl.h>
00026 #include <sigx/shared_dispatchable.h>
00027 
00028 
00029 namespace sigx
00030 {
00031 
00035 class SIGX_API connection_wrapper
00036 {
00037 private:
00038     // volatile because the value should be always read from the variable itself;
00039     // this is necessary because the sigc::connection* is "late bound", i.e.
00040     // it is set by the server thread after an asynchronous "connect" message.
00041     // When the next tunnel functor is created (let's say with disconnect()) 
00042     // then m_sigc_conn is dereferenced (*m_sigc_conn) and the actual pointer 
00043     // value (the sigc::connection*) is treated volatile at the other side of 
00044     // the tunnel (at the server thread's side).
00045     // It is const because the connection_wrapper object doesn't modify the pointer.
00046     typedef std::tr1::shared_ptr<const volatile sigc_connection_ptr> shared_sigc_conn_ptr;
00047 
00048 
00049 public:
00052     connection_wrapper();
00056     connection_wrapper(const shared_dispatchable& _A_disp, const shared_sigc_conn_ptr& _A_conn);
00059     connection_wrapper(const connection_wrapper& other) throw();
00060 
00064     ~connection_wrapper() throw();
00065 
00068     connection_wrapper& operator =(const connection_wrapper& other);
00069 
00070 
00071 public:
00075     bool empty() const;
00076 
00080     bool connected() const;
00081 
00085     bool blocked() const;
00086 
00090     bool block(bool should_block = true);
00091 
00095     bool unblock();
00096 
00100     void disconnect();
00101 
00106     operator bool();
00107 
00108 protected:
00109     void destroy_self();
00110 
00111 
00112 private:
00114     shared_sigc_conn_ptr m_sigc_conn;
00117     shared_dispatchable m_shared_disp;
00119     volatile int* m_sigcconn_refcount;
00120 };
00121 
00122 
00123 } // namespace sigx
00124 
00125 
00126 #endif // end file guard

Generated on Wed Jan 28 21:37:59 2009 for sigx++ by  doxygen 1.5.8