Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

Application.h

Go to the documentation of this file.
00001 /*********************************************************************** 00002 00003 ColorBox2: Application.h 00004 (c) 2004 by Martin Decky 00005 00006 Distributed under the terms of Lesser General Public Licence, see 00007 COPYING. 00008 00009 0.2 20th June 2003 basic structure 00010 0.3 20th August 2004 rewrite 00011 00012 ***********************************************************************/ 00013 00014 00015 #ifndef __CB2__APPLICATION_H__ 00016 #define __CB2__APPLICATION_H__ 00017 00018 00019 #include <cb2/utils.h> 00020 #include <cb2/Template.h> 00021 #include <cb2/Widgets.h> 00022 #include <iostream> 00023 00024 00025 #define CB2_IMPLEMENT_APP_SER(AppType, SerType) \ 00026 int main(int argc, char * argv[]) { \ 00027 try { \ 00028 SerType serializer(argc, argv, std::cin); \ 00029 AppType app; \ 00030 } catch (Exception & e) { \ 00031 CB2::Application::AppError("Application exception", e.What()); \ 00032 } catch (...) { \ 00033 CB2::Application::AppError("Fatal application exception"); \ 00034 } \ 00035 \ 00036 return 0; \ 00037 } 00038 00039 #define CB2_IMPLEMENT_APP(AppType) CB2_IMPLEMENT_APP_SER(AppType, Serializer) 00040 00041 00042 #define CB2_DECLARE_SERIALIZEDCLASS(ClassType) \ 00043 virtual const char * GetSerialName(); 00044 00045 00046 #define CB2_IMPLEMENT_SERIALIZEDCLASS(ClassType) \ 00047 const char * ClassType::GetSerialName() { \ 00048 return #ClassType; \ 00049 } 00050 00051 00052 namespace CB2 { 00053 00054 00062 class Serializer : public Class { 00063 public: 00064 Serializer(int argc, char * argv[], std::istream & input); 00065 virtual ~Serializer(); 00066 00067 virtual void BeginInstance(const char * serialname, const char * instance); 00068 virtual const Serializer & operator<<(const String & data); 00069 virtual const Serializer & operator>>(String & data); 00070 virtual void EndInstance(); 00071 00072 virtual String Render(); 00073 00074 static Serializer & GetSerializer(); 00075 00076 MapList PostVars; 00077 MapList GetVars; 00078 00079 protected: 00080 00081 virtual void load(int argc, char * argv[], std::istream & input); 00082 00083 }; 00084 00085 00101 class SerializedClass : public Class { 00102 public: 00103 SerializedClass(const char * instance); 00104 virtual ~SerializedClass(); 00105 00106 virtual bool Write(Serializer * storage) = 0; 00107 virtual bool Read(Serializer * storage) = 0; 00108 virtual const char * GetSerialName() = 0; 00109 00110 private: 00111 00112 const char * inst; 00113 }; 00114 00115 00128 class Application : public Class { 00129 public: 00130 Application(); 00131 ~Application(); 00132 00133 void SetTemplate(Template * temp, const String & anc); 00134 void SetMimeType(const String & mtype); 00135 00136 Template * Register(Widget * child, String & anc); 00137 00138 static void AppError(const String & error, const String & desc = ""); 00139 00140 private: 00141 Widget * member; 00142 Template * templ; 00143 String anchor; 00144 String mime; 00145 }; 00146 00147 00148 } 00149 00150 00151 #endif

Generated on Thu Sep 16 23:26:49 2004 for ColorBox2 by doxygen 1.3.7