Demo Application for the Celeritous Breakout Board

Dependencies:   mbed

Committer:
celeritous
Date:
Fri May 18 03:55:10 2012 +0000
Revision:
0:1a3da73fe36a
Celeritous_BreakoutBoardDemo

Who changed what in which revision?

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