Measure system

Dependencies:   EthernetNetIf mbed RF12B

Committer:
benecsj
Date:
Thu Mar 10 19:56:45 2011 +0000
Revision:
1:b26ab2467b1a

        

Who changed what in which revision?

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