CrystalSpace

Public API Reference

Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

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 
00285   static void SetApplicationName (char *name)
00286   {
00287     m_ApplicationStringName = name;
00288   }
00289 
00296   static const char* GetApplicationName ()
00297   {
00298     return m_ApplicationStringName;
00299   }
00300 
00306   static void Run ()
00307   {
00308     csDefaultRunLoop (object_reg);
00309   }
00310 private:
00317   static bool ReportLibError (const char* description, ...)
00318   {
00319     va_list args;
00320     va_start (args, description);
00321     csReportV (object_reg, CS_REPORTER_SEVERITY_ERROR,
00322       m_FoundationStringName,
00323       description, args);
00324     va_end (args);
00325     return false;
00326   }
00327 
00328 public:
00335   static bool ReportError (const char* description, ...)
00336   {
00337     va_list args;
00338     va_start (args, description);
00339     csReportV (object_reg, CS_REPORTER_SEVERITY_ERROR,
00340       m_ApplicationStringName,
00341       description, args);
00342     va_end (args);
00343     return false;
00344   }
00345 
00352   static void ReportWarning (const char* description, ...)
00353   {
00354     va_list args;
00355     va_start (args, description);
00356     csReportV (object_reg, CS_REPORTER_SEVERITY_WARNING,
00357       m_ApplicationStringName,
00358       description, args);
00359     va_end (args);
00360   }
00361   
00368   static void ReportInfo (const char* description, ...)
00369   {
00370     va_list args;
00371     va_start (args, description);
00372     csReportV (object_reg, CS_REPORTER_SEVERITY_NOTIFY,
00373       m_ApplicationStringName,
00374       description, args);
00375     va_end (args);
00376   }
00377   
00381   int Main (int argc, char* argv[]);
00382 };
00383 
00386 #endif //__CS_CSAPPLICATIONFRAMEWORK_H__

Generated for Crystal Space by doxygen 1.3.9.1