PCMHost.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_HOST_H__ 00029 # define __PCM_HOST_H__ 00030 00031 // 00032 // Inner includes 00033 // 00034 00035 # include "PCMPremeditations.h" 00036 00037 # include "PCMSingleton.h" 00038 00039 # include "PCMLogger.h" 00040 00041 # include "PCMException.h" 00042 00043 # include "PCMContainer.h" 00044 00045 # include "PCMXDisplay.h" 00046 00047 # include "PCMNode.h" 00048 00049 # include "PCMTimer.h" 00050 00051 # include "PCMSqVM.h" 00052 00053 // 00054 // Outer includes 00055 // 00056 00057 # include <string> 00058 00059 # include <pcapi.h> 00060 00061 // 00062 // Scripting bind includes (for Squirrel) 00063 // 00064 00065 # include <squirrel/squirrel.h> 00066 # include <squirrel/sqstdio.h> 00067 # include <squirrel/sqstdaux.h> 00068 # include <squirrel/sqplus.h> 00069 00070 namespace ParCompMark 00071 { 00072 00077 class Host:public Singleton < Host > 00078 { 00079 00080 // 00081 // Unit test class 00082 // 00083 # ifdef PARCOMPMARK_TEST 00084 friend class ParCompMarkTest::TestHost; 00085 # endif 00086 00087 // 00088 // Scripting binding (for Squirrel) 00089 // 00090 00092 00093 00101 public:static void squirrelGlue() 00102 { 00103 ::SqPlus::SQClassDef < Host > (_T("Host")).staticFunc(&Host::getInstance, 00104 _T("getInstance")).func(&Host::createNode, 00105 _T("createNode")); 00106 } 00107 00109 00110 // 00111 // Typedefs 00112 // 00113 00114 public: 00115 00117 typedef ParCompMark::Pointer < int, 00118 Mutex > IntPointer; 00119 00120 // 00121 // Class constants 00122 // 00123 00125 00126 00127 public: 00128 00134 static const std::string HOSTINITNUT; 00135 00137 00138 // 00139 // Variables 00140 // 00141 00143 00144 00145 protected: 00146 00152 bool mWait; 00153 00159 std::string mName; 00160 00166 SqVM::Pointer mSqVM; 00167 00173 std::string mLowLevelScript; 00174 00180 Container < XDisplay, Mutex >::Pointer mXDisplays; 00181 00187 Container < Node, Mutex >::Pointer mNodes; 00188 00194 bool mInitialized; 00195 00201 OutputNode::Pointer mOutputDocument; 00202 00208 PCid mSessionID; 00209 00215 NetClient *mNetClient; 00216 00222 IntPointer mEndProcessCount; 00223 00229 int mProcessCount; 00230 00236 int mID; 00237 00243 Real mMessageSendingTime; 00244 00246 00247 // 00248 // Constructors & destructor 00249 // 00250 00252 00253 00254 public: 00255 00261 Host(const std::string & name = "(unknown host)", NetClient * netClient = NULL); 00262 00266 virtual ~ Host(); 00267 00269 00270 // 00271 // Getters & setters 00272 // 00273 00275 00276 00277 public: 00278 00284 const bool & getWait() const; 00285 00291 const std::string & getName() const; 00292 00298 void setName(const std::string & name); 00299 00305 const std::string & getLowLevelScript() const; 00306 00312 void setLowLevelScript(const std::string & lowlevelscript); 00313 00319 Container < Node, Mutex >::Pointer & getNodes(); 00320 00326 const bool & getInitialized() const; 00327 00333 OutputNode::Pointer & getOutputDocument(); 00334 00340 const PCid & getSessionID() const; 00341 00347 NetClient *getNetClient() const; 00348 00354 void setNetClient(const NetClient * netclient); 00355 00361 const Host::IntPointer & getEndProcessCount() const; 00362 00368 void setEndProcessCount(const Host::IntPointer & endprocesscount); 00369 00375 const int &getProcessCount() const; 00376 00382 const int &getID() const; 00383 00389 void setID(const int &id); 00390 00396 const Real & getMessageSendingTime() const; 00397 00403 void setMessageSendingTime(const Real & messagesendingtime); 00404 00406 00407 // 00408 // Class methods 00409 // 00410 00412 00413 00414 public: 00415 00420 static Host *getInstance(); 00421 00423 00424 // 00425 // Methods 00426 // 00427 00429 00430 00431 public: 00432 00442 virtual XDisplay::Pointer openXDisplay(const std::string & displayName = ""); 00443 00448 virtual XDisplay::Pointer getFirstXDisplay(); 00449 00453 virtual void openXDisplays(); 00454 00458 virtual void closeXDisplays(); 00459 00463 virtual void initialize(); 00464 00468 virtual void finalize(); 00469 00475 virtual Node *createNode(const char *nodeName); 00476 00480 virtual void start(); 00481 00486 virtual u32 stop(); 00487 00491 virtual void collectData(); 00492 00497 virtual void setFrameID(const u32 & frameID); 00498 00500 00501 }; 00502 00503 // 00504 // Include header implementation 00505 // 00506 00507 # include "PCMHost_impl.h" 00508 00509 } 00510 00511 // Declare Host class (and its enums) for SqPlus binding 00513 DECLARE_INSTANCE_TYPE_NAME(ParCompMark::Host, Host); 00514 00515 #endif