Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef AbstractFrameLoaderH
00033 #define AbstractFrameLoaderH
00034
00035 #include <zeusbase/System/ZObject.h>
00036 #include <zeusbase/System/PropertyFile.h>
00037 #include <zeusbase/System/Directory.h>
00038 #include <zeusbase/System/Interfaces/IXObject.hpp>
00039
00040
00047
00048 #define MStartZeusFramework(loggerclass, frameclass, retval) \
00049 TAutoPtr<ILogger> ptrStartLogger = new loggerclass();\
00050 TLoggerManager::getInstance().setRootLogger(ptrStartLogger);\
00051 TString strSingName = L"ILogger";\
00052 TSingletonManager::getInstance().addSingleton(strSingName, *ptrStartLogger);\
00053 \
00054 try\
00055 {\
00056 TAutoPtr<frameclass> ptrLoader = new frameclass(argc, argv);\
00057 ptrLoader->initialize();\
00058 if (ptrLoader->canStartup())\
00059 {\
00060 RootLogger.printfln(LOGMODE_INFO, "Start up zeus framework...");\
00061 RootLogger.indent();\
00062 ptrLoader->startup();\
00063 RootLogger.unindent();\
00064 RootLogger.printfln(LOGMODE_INFO, "done");\
00065 \
00066 retval = ptrLoader->run();\
00067 \
00068 RootLogger.printfln(LOGMODE_INFO, "Shutdown framework...");\
00069 RootLogger.indent();\
00070 ptrLoader->shutdown();\
00071 RootLogger.unindent();\
00072 RootLogger.printfln(LOGMODE_INFO, "...done");\
00073 }\
00074 }\
00075 catch(...)\
00076 {\
00077 RootLogger.unindent();\
00078 RootLogger.printfln(LOGMODE_INFO, "Exception received. Killing all life :-(");\
00079 }\
00080
00081
00082
00083 BEGIN_NAMESPACE_Zeus
00084
00085 class TArgumentParser;
00086
00087
00090
00091 zeusbase_class TAbstractFrameLoader : public TZObject
00092 {
00093 public:
00094 TAbstractFrameLoader(const TString& strBaseName);
00095 TAbstractFrameLoader(const TString& strBaseName,
00096 int iArgc, char* apArgs[]);
00097 TAbstractFrameLoader(const TString& strBaseName,
00098 int iArgc, wchar_t* awcArgs[]);
00099
00100 virtual void initialize();
00101 virtual bool canStartup();
00102 virtual Retval startup();
00103 virtual Retval shutdown();
00104 virtual Int run()=0;
00105
00106 Retval getRootObject(IXObject*& rpRoot);
00107
00108 protected:
00109 virtual ~TAbstractFrameLoader();
00110 virtual Retval buildXObjectTree(TString strFileName = L"");
00111 void registerClasses();
00112
00113
00114 virtual Retval initProperties();
00115 virtual Retval initSecurity();
00116 virtual Retval initSystemLibraries();
00117 virtual void initSystem();
00118
00119 virtual void onInitPropertiesFailed() {}
00120 virtual void onInitSecurityFailed() {}
00121 virtual void onInitSystemLibrariesFailed() {}
00122
00124 TDirectory m_WorkingDir;
00125
00126 TAutoPtr<TDirectory> m_ptrBaseDirectory;
00128 TFile m_ModuleFile;
00130 TAutoPtr<IXObject> m_ptrRootObject;
00132 TAutoPtr<TPropertyFile> m_ptrSystemSettings;
00134 TString m_strPropertyFileName;
00136 TString m_strConfigFileName;
00138 TArgumentParser& m_rArgumentParser;
00140 Uint m_uiSecurityHandle;
00141
00142 private:
00144 bool m_bInitialized;
00146 bool m_bStartedUp;
00148 TString m_strBaseName;
00149
00150 void create();
00151 void releaseXRootObject();
00152 };
00153
00154
00155
00158
00159 inline bool TAbstractFrameLoader::canStartup()
00160 {
00161 return true;
00162 }
00163
00164 END_NAMESPACE_Zeus
00165
00166 #endif