Dependents: SimpleLCDClock readCard2Twitter_http AnalogClock_StepperMotor_NTP ServoCamV1
if/net/netservice.h@0:3717b703f76d, 2010-05-24 (annotated)
- Committer:
- donatien
- Date:
- Mon May 24 10:23:42 2010 +0000
- Revision:
- 0:3717b703f76d
- Child:
- 1:e52ec2a24c6a
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
donatien | 0:3717b703f76d | 1 | #ifndef NETSERVICE_H |
donatien | 0:3717b703f76d | 2 | #define NETSERVICE_H |
donatien | 0:3717b703f76d | 3 | |
donatien | 0:3717b703f76d | 4 | //class NetDnsRequest; |
donatien | 0:3717b703f76d | 5 | //#include "net.h" |
donatien | 0:3717b703f76d | 6 | |
donatien | 0:3717b703f76d | 7 | //Each connection-oriented object can register as service (by inheriting this class), so that it is polled regularly |
donatien | 0:3717b703f76d | 8 | //It notifies the pool when the connection is terminated so that it can be destroyed |
donatien | 0:3717b703f76d | 9 | |
donatien | 0:3717b703f76d | 10 | #include <list> |
donatien | 0:3717b703f76d | 11 | using std::list; |
donatien | 0:3717b703f76d | 12 | |
donatien | 0:3717b703f76d | 13 | class NetService |
donatien | 0:3717b703f76d | 14 | { |
donatien | 0:3717b703f76d | 15 | public: |
donatien | 0:3717b703f76d | 16 | NetService(bool owned = true); //Is owned by the pool? |
donatien | 0:3717b703f76d | 17 | virtual ~NetService(); |
donatien | 0:3717b703f76d | 18 | |
donatien | 0:3717b703f76d | 19 | virtual void poll(); |
donatien | 0:3717b703f76d | 20 | |
donatien | 0:3717b703f76d | 21 | static void servicesPoll(); //Poll all registered services & destroy closed ones |
donatien | 0:3717b703f76d | 22 | |
donatien | 0:3717b703f76d | 23 | protected: |
donatien | 0:3717b703f76d | 24 | void close(); |
donatien | 0:3717b703f76d | 25 | |
donatien | 0:3717b703f76d | 26 | private: |
donatien | 0:3717b703f76d | 27 | bool m_closed; |
donatien | 0:3717b703f76d | 28 | bool m_removed; |
donatien | 0:3717b703f76d | 29 | bool m_owned; |
donatien | 0:3717b703f76d | 30 | |
donatien | 0:3717b703f76d | 31 | static list<NetService*>& lpServices(); //Helper to prevent static initialization fiasco |
donatien | 0:3717b703f76d | 32 | |
donatien | 0:3717b703f76d | 33 | }; |
donatien | 0:3717b703f76d | 34 | |
donatien | 0:3717b703f76d | 35 | #endif |