diff options
author | David Robillard <d@drobilla.net> | 2013-01-12 23:38:03 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2013-01-12 23:38:03 +0000 |
commit | df1447c665e6c3631961297a9d3e9aff4e94c47f (patch) | |
tree | c0ff117c362e6d571f430f886ab62f372b59af08 /src/socket | |
parent | bb335dca695273622b7a4ebbefbe9e089edb9ab4 (diff) | |
download | ingen-df1447c665e6c3631961297a9d3e9aff4e94c47f.tar.gz ingen-df1447c665e6c3631961297a9d3e9aff4e94c47f.tar.bz2 ingen-df1447c665e6c3631961297a9d3e9aff4e94c47f.zip |
Remove Raul::SharedPtr and switch to std::shared_ptr.
Use project local short type aliases for shared_ptr and friends.
Move Raul::Disposable and Raul::Manageable into Raul::Maid.
Use sets to store machina nodes and edges to avoid O(n) searches.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4939 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/socket')
-rw-r--r-- | src/socket/Socket.cpp | 7 | ||||
-rw-r--r-- | src/socket/Socket.hpp | 5 | ||||
-rw-r--r-- | src/socket/SocketClient.hpp | 16 | ||||
-rw-r--r-- | src/socket/SocketListener.cpp | 4 | ||||
-rw-r--r-- | src/socket/SocketListener.hpp | 1 | ||||
-rw-r--r-- | src/socket/SocketReader.cpp | 6 | ||||
-rw-r--r-- | src/socket/SocketReader.hpp | 18 | ||||
-rw-r--r-- | src/socket/SocketServer.hpp | 10 | ||||
-rw-r--r-- | src/socket/SocketWriter.cpp | 8 | ||||
-rw-r--r-- | src/socket/SocketWriter.hpp | 28 | ||||
-rw-r--r-- | src/socket/ingen_socket_client.cpp | 14 | ||||
-rw-r--r-- | src/socket/ingen_socket_server.cpp | 4 |
12 files changed, 61 insertions, 60 deletions
diff --git a/src/socket/Socket.cpp b/src/socket/Socket.cpp index 2de88226..689e7eb6 100644 --- a/src/socket/Socket.cpp +++ b/src/socket/Socket.cpp @@ -21,6 +21,7 @@ #include <stdlib.h> #include <sys/socket.h> #include <sys/un.h> +#include <unistd.h> #include <string> @@ -142,7 +143,7 @@ Socket::listen() } } -SharedPtr<Socket> +SPtr<Socket> Socket::accept() { socklen_t client_addr_len = _addr_len; @@ -151,7 +152,7 @@ Socket::accept() int conn = ::accept(_sock, client_addr, &client_addr_len); if (conn == -1) { - return SharedPtr<Socket>(); + return SPtr<Socket>(); } Raul::URI client_uri = _uri; @@ -161,7 +162,7 @@ Socket::accept() client_uri = Raul::URI(_uri.scheme() + "://" + host); } - return SharedPtr<Socket>( + return SPtr<Socket>( new Socket(_type, client_uri, client_addr, client_addr_len, conn)); } diff --git a/src/socket/Socket.hpp b/src/socket/Socket.hpp index ed2ddb74..ebe9f68f 100644 --- a/src/socket/Socket.hpp +++ b/src/socket/Socket.hpp @@ -21,9 +21,10 @@ #include <sys/socket.h> #include "raul/Noncopyable.hpp" -#include "raul/SharedPtr.hpp" #include "raul/URI.hpp" +#include "ingen/types.hpp" + namespace Ingen { namespace Socket { @@ -71,7 +72,7 @@ public: /** Accept a connection. * @return An new open socket for the connection. */ - SharedPtr<Socket> accept(); + SPtr<Socket> accept(); /** Return the file descriptor for the socket. */ int fd() { return _sock; } diff --git a/src/socket/SocketClient.hpp b/src/socket/SocketClient.hpp index 14227c90..b05cb343 100644 --- a/src/socket/SocketClient.hpp +++ b/src/socket/SocketClient.hpp @@ -27,10 +27,10 @@ namespace Socket { class SocketClient : public SocketWriter { public: - SocketClient(World& world, - const Raul::URI& uri, - SharedPtr<Socket> sock, - SharedPtr<Interface> respondee) + SocketClient(World& world, + const Raul::URI& uri, + SPtr<Socket> sock, + SPtr<Interface> respondee) : SocketWriter(world.uri_map(), world.uris(), uri, sock) , _respondee(respondee) , _reader(world, *respondee.get(), sock) @@ -38,17 +38,17 @@ public: _reader.start(); } - virtual SharedPtr<Interface> respondee() const { + virtual SPtr<Interface> respondee() const { return _respondee; } - virtual void set_respondee(SharedPtr<Interface> respondee) { + virtual void set_respondee(SPtr<Interface> respondee) { _respondee = respondee; } private: - SharedPtr<Interface> _respondee; - SocketReader _reader; + SPtr<Interface> _respondee; + SocketReader _reader; }; } // namespace Socket diff --git a/src/socket/SocketListener.cpp b/src/socket/SocketListener.cpp index 0628b7a5..4e1f9512 100644 --- a/src/socket/SocketListener.cpp +++ b/src/socket/SocketListener.cpp @@ -109,14 +109,14 @@ SocketListener::_run() } if (pfds[0].revents & POLLIN) { - SharedPtr<Socket> conn = _unix_sock.accept(); + SPtr<Socket> conn = _unix_sock.accept(); if (conn) { new SocketServer(_world, *engine, conn); } } if (pfds[1].revents & POLLIN) { - SharedPtr<Socket> conn = _net_sock.accept(); + SPtr<Socket> conn = _net_sock.accept(); if (conn) { new SocketServer(_world, *engine, conn); } diff --git a/src/socket/SocketListener.hpp b/src/socket/SocketListener.hpp index c4700ed4..bea55da2 100644 --- a/src/socket/SocketListener.hpp +++ b/src/socket/SocketListener.hpp @@ -16,7 +16,6 @@ #include <string> -#include "raul/SharedPtr.hpp" #include "raul/Thread.hpp" #include "Socket.hpp" diff --git a/src/socket/SocketReader.cpp b/src/socket/SocketReader.cpp index cc5da947..4ff65b3b 100644 --- a/src/socket/SocketReader.cpp +++ b/src/socket/SocketReader.cpp @@ -30,9 +30,9 @@ namespace Ingen { namespace Socket { -SocketReader::SocketReader(Ingen::World& world, - Interface& iface, - SharedPtr<Socket> sock) +SocketReader::SocketReader(Ingen::World& world, + Interface& iface, + SPtr<Socket> sock) : Raul::Thread() , _world(world) , _iface(iface) diff --git a/src/socket/SocketReader.hpp b/src/socket/SocketReader.hpp index 51435368..ea2bcd8e 100644 --- a/src/socket/SocketReader.hpp +++ b/src/socket/SocketReader.hpp @@ -33,9 +33,9 @@ namespace Socket { class SocketReader : public Raul::Thread { public: - SocketReader(World& world, - Interface& iface, - SharedPtr<Socket> sock); + SocketReader(World& world, + Interface& iface, + SPtr<Socket> sock); ~SocketReader(); @@ -58,12 +58,12 @@ private: const SerdNode* object_datatype, const SerdNode* object_lang); - World& _world; - Interface& _iface; - SerdEnv* _env; - SordInserter* _inserter; - SordNode* _msg_node; - SharedPtr<Socket> _socket; + World& _world; + Interface& _iface; + SerdEnv* _env; + SordInserter* _inserter; + SordNode* _msg_node; + SPtr<Socket> _socket; }; } // namespace Ingen diff --git a/src/socket/SocketServer.hpp b/src/socket/SocketServer.hpp index 6bbd792d..371bd1e0 100644 --- a/src/socket/SocketServer.hpp +++ b/src/socket/SocketServer.hpp @@ -29,9 +29,9 @@ namespace Socket { class SocketServer : public Server::EventWriter, public SocketReader { public: - SocketServer(World& world, - Server::Engine& engine, - SharedPtr<Socket> sock) + SocketServer(World& world, + Server::Engine& engine, + SPtr<Socket> sock) : Server::EventWriter(engine) , SocketReader(world, *this, sock) , _engine(engine) @@ -49,8 +49,8 @@ public: } private: - Server::Engine& _engine; - SharedPtr<SocketWriter> _writer; + Server::Engine& _engine; + SPtr<SocketWriter> _writer; }; } // namespace Ingen diff --git a/src/socket/SocketWriter.cpp b/src/socket/SocketWriter.cpp index d2652dec..fd099e30 100644 --- a/src/socket/SocketWriter.cpp +++ b/src/socket/SocketWriter.cpp @@ -40,10 +40,10 @@ socket_sink(const void* buf, size_t len, void* stream) return ret; } -SocketWriter::SocketWriter(URIMap& map, - URIs& uris, - const Raul::URI& uri, - SharedPtr<Socket> sock) +SocketWriter::SocketWriter(URIMap& map, + URIs& uris, + const Raul::URI& uri, + SPtr<Socket> sock) : AtomWriter(map, uris, *this) , _map(map) , _sratom(sratom_new(&map.urid_map_feature()->urid_map)) diff --git a/src/socket/SocketWriter.hpp b/src/socket/SocketWriter.hpp index d6ba5dd3..141b0ca5 100644 --- a/src/socket/SocketWriter.hpp +++ b/src/socket/SocketWriter.hpp @@ -19,11 +19,11 @@ #include <stdint.h> -#include "ingen/Interface.hpp" #include "ingen/AtomSink.hpp" #include "ingen/AtomWriter.hpp" +#include "ingen/Interface.hpp" +#include "ingen/types.hpp" #include "raul/URI.hpp" -#include "raul/SharedPtr.hpp" #include "sratom/sratom.h" #include "Socket.hpp" @@ -36,10 +36,10 @@ namespace Socket { class SocketWriter : public AtomWriter, public AtomSink { public: - SocketWriter(URIMap& map, - URIs& uris, - const Raul::URI& uri, - SharedPtr<Socket> sock); + SocketWriter(URIMap& map, + URIs& uris, + const Raul::URI& uri, + SPtr<Socket> sock); ~SocketWriter(); @@ -51,14 +51,14 @@ public: Raul::URI uri() const { return _uri; } protected: - URIMap& _map; - Sratom* _sratom; - SerdNode _base; - SerdURI _base_uri; - SerdEnv* _env; - SerdWriter* _writer; - Raul::URI _uri; - SharedPtr<Socket> _socket; + URIMap& _map; + Sratom* _sratom; + SerdNode _base; + SerdURI _base_uri; + SerdEnv* _env; + SerdWriter* _writer; + Raul::URI _uri; + SPtr<Socket> _socket; }; } // namespace Socket diff --git a/src/socket/ingen_socket_client.cpp b/src/socket/ingen_socket_client.cpp index e835adc8..88842dde 100644 --- a/src/socket/ingen_socket_client.cpp +++ b/src/socket/ingen_socket_client.cpp @@ -23,21 +23,21 @@ #include "Socket.hpp" #include "SocketClient.hpp" -static SharedPtr<Ingen::Interface> -new_socket_interface(Ingen::World* world, - const Raul::URI& uri, - SharedPtr<Ingen::Interface> respondee) +static Ingen::SPtr<Ingen::Interface> +new_socket_interface(Ingen::World* world, + const Raul::URI& uri, + Ingen::SPtr<Ingen::Interface> respondee) { - SharedPtr<Ingen::Socket::Socket> sock( + Ingen::SPtr<Ingen::Socket::Socket> sock( new Ingen::Socket::Socket(Ingen::Socket::Socket::type_from_uri(uri))); if (!sock->connect(uri)) { world->log().error(Raul::fmt("Failed to connect <%1%> (%2%)\n") % sock->uri() % strerror(errno)); - return SharedPtr<Ingen::Interface>(); + return Ingen::SPtr<Ingen::Interface>(); } Ingen::Socket::SocketClient* client = new Ingen::Socket::SocketClient( *world, uri, sock, respondee); - return SharedPtr<Ingen::Interface>(client); + return Ingen::SPtr<Ingen::Interface>(client); } struct IngenSocketClientModule : public Ingen::Module { diff --git a/src/socket/ingen_socket_server.cpp b/src/socket/ingen_socket_server.cpp index 45c587ce..37b05bae 100644 --- a/src/socket/ingen_socket_server.cpp +++ b/src/socket/ingen_socket_server.cpp @@ -26,11 +26,11 @@ using namespace Ingen; struct IngenSocketServerModule : public Ingen::Module { void load(Ingen::World* world) { - listener = SharedPtr<Ingen::Socket::SocketListener>( + listener = SPtr<Ingen::Socket::SocketListener>( new Ingen::Socket::SocketListener(*world)); } - SharedPtr<Ingen::Socket::SocketListener> listener; + SPtr<Ingen::Socket::SocketListener> listener; }; extern "C" { |