save loops

Dependencies:   mbed

Committer:
mbedalvaro
Date:
Tue Dec 02 04:39:15 2014 +0000
Revision:
0:df6fdd9b99f0
this new version of skinGames will have a function that stops scanning as the laser reaches the same position (i.e., loops) with a certain precision. It is for extracting contours for Takashita project. It can then save on a file or send on osc

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbedalvaro 0:df6fdd9b99f0 1
mbedalvaro 0:df6fdd9b99f0 2 /*
mbedalvaro 0:df6fdd9b99f0 3 Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com)
mbedalvaro 0:df6fdd9b99f0 4
mbedalvaro 0:df6fdd9b99f0 5 Permission is hereby granted, free of charge, to any person obtaining a copy
mbedalvaro 0:df6fdd9b99f0 6 of this software and associated documentation files (the "Software"), to deal
mbedalvaro 0:df6fdd9b99f0 7 in the Software without restriction, including without limitation the rights
mbedalvaro 0:df6fdd9b99f0 8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
mbedalvaro 0:df6fdd9b99f0 9 copies of the Software, and to permit persons to whom the Software is
mbedalvaro 0:df6fdd9b99f0 10 furnished to do so, subject to the following conditions:
mbedalvaro 0:df6fdd9b99f0 11
mbedalvaro 0:df6fdd9b99f0 12 The above copyright notice and this permission notice shall be included in
mbedalvaro 0:df6fdd9b99f0 13 all copies or substantial portions of the Software.
mbedalvaro 0:df6fdd9b99f0 14
mbedalvaro 0:df6fdd9b99f0 15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
mbedalvaro 0:df6fdd9b99f0 16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
mbedalvaro 0:df6fdd9b99f0 17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
mbedalvaro 0:df6fdd9b99f0 18 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
mbedalvaro 0:df6fdd9b99f0 19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
mbedalvaro 0:df6fdd9b99f0 20 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
mbedalvaro 0:df6fdd9b99f0 21 THE SOFTWARE.
mbedalvaro 0:df6fdd9b99f0 22 */
mbedalvaro 0:df6fdd9b99f0 23
mbedalvaro 0:df6fdd9b99f0 24 /** \file
mbedalvaro 0:df6fdd9b99f0 25 DNS Request header file
mbedalvaro 0:df6fdd9b99f0 26 */
mbedalvaro 0:df6fdd9b99f0 27
mbedalvaro 0:df6fdd9b99f0 28 #ifndef DNSREQUEST_H
mbedalvaro 0:df6fdd9b99f0 29 #define DNSREQUEST_H
mbedalvaro 0:df6fdd9b99f0 30
mbedalvaro 0:df6fdd9b99f0 31 #include "core/net.h"
mbedalvaro 0:df6fdd9b99f0 32 #include "core/ipaddr.h"
mbedalvaro 0:df6fdd9b99f0 33 #include "core/host.h"
mbedalvaro 0:df6fdd9b99f0 34 //Essentially it is a safe interface to NetDnsRequest
mbedalvaro 0:df6fdd9b99f0 35
mbedalvaro 0:df6fdd9b99f0 36 ///DNS Request error codes
mbedalvaro 0:df6fdd9b99f0 37 enum DNSRequestErr
mbedalvaro 0:df6fdd9b99f0 38 {
mbedalvaro 0:df6fdd9b99f0 39 __DNS_MIN = -0xFFFF,
mbedalvaro 0:df6fdd9b99f0 40 DNS_SETUP, ///<DNSRequest not properly configured
mbedalvaro 0:df6fdd9b99f0 41 DNS_IF, ///<Interface has problems, does not exist or is not initialized
mbedalvaro 0:df6fdd9b99f0 42 DNS_MEM, ///<Not enough mem
mbedalvaro 0:df6fdd9b99f0 43 DNS_INUSE, ///<Interface / Port is in use
mbedalvaro 0:df6fdd9b99f0 44 DNS_PROCESSING, ///<Request has not completed
mbedalvaro 0:df6fdd9b99f0 45 //...
mbedalvaro 0:df6fdd9b99f0 46 DNS_OK = 0 ///<Success
mbedalvaro 0:df6fdd9b99f0 47 };
mbedalvaro 0:df6fdd9b99f0 48
mbedalvaro 0:df6fdd9b99f0 49 ///DNS Request Result Events
mbedalvaro 0:df6fdd9b99f0 50 enum DNSReply
mbedalvaro 0:df6fdd9b99f0 51 {
mbedalvaro 0:df6fdd9b99f0 52 DNS_PRTCL,
mbedalvaro 0:df6fdd9b99f0 53 DNS_NOTFOUND, ///Hostname is unknown
mbedalvaro 0:df6fdd9b99f0 54 DNS_ERROR, ///Problem with DNS Service
mbedalvaro 0:df6fdd9b99f0 55 //...
mbedalvaro 0:df6fdd9b99f0 56 DNS_FOUND,
mbedalvaro 0:df6fdd9b99f0 57 };
mbedalvaro 0:df6fdd9b99f0 58
mbedalvaro 0:df6fdd9b99f0 59 class NetDnsRequest;
mbedalvaro 0:df6fdd9b99f0 60 enum NetDnsReply;
mbedalvaro 0:df6fdd9b99f0 61
mbedalvaro 0:df6fdd9b99f0 62 ///This is a simple DNS Request class
mbedalvaro 0:df6fdd9b99f0 63 /**
mbedalvaro 0:df6fdd9b99f0 64 This class exposes an API to deal with DNS Requests
mbedalvaro 0:df6fdd9b99f0 65 */
mbedalvaro 0:df6fdd9b99f0 66 class DNSRequest
mbedalvaro 0:df6fdd9b99f0 67 {
mbedalvaro 0:df6fdd9b99f0 68 public:
mbedalvaro 0:df6fdd9b99f0 69 ///Creates a new request
mbedalvaro 0:df6fdd9b99f0 70 DNSRequest();
mbedalvaro 0:df6fdd9b99f0 71
mbedalvaro 0:df6fdd9b99f0 72 ///Terminates and closes request
mbedalvaro 0:df6fdd9b99f0 73 ~DNSRequest();
mbedalvaro 0:df6fdd9b99f0 74
mbedalvaro 0:df6fdd9b99f0 75 ///Resolves an hostname
mbedalvaro 0:df6fdd9b99f0 76 /**
mbedalvaro 0:df6fdd9b99f0 77 @param hostname : hostname to resolve
mbedalvaro 0:df6fdd9b99f0 78 */
mbedalvaro 0:df6fdd9b99f0 79 DNSRequestErr resolve(const char* hostname);
mbedalvaro 0:df6fdd9b99f0 80
mbedalvaro 0:df6fdd9b99f0 81 ///Resolves an hostname
mbedalvaro 0:df6fdd9b99f0 82 /**
mbedalvaro 0:df6fdd9b99f0 83 @param host : hostname to resolve, the result will be stored in the IpAddr field of this object
mbedalvaro 0:df6fdd9b99f0 84 */
mbedalvaro 0:df6fdd9b99f0 85 DNSRequestErr resolve(Host* pHost);
mbedalvaro 0:df6fdd9b99f0 86
mbedalvaro 0:df6fdd9b99f0 87 ///Setups callback
mbedalvaro 0:df6fdd9b99f0 88 /**
mbedalvaro 0:df6fdd9b99f0 89 The callback function will be called on result.
mbedalvaro 0:df6fdd9b99f0 90 @param pMethod : callback function
mbedalvaro 0:df6fdd9b99f0 91 */
mbedalvaro 0:df6fdd9b99f0 92 void setOnReply( void (*pMethod)(DNSReply) );
mbedalvaro 0:df6fdd9b99f0 93
mbedalvaro 0:df6fdd9b99f0 94 class CDummy;
mbedalvaro 0:df6fdd9b99f0 95 ///Setups callback
mbedalvaro 0:df6fdd9b99f0 96 /**
mbedalvaro 0:df6fdd9b99f0 97 The callback function will be called on result.
mbedalvaro 0:df6fdd9b99f0 98 @param pItem : instance of class on which to execute the callback method
mbedalvaro 0:df6fdd9b99f0 99 @param pMethod : callback method
mbedalvaro 0:df6fdd9b99f0 100 */
mbedalvaro 0:df6fdd9b99f0 101 template<class T>
mbedalvaro 0:df6fdd9b99f0 102 void setOnReply( T* pItem, void (T::*pMethod)(DNSReply) )
mbedalvaro 0:df6fdd9b99f0 103 {
mbedalvaro 0:df6fdd9b99f0 104 m_pCbItem = (CDummy*) pItem;
mbedalvaro 0:df6fdd9b99f0 105 m_pCbMeth = (void (CDummy::*)(DNSReply)) pMethod;
mbedalvaro 0:df6fdd9b99f0 106 }
mbedalvaro 0:df6fdd9b99f0 107
mbedalvaro 0:df6fdd9b99f0 108 ///Gets IP address once it has been resolved
mbedalvaro 0:df6fdd9b99f0 109 /**
mbedalvaro 0:df6fdd9b99f0 110 @param pIp : pointer to an IpAddr instance in which to store the resolved IP address
mbedalvaro 0:df6fdd9b99f0 111 */
mbedalvaro 0:df6fdd9b99f0 112 DNSRequestErr getResult(IpAddr* pIp);
mbedalvaro 0:df6fdd9b99f0 113
mbedalvaro 0:df6fdd9b99f0 114 ///Closes DNS Request before completion
mbedalvaro 0:df6fdd9b99f0 115 DNSRequestErr close();
mbedalvaro 0:df6fdd9b99f0 116
mbedalvaro 0:df6fdd9b99f0 117 protected:
mbedalvaro 0:df6fdd9b99f0 118 void onNetDnsReply(NetDnsReply r);
mbedalvaro 0:df6fdd9b99f0 119 DNSRequestErr checkInst();
mbedalvaro 0:df6fdd9b99f0 120
mbedalvaro 0:df6fdd9b99f0 121 private:
mbedalvaro 0:df6fdd9b99f0 122 NetDnsRequest* m_pNetDnsRequest;
mbedalvaro 0:df6fdd9b99f0 123
mbedalvaro 0:df6fdd9b99f0 124 CDummy* m_pCbItem;
mbedalvaro 0:df6fdd9b99f0 125 void (CDummy::*m_pCbMeth)(DNSReply);
mbedalvaro 0:df6fdd9b99f0 126
mbedalvaro 0:df6fdd9b99f0 127 void (*m_pCb)(DNSReply);
mbedalvaro 0:df6fdd9b99f0 128
mbedalvaro 0:df6fdd9b99f0 129 };
mbedalvaro 0:df6fdd9b99f0 130
mbedalvaro 0:df6fdd9b99f0 131 #endif