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

CXtEventLoop Class Reference

#include <CXtEventLoop.h>

Inheritance diagram for CXtEventLoop:

CEventLoop List of all members.

Public Member Functions

 CXtEventLoop ()
virtual ~CXtEventLoop ()
Widget getTopLevel () const
 Returns the m_TopLevel member data.
XtAppContext getAppContext () const
 Returns the application context.
XrmOptionDescRec * getOptionTable () const
 Returs a pointer to the option table.
char ** getFallbackResources () const
 Returns a pointer to the fallback resource list.
 STD (string) getApplicationClass() const
 Returns the application class name.
unsigned int getOptionCount () const
 Returns the number of options in the Option list.
void exit ()

Protected Member Functions

void setTopLevel (const Widget am_TopLevel)
 Set the value of the top level widget:.
void setAppContext (XtAppContext newContext)
 Sets a new value for the application context.
void setOptionTable (XrmOptionDescRec *pTable)
 Set a new option table pointer.
void setFallbackResources (char **resources)
void setApplicationClass (const STD(string)&ClassName)
 Set a new application class string.
void setOptionCount (unsigned int nCount)
 Set the number of items in the option list.
virtual Widget InitializeApplication (int &argc, char **argv)
virtual void SetupApplicationResources (Widget TopLevel)
virtual void SetupWidgetTree (Widget TopLevel)

Private Member Functions

 STD (string) m_sClass
 Application class.
virtual int operator() (int argc, char **argv)
 CXtEventLoop (const CXtEventLoop &aCXtEventLoop)
CXtEventLoopoperator= (const CXtEventLoop &aCXtEventLoop)
int operator== (const CXtEventLoop &aCXtEventLoop) const

Private Attributes

Widget m_TopLevel
XtAppContext m_AppContext
 Xt application context.
XrmOptionDescRec * m_pOptionTable
 Command line option table (optional).
unsigned int m_nOptionCount
 Number of options.
char ** m_ppcFallbackResources
 Application fall back resourcelist.
bool m_fExit
 TRUE when supposed to exit.

Detailed Description

Encapsulates an occurance of an Xt event loop. The main loop synchronizes the event loop thread with the application each pass through the Xt event loop e.g. the event loop looks like:

while(1) { XtGetEvent() LockMutex() XtDispatchEvent(); UnlockMutex(); yield(); // Let someone else run. }

This implies that work procedures and timer procs are also synchonrized to the application. Note that this synchronization can be costly if there are work procedures continuously active.

Definition at line 330 of file CXtEventLoop.h.


Constructor & Destructor Documentation

CXtEventLoop::CXtEventLoop  ) 
 

The constructor is essentially a no-op. The base class already is checking for duplication of the singleton. We'll just let the exception pass up and through us satisfying the condition that if an exception fires we prevent full construction.

The real work of initializing the Xt application is done in operator(), when we have a thread context of our own.

Definition at line 319 of file CXtEventLoop.cpp.

References FALSE.

CXtEventLoop::~CXtEventLoop  )  [virtual]
 

In theory the application specific code will destroy all application data and objects including the Xt application context and therefore this function is also a no-op.

Subclasses should either replace/supplement this or tear down the Xt stuff prior to destruction.

Definition at line 339 of file CXtEventLoop.cpp.

CXtEventLoop::CXtEventLoop const CXtEventLoop aCXtEventLoop  )  [private]
 

Copy construction, assignment and equality comparison are invalid and hence declared privatge and not implemented.


Member Function Documentation

void CXtEventLoop::exit  )  [inline]
 

Definition at line 429 of file CXtEventLoop.h.

References m_fExit.

XtAppContext CXtEventLoop::getAppContext  )  const [inline]
 

Returns the application context.

Definition at line 369 of file CXtEventLoop.h.

char** CXtEventLoop::getFallbackResources  )  const [inline]
 

Returns a pointer to the fallback resource list.

Definition at line 379 of file CXtEventLoop.h.

unsigned int CXtEventLoop::getOptionCount  )  const [inline]
 

Returns the number of options in the Option list.

Definition at line 389 of file CXtEventLoop.h.

XrmOptionDescRec* CXtEventLoop::getOptionTable  )  const [inline]
 

Returs a pointer to the option table.

Definition at line 374 of file CXtEventLoop.h.

Widget CXtEventLoop::getTopLevel  )  const [inline]
 

Returns the m_TopLevel member data.

Definition at line 364 of file CXtEventLoop.h.

Widget CXtEventLoop::InitializeApplication int &  argc,
char **  argv
[protected, virtual]
 

Called to initialize the X toolkit. Default behavior is to call XtAppinit(), and return its result.

A typical implementation of a subclass will might setup an options table and call setOptionTable and setOptionCount, Override the default class name via setApplicationClass, and fill in a set of fallback resources via setFallbackResources

