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