Program the control the fischertechnik robo interface or intelligent interface via tcp socket or via a java gui.
LPC1768/core/netservice.h@1:2c9d412ad471, 2011-05-04 (annotated)
- Committer:
- networker
- Date:
- Wed May 04 15:42:13 2011 +0000
- Revision:
- 1:2c9d412ad471
- Parent:
- 0:7f26f0680202
first publication (mbed challenge submission)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
networker | 0:7f26f0680202 | 1 | |
networker | 0:7f26f0680202 | 2 | /* |
networker | 0:7f26f0680202 | 3 | Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com) |
networker | 0:7f26f0680202 | 4 | |
networker | 0:7f26f0680202 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy |
networker | 0:7f26f0680202 | 6 | of this software and associated documentation files (the "Software"), to deal |
networker | 0:7f26f0680202 | 7 | in the Software without restriction, including without limitation the rights |
networker | 0:7f26f0680202 | 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
networker | 0:7f26f0680202 | 9 | copies of the Software, and to permit persons to whom the Software is |
networker | 0:7f26f0680202 | 10 | furnished to do so, subject to the following conditions: |
networker | 0:7f26f0680202 | 11 | |
networker | 0:7f26f0680202 | 12 | The above copyright notice and this permission notice shall be included in |
networker | 0:7f26f0680202 | 13 | all copies or substantial portions of the Software. |
networker | 0:7f26f0680202 | 14 | |
networker | 0:7f26f0680202 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
networker | 0:7f26f0680202 | 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
networker | 0:7f26f0680202 | 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
networker | 0:7f26f0680202 | 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
networker | 0:7f26f0680202 | 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
networker | 0:7f26f0680202 | 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
networker | 0:7f26f0680202 | 21 | THE SOFTWARE. |
networker | 0:7f26f0680202 | 22 | */ |
networker | 0:7f26f0680202 | 23 | |
networker | 0:7f26f0680202 | 24 | /** |
networker | 0:7f26f0680202 | 25 | \file Net Service base class header file |
networker | 0:7f26f0680202 | 26 | */ |
networker | 0:7f26f0680202 | 27 | |
networker | 0:7f26f0680202 | 28 | #ifndef NETSERVICE_H |
networker | 0:7f26f0680202 | 29 | #define NETSERVICE_H |
networker | 0:7f26f0680202 | 30 | |
networker | 0:7f26f0680202 | 31 | #include <list> |
networker | 0:7f26f0680202 | 32 | using std::list; |
networker | 0:7f26f0680202 | 33 | |
networker | 0:7f26f0680202 | 34 | ///Net Service base class |
networker | 0:7f26f0680202 | 35 | /** |
networker | 0:7f26f0680202 | 36 | Each connection-oriented object can register as service (by inheriting this class), so that it is polled regularly. |
networker | 0:7f26f0680202 | 37 | It notifies the pool when the connection is terminated so that it can be destroyed. |
networker | 0:7f26f0680202 | 38 | */ |
networker | 0:7f26f0680202 | 39 | class NetService |
networker | 0:7f26f0680202 | 40 | { |
networker | 0:7f26f0680202 | 41 | public: |
networker | 0:7f26f0680202 | 42 | ///Instantiates a new service |
networker | 0:7f26f0680202 | 43 | /** |
networker | 0:7f26f0680202 | 44 | @param owned If true the object is owned by the pool and will be destroyed on closure. |
networker | 0:7f26f0680202 | 45 | */ |
networker | 0:7f26f0680202 | 46 | NetService(bool owned = true); //Is owned by the pool? |
networker | 0:7f26f0680202 | 47 | virtual ~NetService(); |
networker | 0:7f26f0680202 | 48 | |
networker | 0:7f26f0680202 | 49 | ///This method can be inherited so that it is called on each @a Net::poll() call. |
networker | 0:7f26f0680202 | 50 | virtual void poll(); |
networker | 0:7f26f0680202 | 51 | |
networker | 0:7f26f0680202 | 52 | static void servicesPoll(); //Poll all registered services & destroy closed ones |
networker | 0:7f26f0680202 | 53 | |
networker | 0:7f26f0680202 | 54 | protected: |
networker | 0:7f26f0680202 | 55 | ///This flags the service as to be destructed if owned by the pool. |
networker | 0:7f26f0680202 | 56 | void close(); |
networker | 0:7f26f0680202 | 57 | |
networker | 0:7f26f0680202 | 58 | private: |
networker | 0:7f26f0680202 | 59 | bool m_closed; |
networker | 0:7f26f0680202 | 60 | bool m_removed; |
networker | 0:7f26f0680202 | 61 | bool m_owned; |
networker | 0:7f26f0680202 | 62 | |
networker | 0:7f26f0680202 | 63 | static list<NetService*>& lpServices(); //Helper to prevent static initialization fiasco |
networker | 0:7f26f0680202 | 64 | |
networker | 0:7f26f0680202 | 65 | }; |
networker | 0:7f26f0680202 | 66 | |
networker | 0:7f26f0680202 | 67 | #endif |