UDPSharedListener.h

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // $Id$
00004 //
00005 // Copyright 2008, 2009, 2010, 2011, 2012  Antonio Franchi and Paolo Stegagno    
00006 //
00007 // This file is part of MIP.
00008 //
00009 // MIP is free software: you can redistribute it and/or modify
00010 // it under the terms of the GNU General Public License as published by
00011 // the Free Software Foundation, either version 3 of the License, or
00012 // (at your option) any later version.
00013 //
00014 // MIP is distributed in the hope that it will be useful,
00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 // GNU General Public License for more details.
00018 //
00019 // You should have received a copy of the GNU General Public License
00020 // along with MIP. If not, see <http://www.gnu.org/licenses/>.
00021 //
00022 // Contact info: antonio.franchi@tuebingen.mpg.de stegagno@diag.uniroma1.it
00023 //
00024 // ----------------------------------------------------------------------------
00025 
00026 
00032 
00033 
00034 #ifndef __UDP_SHARED_LISTENER_INCLUDED_
00035 #define __UDP_SHARED_LISTENER_INCLUDED_
00036 
00037 #ifdef MIP_HOST_APPLE
00038 #include <applePatch.h>
00039 #endif
00040 
00041 #include <Time.h>
00042 #include <socketUDP.h>
00043 #include <SharedListener.h>
00044 
00045 //#define ROBOT_BASE_PORT 56000 //TODO take it from options
00046 
00047 using namespace std;
00048  
00050 /* @{ */
00051 
00052 namespace MipBaselib{
00053  
00057 class UDPSharedListener : public SharedListener {
00058  private:
00059   
00060   static bool _instanceFlag;
00061   static UDPSharedListener *_singleInst;
00062 
00063   ListenerUDP* _listener;
00064   
00065   UDPSharedListener();
00066   
00067   void _receive(string& message, string& address);
00068   
00069   template <class T> friend void* sharedListenerThread(void* p);
00070  
00071  public:
00072   
00074   ~UDPSharedListener();
00075   
00077   static UDPSharedListener* getInstance();
00078   
00080   static int getPort(int robotId);
00081   
00082 };
00083 
00084 
00085 
00086 
00087 /* @} */
00088  
00089 };// end namespace MipResources{
00090 
00091 
00092 #endif
00093 
00094 
00095 
00096 
00097 
00098 

Generated on Mon Feb 20 07:01:07 2017 for MIP by  doxygen 1.5.6