cstool/csapplicationframework.h
Go to the documentation of this file.00001 /* 00002 Copyright (C) 2003 by Odes B. Boatwright. 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License as published by the Free Software Foundation; either 00007 version 2 of the License, or (at your option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public 00015 License along with this library; if not, write to the Free 00016 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00017 */ 00018 00019 #ifndef __CS_CSAPPLICATIONFRAMEWORK_H__ 00020 #define __CS_CSAPPLICATIONFRAMEWORK_H__ 00021 00030 #include "csextern.h" 00031 #include "cstool/initapp.h" 00032 #include "iutil/event.h" 00033 #include "iutil/objreg.h" 00034 #include "ivaria/reporter.h" 00035 00110 class CS_CSTOOL_EXPORT csApplicationFramework : public csInitializer 00111 { 00112 private: 00124 static csApplicationFramework* m_Ptr; 00125 00132 static const char* m_FoundationStringName; 00133 00140 static char* m_ApplicationStringName; 00141 00142 protected: 00152 csApplicationFramework (); 00153 00167 static bool Initialize (int argc, char* argv[]); 00168 00178 static bool Start (); 00179 00188 static void End (); 00189 public: 00193 virtual ~csApplicationFramework (); 00194 00202 static void Quit (); 00203 00204 protected: 00208 static iObjectRegistry* object_reg; 00209 00224 virtual bool OnInitialize (int argc, char* argv[]) = 0; 00225 00237 virtual bool Application () = 0; 00238 00247 virtual void OnExit (); 00248 public: 00249 // Inline Helper Functions 00253 static iObjectRegistry* GetObjectRegistry () { return object_reg; }; 00254 00263 operator iObjectRegistry* () { return object_reg; } 00264 00268 bool Open () { return OpenApplication (object_reg); } 00269 00284 static void SetApplicationName (char *name) 00285 { 00286 m_ApplicationStringName = name; 00287 } 00288 00295 static const char* GetApplicationName () 00296 { 00297 return m_ApplicationStringName; 00298 } 00299 00305 static void Run () 00306 { 00307 csDefaultRunLoop (object_reg); 00308 } 00309 private: 00316 static bool ReportLibError (const char* description, ...) 00317 { 00318 va_list args; 00319 va_start (args, description); 00320 csReportV (object_reg, CS_REPORTER_SEVERITY_ERROR, 00321 m_FoundationStringName, 00322 description, args); 00323 va_end (args); 00324 return false; 00325 } 00326 00327 public: 00334 static bool ReportError (const char* description, ...) 00335 { 00336 va_list args; 00337 va_start (args, description); 00338 csReportV (object_reg, CS_REPORTER_SEVERITY_ERROR, 00339 m_ApplicationStringName, 00340 description, args); 00341 va_end (args); 00342 return false; 00343 } 00344 00351 static void ReportInfo (const char* description, ...) 00352 { 00353 va_list args; 00354 va_start (args, description); 00355 csReportV (object_reg, CS_REPORTER_SEVERITY_NOTIFY, 00356 m_ApplicationStringName, 00357 description, args); 00358 va_end (args); 00359 } 00360 00364 int Main (int argc, char* argv[]); 00365 }; 00366 00369 #endif //__CS_CSAPPLICATIONFRAMEWORK_H__
Generated for Crystal Space by doxygen 1.2.18