mail[Wesnoth-commits] r43623 - in /trunk/src/ana: api/ src/


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by billybiset on June 21, 2010 - 02:36:
Author: billynux
Date: Mon Jun 21 02:36:14 2010
New Revision: 43623

URL: http://svn.gna.org/viewcvs/wesnoth?rev=43623&view=rev
Log:
Fixed the use of component ids throughout ana.

Modified:
    trunk/src/ana/api/ana.hpp
    trunk/src/ana/src/CMakeLists.txt
    trunk/src/ana/src/asio_client.cpp
    trunk/src/ana/src/asio_client.hpp
    trunk/src/ana/src/asio_server.cpp
    trunk/src/ana/src/asio_server.hpp

Modified: trunk/src/ana/api/ana.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/ana/api/ana.hpp?rev=43623&r1=43622&r2=43623&view=diff
==============================================================================
--- trunk/src/ana/api/ana.hpp (original)
+++ trunk/src/ana/api/ana.hpp Mon Jun 21 02:36:14 2010
@@ -123,6 +123,9 @@
     /** Used for implementation purposes. */
     namespace detail
     {
+        /** Last issued client_id.  */ 
+        static client_id last_client_id_ = 0;
+
         /**
          * Base class for any network entity that handles incoming messages.
          */
@@ -140,19 +143,22 @@
                 virtual void set_listener_handler( listener_handler* 
listener ) = 0;
 
                 /**
-                 * Get the client_id of this listener.
+                 * Get the ID of this listener.
                  *
-                 * @returns : ServerID for the server application, or a 
comparable client_id
-                 *            unique to this listener.
-                 *
-                 * \sa ServerID
-                 * \sa client_id
+                 * @returns : ID of the network component represented by 
this listener.
                  */
-                virtual client_id id() const                                 
   = 0;
-
-            protected: // should be so?
+                client_id id() const {return id_;}
+
+            protected:
+                listener() :
+                    id_(++last_client_id_)
+                {
+                }
+
                 /** Start listening for incoming messages. */
                 virtual void run_listener()                                  
   = 0;
+
+                const client_id     id_               /** This proxy's 
client_id. */ ;
         };
     } //namespace details
 
@@ -351,43 +357,27 @@
         /**
          * A connected client's representative in the server side.
          */
-        class client_proxy : public virtual detail::listener,
-                             boost::noncopyable
+        struct client_proxy : public virtual detail::listener,
+                              boost::noncopyable
         {
-            public:
-                /**
-                 * Send a buffer to the corresponding client.
-                 *
-                 * @param buffer : The memory portion or buffer being sent.
-                 * @param handler : The handler of the completion or error 
event.
-                 * @param sender : The object with the timeout configuration.
-                 *
-                 * \sa shared_buffer
-                 * \sa send_handler
-                 * \sa timed_sender
-                 */
-                virtual void send(detail::shared_buffer, send_handler*, 
timed_sender* ) = 0;
-
-                /**
-                 * Get the ID of this client.
-                 *
-                 * @returns : ID of the client represented by this proxy.
-                 */
-                virtual client_id id() const {return id_;}
-
-                /** Standard destructor. */
-                virtual ~client_proxy() {}
-
-                // Allow server objects to invoke run_listener directly.
-                using detail::listener::run_listener;
-
-            protected:
-                /** Standard constructor, sets the ID to the next available 
one. */
-                client_proxy() : id_(++last_client_id_) {}
-
-            private:
-                static client_id    last_client_id_   /** Last issued 
client_id.  */ ;
-                const client_id     id_               /** This proxy's 
client_id. */ ;
+            /**
+             * Send a buffer to the corresponding client.
+             *
+             * @param buffer : The memory portion or buffer being sent.
+             * @param handler : The handler of the completion or error event.
+             * @param sender : The object with the timeout configuration.
+             *
+             * \sa shared_buffer
+             * \sa send_handler
+             * \sa timed_sender
+             */
+            virtual void send(detail::shared_buffer, send_handler*, 
timed_sender* ) = 0;
+
+            /** Standard destructor. */
+            virtual ~client_proxy() {}
+
+            // Allow server objects to invoke run_listener directly.
+            using detail::listener::run_listener;
         };
     };
 

