diff options
author | David Robillard <d@drobilla.net> | 2006-06-09 15:07:31 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2006-06-09 15:07:31 +0000 |
commit | acbda29f838280ba98cf9e9e539e9d8a6e8fc6ad (patch) | |
tree | e31b37a2456e6d1e564c9a7146c88be259d338b0 /src/common/interface/ClientKey.h | |
download | ingen-acbda29f838280ba98cf9e9e539e9d8a6e8fc6ad.tar.gz ingen-acbda29f838280ba98cf9e9e539e9d8a6e8fc6ad.tar.bz2 ingen-acbda29f838280ba98cf9e9e539e9d8a6e8fc6ad.zip |
Added Om aka Graph aka god knows what
git-svn-id: http://svn.drobilla.net/lad/grauph@9 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/common/interface/ClientKey.h')
-rw-r--r-- | src/common/interface/ClientKey.h | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/src/common/interface/ClientKey.h b/src/common/interface/ClientKey.h new file mode 100644 index 00000000..eb580a2d --- /dev/null +++ b/src/common/interface/ClientKey.h @@ -0,0 +1,84 @@ +/* This file is part of Om. Copyright (C) 2006 Dave Robillard. + * + * Om 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. + * + * Om 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., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef CLIENTKEY_H +#define CLIENTKEY_H + +#include <string> + +namespace Om { +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 + }; + + ClientKey() + : _type(NIL), + _uri("") + {} + + ClientKey(Type type, const std::string& uri) + : _type(OSC_URL) + , _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 Om + +#endif // CLIENTKEY_H + |