GFC Logo GFC Title Logo
Reference Manual
Main Page  |  Namespace List  |  Alphabetical List  |  Class List  |  File List

GFC::G::MainLoop Class Reference

A C++ interface for the GMainLoop. More...

#include <gfc/glib/main.hh>

Inheritance diagram for GFC::G::MainLoop:

GFC::Object GFC::Trackable List of all members.

Public Member Functions

Constructors
Accessors
Methods

Static Public Member Functions


Detailed Description

A C++ interface for the GMainLoop.

It manages all the available sources of events for GLib and GTK+ applications. These events can come from any number of different types of sources such as file descriptors (plain files, pipes or sockets) and timeouts. New types of event sources can also be added using G::Source::attach().

To allow multiple independent sets of sources to be handled in different threads, each source is associated with a MainContext. A MainContext can only be running in a single thread, but sources can be added to it and removed from it from other threads.

Each event source is assigned a priority. The default priority, G::PRIORITY_DEFAULT, is 0. Values less than 0 denote higher priorities. Values greater than 0 denote lower priorities. Events from high priority sources are always processed before events from lower priority sources.

Idle functions can also be added, and assigned a priority. These will be run whenever no events with a higher priority are ready to be processed.

MainLoop represents a main event loop. After constructing a MainLoop and adding the initial event sources, run() is called. This continuously checks for new events from each of the event sources and dispatches them. Finally, the processing of an event from one of the sources leads to a call to quit() to exit the main loop, and run() returns.

It is possible to create new instances of MainLoop recursively. This is often used in GTK+ applications when showing modal dialog boxes. Note that event sources are associated with a particular MainContext, and will be checked and dispatched for all main loops associated with that MainContext.


Constructor & Destructor Documentation

GFC::G::MainLoop::MainLoop bool  is_running = false  ) 
 

Construct a new main loop object using the default MainContext.

Parameters:
is_running Set true to indicate that the loop is running.

The is_running argument is not very important since calling run() will set this to true anyway.

GFC::G::MainLoop::MainLoop MainContext context,
bool  is_running = false
 

Construct a new main loop object using the specified MainContext.

Parameters:
context A MainContext.
is_running Set true to indicate that the loop is running.

The is_running argument is not very important since calling run() will set this to true anyway.


Member Function Documentation

int GFC::G::MainLoop::depth  )  [static]
 

Get the main loop recursion level in the current thread.

Returns:
The main loop recursion level in the current thread.

When called from the toplevel, this method returns 0. When called from within a callback from G::MainContext::iteration() (or G::MainLoop::run(), etc.) it returns 1. When called from within a callback to a recursive call to G::MainContext::iteration(), it returns 2. And so forth.

Pointer<MainContext> GFC::G::MainLoop::get_context  )  const
 

Obtains the MainContext of loop.

Returns:
The MainContext of loop

bool GFC::G::MainLoop::is_running  )  const
 

Checks to see if the main loop is currently being run via run().

Returns:
true if the main loop is currently being run.

void GFC::G::MainLoop::run  ) 
 

Runs a main loop until quit() is called on the loop.

If this is called for the thread of the loop's MainContext, it will process events from the loop, otherwise it will simply wait.

virtual void GFC::G::MainLoop::unref  )  [virtual]
 

Decreases the reference count on a main loop object by one.

When the reference count becomes zero for a heap object delete is called. Remember, as with all GFC Objects you must call unref() on a dynamically allocated MainLoop, not delete. If you use a smart you don't need to call unref(), the smart pointer will do that for you. You don't need to call unref() on a loop allocated on the stack unless you first called ref().

Reimplemented from GFC::Object.


The documentation for this class was generated from the following file:
Generated on Tue Aug 24 00:04:57 2004 for GFC-Core by doxygen 1.3.8