From bb1c49dfa484db080938cff6f8f70167c9026a1c Mon Sep 17 00:00:00 2001 From: David Robillard Date: Tue, 24 Jul 2007 19:26:47 +0000 Subject: Consistently rename all C++ files .cpp/.hpp. Fix (some) inclusion guard names to not clash with other libs. git-svn-id: http://svn.drobilla.net/lad/ingen@613 a436a847-0d15-0410-975c-d299462d15a1 --- src/common/interface/ClientKey.hpp | 86 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 src/common/interface/ClientKey.hpp (limited to 'src/common/interface/ClientKey.hpp') diff --git a/src/common/interface/ClientKey.hpp b/src/common/interface/ClientKey.hpp new file mode 100644 index 00000000..b007a647 --- /dev/null +++ b/src/common/interface/ClientKey.hpp @@ -0,0 +1,86 @@ +/* This file is part of Ingen. + * Copyright (C) 2007 Dave Robillard + * + * Ingen is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) any later + * version. + * + * Ingen 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 General Public License for details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef CLIENTKEY_H +#define CLIENTKEY_H + +#include + +namespace Ingen { +namespace Shared { + + +/** Key for looking up clients. + * + * This might actually be a lookup key (as in OSC clients) or a direct handle + * of some kind (eg pointer) (for in-process or shared memory clients). + * + * This is shared code, nothing client or server code specific should be here. + */ +class ClientKey +{ +public: + /** A key to identify a particular ClientInterface. + * + * There are two different OSC key types because one is for server side, + * and one is for client side. A client can not identify it's own URL to + * the host (for NAT traversal, etc) so it can only know the outgoing UDP + * port it's sending on. The server however identifies that client by the + * full incoming URL. + */ + enum Type { + NIL, ///< A NULL key (represents no client) + OSC_URL, ///< An OSC URL (remote host/client) + OSC_PORT, ///< A local OSC port + DIRECT ///< A direct in-process function call client + }; + + ClientKey() + : _type(NIL), + _uri("") + {} + + ClientKey(Type type, const std::string& uri) + : _type(type) + , _uri(uri) + {} + + /*ClientKey(Type type, int port) + : _type(OSC_PORT) + , _port(port) + {}*/ + + inline bool + operator==(const ClientKey& key) const + { + return (_type == key._type && _uri == key._uri); + } + + inline Type type() const { return _type; } + inline const std::string& uri() const { return _uri; } + +protected: + Type _type; + const std::string _uri; ///< URL for OSC_URL, (string) port number for OSC_PORT +}; + + +} // namespace Shared +} // namespace Ingen + +#endif // CLIENTKEY_H + -- cgit v1.2.1