PCMNetwork.h
Go to the documentation of this file.00001 00002 // 00003 // This source file is a part of ParCompMark 00004 // Parallel Compositing Benchmark Framework 00005 // 00006 // for latest info see http://parcompmark.sourceforge.net 00007 00008 // 00009 // Copyright (C) 2006 IT2 ParCompMark Dev. Team 00010 // 00011 // This program is free software; you can redistribute it and/or 00012 // modify it under the terms of the GNU General Public License 00013 // as published by the Free Software Foundation; either version 2 00014 // of the License, or (at your option) any later version. 00015 // 00016 // This program is distributed in the hope that it will be useful, 00017 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 // GNU General Public License for more details. 00020 // 00021 // You should have received a copy of the GNU General Public License 00022 // along with this program; if not, write to the Free Software 00023 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00024 00027 00028 #ifndef __PCM_NETWORK_H__ 00029 # define __PCM_NETWORK_H__ 00030 00031 // 00032 // Inner includes 00033 // 00034 00035 # include "PCMPremeditations.h" 00036 00037 # include "PCMThread.h" 00038 00039 # include "PCMPointer.h" 00040 00041 # include "PCMException.h" 00042 00043 # include "PCMLogger.h" 00044 00045 # include "PCMContainer.h" 00046 00047 # include "PCMFileSystemManager.h" 00048 00049 // 00050 // Outer includes 00051 // 00052 00053 # include <sys/socket.h> 00054 00055 # include <arpa/inet.h> 00056 00057 # include <unistd.h> 00058 00059 # include <linux/if.h> 00060 00061 # include <sys/ioctl.h> 00062 00063 namespace ParCompMark 00064 { 00065 00070 class Network:public Thread 00071 { 00072 00073 // 00074 // Unit test class 00075 // 00076 # ifdef PARCOMPMARK_TEST 00077 friend class ParCompMarkTest::TestNetwork; 00078 # endif 00079 00080 // 00081 // Typedefs 00082 // 00083 00084 public: 00085 00087 typedef Pointer < Network, 00088 DummyLock > Pointer; 00089 00091 typedef struct IfConf 00092 00093 { 00095 std::string IP; 00097 std::string Netmask; 00099 std::string BroadcastIP; 00100 typedef ParCompMark::Pointer < IfConf, 00101 DummyLock > Pointer; 00102 } IfConf; 00103 00104 // 00105 // Class variables 00106 // 00107 00109 00110 00111 protected: 00112 00118 static Container < Network::IfConf, 00119 DummyLock >::Pointer mIfConfs; 00120 00126 static unsigned short mCommunicationPort; 00127 00133 static unsigned short mBroadcastPort; 00134 00136 00137 // 00138 // Variables 00139 // 00140 00142 00143 00144 protected: 00145 00151 bool mInitialized; 00152 00158 int mStreamSocket; 00159 00165 int mBroadcastSocket; 00166 00172 std::string mOwnIP; 00173 00175 00176 // 00177 // Constructors & destructor 00178 // 00179 00181 00182 00183 public: 00184 00189 Network(const std::string & name); 00190 00194 virtual ~ Network(); 00195 00197 00198 // 00199 // Getters & setters 00200 // 00201 00203 00204 00205 public: 00206 00212 static Container < Network::IfConf, 00213 DummyLock >::Pointer & getIfConfs(); 00214 00220 const bool & getInitialized() const; 00221 00227 static const unsigned short &getCommunicationPort(); 00228 00234 static void setCommunicationPort(const unsigned short &communicationport); 00235 00241 static const unsigned short &getBroadcastPort(); 00242 00248 static void setBroadcastPort(const unsigned short &broadcastport); 00249 00255 const int &getStreamSocket() const; 00256 00262 void setStreamSocket(const int &streamsocket); 00263 00269 const int &getBroadcastSocket() const; 00270 00276 const std::string & getOwnIP() const; 00277 00279 00280 // 00281 // Class methods 00282 // 00283 00285 00286 00287 public: 00288 00292 static void getIP(); 00293 00298 static std::string getHostName(); 00299 00301 00302 }; 00303 00304 // 00305 // Include header implementation 00306 // 00307 00308 # include "PCMNetwork_impl.h" 00309 00310 } 00311 00312 #endif