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

MainLoop Class Reference

A typical main loop. More...

#include <MainLoop.h>

List of all members.

Public Member Functions

 MainLoop ()
 Constructor.
 ~MainLoop ()
 Destructor.
int Run ()
 This executes the main loop until Quit() is called.
void Quit ()
 Leaves the main loop.
void SetExitCode (int code)
 Sets the exit code.
int GetExitCode () const
 Returns the exit code.
virtual void OnInitialize ()=0
 (abstract) This method is called right before entering the main loop.
virtual void OnTerminate ()=0
 (abstract) This method is called right after leaving the main loop.
virtual void OnBeforeProcessing ()
 (abstract) This method is called before the events are processed (after waiting for events).
virtual void OnAfterProcessing ()
 (abstract) This method is called after the events are processed (before waiting for events).
IOInterfaceListGetIOInterfaceList () const
 Returns the IOInterfaceList.
EventInterfaceListGetEventInterfaceList () const
 Returns the EventInterfaceList.
void Report (const std::string &name, std::ostream &out, int ccindent=0) const
 Writes a report of this object to the given stream. This is mainly useful for debugging.

Protected Attributes

bool mQuit
 Set to true to leave the main loop.
int mExitCode
 The exit code.
IOInterfaceListmIOInterfaceList
 The IOInterface list.
EventInterfaceListmEventInterfaceList
 The EventInterface list.


Detailed Description

A typical main loop.

This abstract class implements a main loop for a typical application. It listens to all handles of the attached IOInterfaceList and waits for all timeouts of the attached EventInterfaceList.

To use this class, derive your main application class from it and overwrite the methods OnInitialize() and OnTerminate(). Your application should first add all EventInterface to the EventInterfaceList and all IOInterfaces to the IOInterfaceList. It may then call Run() to execute the main loop. Immediately before entering the main loop, OnInitialize() is called. Then, the program waits until

Any such event may force the main loop to quit by calling Quit(). The main loop then calls OnTerminate() and returns the exit code (set by SetExitCode).


The documentation for this class was generated from the following file:
Generated on Wed Jun 1 09:19:07 2005 for libmip by doxygen 1.3.8