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