NetServices Stack source

Dependents:   HelloWorld ServoInterfaceBoardExample1 4180_Lab4

Committer:
donatien
Date:
Thu Aug 05 14:32:43 2010 +0000
Revision:
9:c79fa4034f5b
Child:
10:d098e9192450

        

Who changed what in which revision?

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