Definition at line 359 of file CXtEventLoop.cpp.

References m_AppContext, and m_TopLevel.

Referenced by operator()().

int CXtEventLoop::operator() int  argc,
char **  argv
[private, virtual]
 

Entry point for the Xt event loop thread. The initialization functions are called to allow the application to set up the application widget set. After this is done, the event loop is entered. Each call of XtDispatchEvent is bracketed by calls to lock/unlock the application serializatio mutex.

Note that throughout the entire initialization of the Xt, the global mutex is held.

Implements CEventLoop.

Definition at line 425 of file CXtEventLoop.cpp.

References CApplicationSerializer::getInstance(), InitializeApplication(), CThreadRecursiveMutex::Lock(), m_AppContext, m_TopLevel, SetupApplicationResources(), SetupWidgetTree(), and CThreadRecursiveMutex::UnLock().

CXtEventLoop& CXtEventLoop::operator= const CXtEventLoop aCXtEventLoop  )  [private]
 

int CXtEventLoop::operator== const CXtEventLoop aCXtEventLoop  )  const [private]
 

void CXtEventLoop::setAppContext XtAppContext  newContext  )  [inline, protected]
 

Sets a new value for the application context.

Definition at line 400 of file CXtEventLoop.h.

References m_AppContext.

void CXtEventLoop::setApplicationClass const STD(string)&  ClassName  )  [inline, protected]
 

Set a new application class string.

Definition at line 413 of file CXtEventLoop.h.

void CXtEventLoop::setFallbackResources char **  resources  )  [inline, protected]
 

Set new fallback resource list.

Bug:
May want to do a copy in instead of pointer copy.

Definition at line 409 of file CXtEventLoop.h.

References m_ppcFallbackResources.

void CXtEventLoop::setOptionCount unsigned int  nCount  )  [inline, protected]
 

Set the number of items in the option list.

Definition at line 417 of file CXtEventLoop.h.

References m_nOptionCount.

void CXtEventLoop::setOptionTable XrmOptionDescRec *  pTable  )  [inline, protected]
 

Set a new option table pointer.

Definition at line 404 of file CXtEventLoop.h.

References m_pOptionTable.

void CXtEventLoop::setTopLevel const Widget  am_TopLevel  )  [inline, protected]
 

Set the value of the top level widget:.

Definition at line 395 of file CXtEventLoop.h.

References m_TopLevel.

void CXtEventLoop::SetupApplicationResources Widget  TopLevel  )  [protected, virtual]
 

Called from operator() to process the resource database. Since the resource database requires definitions which are application specific but is not actually required, the default behavior is to do nothing.

Normal applications will override this member toset up resource definition structures, invoke XtGetApplicationResrouces() to retrieve the actual values from the resource database and validity check them.

\

Definition at line 391 of file CXtEventLoop.cpp.

Referenced by operator()().

void CXtEventLoop::SetupWidgetTree Widget  TopLevel  )  [protected, virtual]
 

operator() calls this function to set up the initial widget tree.

This is completely application specific. Most applications will require a widget tree in addition to the shell widget produced by XtAppInitialize(). This member should be overridden to produce this tree.

Definition at line 406 of file CXtEventLoop.cpp.

Referenced by operator()().

CXtEventLoop::STD string   )  const [inline]
 

Returns the application class name.

Definition at line 384 of file CXtEventLoop.h.

CXtEventLoop::STD string   )  [private]
 

Application class.


Member Data Documentation

XtAppContext CXtEventLoop::m_AppContext [private]
 

Xt application context.

Definition at line 338 of file CXtEventLoop.h.

Referenced by InitializeApplication(), operator()(), and setAppContext().

bool CXtEventLoop::m_fExit [private]
 

TRUE when supposed to exit.

Definition at line 344 of file CXtEventLoop.h.

Referenced by exit().

unsigned int CXtEventLoop::m_nOptionCount [private]
 

Number of options.

Definition at line 341 of file CXtEventLoop.h.

Referenced by setOptionCount().

XrmOptionDescRec* CXtEventLoop::m_pOptionTable [private]
 

Command line option table (optional).

Definition at line 340 of file CXtEventLoop.h.

Referenced by setOptionTable().

char** CXtEventLoop::m_ppcFallbackResources [private]
 

Application fall back resourcelist.

Definition at line 342 of file CXtEventLoop.h.

Referenced by setFallbackResources().

Widget CXtEventLoop::m_TopLevel [private]
 

m_TopLevel is the top level of the application's widget hierarchy. in order to use the Xm++ library it will be necessary to retrieve this and instantiate Widget object from it.

Definition at line 337 of file CXtEventLoop.h.

Referenced by InitializeApplication(), operator()(), and setTopLevel().


The documentation for this class was generated from the following files:
Generated on Thu Jan 6 16:58:45 2005 for Spectrodaq External Event Framework by  doxygen 1.3.9.1