Modified: trunk/src/ana/src/CMakeLists.txt
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/ana/src/CMakeLists.txt?rev=43623&r1=43622&r2=43623&view=diff
==============================================================================
--- trunk/src/ana/src/CMakeLists.txt (original)
+++ trunk/src/ana/src/CMakeLists.txt Mon Jun 21 02:36:14 2010
@@ -2,7 +2,7 @@
 
 include_directories( ../api )
 
-find_package( Boost 1.35 REQUIRED COMPONENTS thread bind)
+find_package( Boost 1.35 REQUIRED COMPONENTS thread system)
 
 set ( common_srcs asio_listener.cpp )
 

Modified: trunk/src/ana/src/asio_client.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/ana/src/asio_client.cpp?rev=43623&r1=43622&r2=43623&view=diff
==============================================================================
--- trunk/src/ana/src/asio_client.cpp (original)
+++ trunk/src/ana/src/asio_client.cpp Mon Jun 21 02:36:14 2010
@@ -67,11 +67,6 @@
         run_listener( );
 
     boost::thread t( boost::bind( &boost::asio::io_service::run, 
&io_service_) );
-}
-
-ana::client_id asio_client::id() const
-{
-    return 0;
 }
 
 void asio_client::handle_proxy_connection(const boost::system::error_code& 
ec, ana::connection_handler* handler)

Modified: trunk/src/ana/src/asio_client.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/ana/src/asio_client.hpp?rev=43623&r1=43622&r2=43623&view=diff
==============================================================================
--- trunk/src/ana/src/asio_client.hpp (original)
+++ trunk/src/ana/src/asio_client.hpp Mon Jun 21 02:36:14 2010
@@ -69,8 +69,6 @@
 
         virtual void run();
 
-        virtual ana::client_id id() const;
-
         virtual void send( boost::asio::const_buffer, ana::send_handler*, 
ana::send_type );
 
         virtual void disconnect_listener();

Modified: trunk/src/ana/src/asio_server.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/ana/src/asio_server.cpp?rev=43623&r1=43622&r2=43623&view=diff
==============================================================================
--- trunk/src/ana/src/asio_server.cpp (original)
+++ trunk/src/ana/src/asio_server.cpp Mon Jun 21 02:36:14 2010
@@ -42,8 +42,6 @@
 using namespace ana;
 
 using boost::asio::ip::tcp;
-
-client_id server::client_proxy::last_client_id_ = 0;
 
 asio_server::asio_server() :
     io_service_(),
@@ -102,11 +100,6 @@
     io_thread_ = boost::thread( boost::bind( &boost::asio::io_service::run, 
&io_service_) );
 }
 
-client_id asio_server::id() const
-{
-    return 0;
-}
-
 void asio_server::async_accept( connection_handler* handler )
 {
     try

Modified: trunk/src/ana/src/asio_server.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/ana/src/asio_server.hpp?rev=43623&r1=43622&r2=43623&view=diff
==============================================================================
--- trunk/src/ana/src/asio_server.hpp (original)
+++ trunk/src/ana/src/asio_server.hpp Mon Jun 21 02:36:14 2010
@@ -96,8 +96,6 @@
         virtual void run_listener();
         virtual void run(ana::port pt);
 
-        virtual ana::client_id id() const;
-
         virtual void deregister_client(client_proxy* client);
 
         void handle_accept (const boost::system::error_code& 
ec,asio_client_proxy* client, ana::connection_handler* );




Related Messages


Powered by MHonArc, Updated Mon Jun 21 03:00:18 2010