00001 // Copyright (c) 2004, Thomas Lochmatter, thl@lothosoft.ch 00002 00003 #ifndef classMainLoop 00004 #define classMainLoop 00005 00006 #include "IOInterfaceList.h" 00007 #include "EventInterfaceList.h" 00008 00010 00019 class MainLoop { 00020 00021 protected: 00023 bool mQuit; 00025 int mExitCode; 00026 00028 IOInterfaceList *mIOInterfaceList; 00030 EventInterfaceList *mEventInterfaceList; 00031 00032 public: 00034 MainLoop(); 00036 ~MainLoop(); 00037 00039 int Run(); 00041 void Quit(); 00043 void SetExitCode(int code) {mExitCode=code;} 00045 int GetExitCode() const {return mExitCode;} 00046 00048 virtual void OnInitialize() = 0; 00050 virtual void OnTerminate() = 0; 00052 virtual void OnBeforeProcessing() {} 00054 virtual void OnAfterProcessing() {} 00055 00057 IOInterfaceList *GetIOInterfaceList() const {return mIOInterfaceList;} 00059 EventInterfaceList *GetEventInterfaceList() const {return mEventInterfaceList;} 00060 00062 void Report(const std::string &name, std::ostream &out, int ccindent=0) const; 00063 00064 }; 00065 00066 #endif