Laser Sensing Display for UI interfaces in the real world

Dependencies:   mbed

Fork of skinGames_forktest by Alvaro Cassinelli

Committer:
mbedalvaro
Date:
Thu Apr 17 08:04:14 2014 +0000
Revision:
47:199042980678
Parent:
31:5f039cbddee8
publishing for sharing with Ken Iwasaki

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbedalvaro 31:5f039cbddee8 1
mbedalvaro 31:5f039cbddee8 2 /*
mbedalvaro 31:5f039cbddee8 3 Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com)
mbedalvaro 31:5f039cbddee8 4
mbedalvaro 31:5f039cbddee8 5 Permission is hereby granted, free of charge, to any person obtaining a copy
mbedalvaro 31:5f039cbddee8 6 of this software and associated documentation files (the "Software"), to deal
mbedalvaro 31:5f039cbddee8 7 in the Software without restriction, including without limitation the rights
mbedalvaro 31:5f039cbddee8 8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
mbedalvaro 31:5f039cbddee8 9 copies of the Software, and to permit persons to whom the Software is
mbedalvaro 31:5f039cbddee8 10 furnished to do so, subject to the following conditions:
mbedalvaro 31:5f039cbddee8 11
mbedalvaro 31:5f039cbddee8 12 The above copyright notice and this permission notice shall be included in
mbedalvaro 31:5f039cbddee8 13 all copies or substantial portions of the Software.
mbedalvaro 31:5f039cbddee8 14
mbedalvaro 31:5f039cbddee8 15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
mbedalvaro 31:5f039cbddee8 16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
mbedalvaro 31:5f039cbddee8 17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
mbedalvaro 31:5f039cbddee8 18 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
mbedalvaro 31:5f039cbddee8 19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
mbedalvaro 31:5f039cbddee8 20 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
mbedalvaro 31:5f039cbddee8 21 THE SOFTWARE.
mbedalvaro 31:5f039cbddee8 22 */
mbedalvaro 31:5f039cbddee8 23
mbedalvaro 31:5f039cbddee8 24 #ifndef HOST_H
mbedalvaro 31:5f039cbddee8 25 #define HOST_H
mbedalvaro 31:5f039cbddee8 26
mbedalvaro 31:5f039cbddee8 27 #include "ipaddr.h"
mbedalvaro 31:5f039cbddee8 28 #include <string.h>
mbedalvaro 31:5f039cbddee8 29
mbedalvaro 31:5f039cbddee8 30 ///Host information container
mbedalvaro 31:5f039cbddee8 31 /**
mbedalvaro 31:5f039cbddee8 32 This class is a container for data relative to a connection:
mbedalvaro 31:5f039cbddee8 33 - IP Address
mbedalvaro 31:5f039cbddee8 34 - Port number
mbedalvaro 31:5f039cbddee8 35 - Host Name
mbedalvaro 31:5f039cbddee8 36 */
mbedalvaro 31:5f039cbddee8 37 class Host
mbedalvaro 31:5f039cbddee8 38 {
mbedalvaro 31:5f039cbddee8 39 public:
mbedalvaro 31:5f039cbddee8 40 ///Initiliazes host with null values
mbedalvaro 31:5f039cbddee8 41 Host() : m_ip(0,0,0,0), m_port(0), m_name(NULL)
mbedalvaro 31:5f039cbddee8 42 {
mbedalvaro 31:5f039cbddee8 43
mbedalvaro 31:5f039cbddee8 44 }
mbedalvaro 31:5f039cbddee8 45
mbedalvaro 31:5f039cbddee8 46 ///Initializes host
mbedalvaro 31:5f039cbddee8 47 Host(const IpAddr& ip, const int& port, const char* name="" ) : m_ip(ip), m_port(port), m_name(NULL)
mbedalvaro 31:5f039cbddee8 48 {
mbedalvaro 31:5f039cbddee8 49 setName(name);
mbedalvaro 31:5f039cbddee8 50 }
mbedalvaro 31:5f039cbddee8 51
mbedalvaro 31:5f039cbddee8 52 ~Host()
mbedalvaro 31:5f039cbddee8 53 {
mbedalvaro 31:5f039cbddee8 54 if(m_name)
mbedalvaro 31:5f039cbddee8 55 {
mbedalvaro 31:5f039cbddee8 56 delete[] m_name;
mbedalvaro 31:5f039cbddee8 57 }
mbedalvaro 31:5f039cbddee8 58 }
mbedalvaro 31:5f039cbddee8 59
mbedalvaro 31:5f039cbddee8 60 ///Returns IP address
mbedalvaro 31:5f039cbddee8 61 const IpAddr& getIp() const
mbedalvaro 31:5f039cbddee8 62 {
mbedalvaro 31:5f039cbddee8 63 return m_ip;
mbedalvaro 31:5f039cbddee8 64 }
mbedalvaro 31:5f039cbddee8 65
mbedalvaro 31:5f039cbddee8 66 ///Returns port number
mbedalvaro 31:5f039cbddee8 67 const int& getPort() const
mbedalvaro 31:5f039cbddee8 68 {
mbedalvaro 31:5f039cbddee8 69 return m_port;
mbedalvaro 31:5f039cbddee8 70 }
mbedalvaro 31:5f039cbddee8 71
mbedalvaro 31:5f039cbddee8 72 ///Returns host name
mbedalvaro 31:5f039cbddee8 73 const char* getName() const
mbedalvaro 31:5f039cbddee8 74 {
mbedalvaro 31:5f039cbddee8 75 return m_name;
mbedalvaro 31:5f039cbddee8 76 }
mbedalvaro 31:5f039cbddee8 77
mbedalvaro 31:5f039cbddee8 78 ///Sets IP address
mbedalvaro 31:5f039cbddee8 79 void setIp(const IpAddr& ip)
mbedalvaro 31:5f039cbddee8 80 {
mbedalvaro 31:5f039cbddee8 81 m_ip = ip;
mbedalvaro 31:5f039cbddee8 82 }
mbedalvaro 31:5f039cbddee8 83
mbedalvaro 31:5f039cbddee8 84 ///Sets port number
mbedalvaro 31:5f039cbddee8 85 void setPort(int port)
mbedalvaro 31:5f039cbddee8 86 {
mbedalvaro 31:5f039cbddee8 87 m_port = port;
mbedalvaro 31:5f039cbddee8 88 }
mbedalvaro 31:5f039cbddee8 89
mbedalvaro 31:5f039cbddee8 90 ///Sets host name
mbedalvaro 31:5f039cbddee8 91 void setName(const char* name)
mbedalvaro 31:5f039cbddee8 92 {
mbedalvaro 31:5f039cbddee8 93 if(m_name)
mbedalvaro 31:5f039cbddee8 94 delete[] m_name;
mbedalvaro 31:5f039cbddee8 95 int len = strlen(name);
mbedalvaro 31:5f039cbddee8 96 if(len)
mbedalvaro 31:5f039cbddee8 97 {
mbedalvaro 31:5f039cbddee8 98 m_name = new char[len+1];
mbedalvaro 31:5f039cbddee8 99 strcpy(m_name, name);
mbedalvaro 31:5f039cbddee8 100 }
mbedalvaro 31:5f039cbddee8 101 }
mbedalvaro 31:5f039cbddee8 102
mbedalvaro 31:5f039cbddee8 103 private:
mbedalvaro 31:5f039cbddee8 104 IpAddr m_ip;
mbedalvaro 31:5f039cbddee8 105 int m_port;
mbedalvaro 31:5f039cbddee8 106 char* m_name;
mbedalvaro 31:5f039cbddee8 107 };
mbedalvaro 31:5f039cbddee8 108
mbedalvaro 31:5f039cbddee8 109 #endif