Application Class Reference

Class declaration for the application class. More...

Inherits ApplicationPlatform, and boost::noncopyable.

List of all members.

Public Types

typedef boost::shared_ptr<
boost::signal< void() > > 
SignalPtr
 Since boost::signal is noncopyable we use smart pointers of signals.

Public Member Functions

void addLocalWindowClassToUnregister (const Seed &)
 Adds a class name to be unregistered.
bool addWaitEvent (HANDLE hEvent, SignalPtr)
 Adds a waitable event HANDLE and the according signal.
void generateLocalClassName (Seed &)
 Generates a new class name.
HINSTANCE getAppHandle ()
 Returns the HINSTANCE to the process.
const CommandLinegetCommandLine ()
 Returns the command line object.
SmartUtil::tstring getModuleFileName () const
 Returns the full filename to the process.
SmartUtil::tstring getModulePath () const
 Returns the path to the process.
bool isAppAlreadyRunning ()
 Determine if is an application is already running or not.
bool lastWidget (const Widget *This) const
 Returns true if we have only one registered Widget left in the application.
void removeWaitEvent (HANDLE hEvent)
 Removes the waitable event HANDLE and the according signal.
int run ()
 Starts the application.
void setHeartBeatFunction (HeartBeat *mainHeartBeatObject)
 Sets the Heart Beat object.
void setSystemClassName (Seed &, const SmartUtil::tstring &)
 Set the class name.

Static Public Member Functions

static void checkCorruptOrMemleak (bool &corruptMemMemLeak)
 Calls various leak and memory corruption routines.
static Applicationinstance ()
 Returns the Application object.
static void neededSmartWinInit ()
 The initialization that must be done first.
static unsigned int reportErr (xCeption &err, bool corruptMemMemLeak)
 Shows the xCeption.


Detailed Description

Class declaration for the application class.

Every application using SmartWin will get ONE and ONLY one Application object automatically.
Class is a "natural" Singleton (see GoF "Design Patterns") which means that you must access
that one object through a static function.
To get to the Application object use the static member function Application::instance()
The Application object contains several useful functions, e.g. the getModulePath and the getCommandLine functions which in turn loads a bitmap and returns the handle to it, retrieves the path to the physical directory of the exe file and retrieves a vector of command line parameters.
The Application class inherits from boost::noncopyable to indicate it's not to be copied


Member Function Documentation

void addLocalWindowClassToUnregister ( const Seed  ) 

Adds a class name to be unregistered.

Use this function to add a window class that will be unregistered when the application finishes. The class name is taken from the Seed passed.

bool addWaitEvent ( HANDLE  hEvent,
SignalPtr   
)

Adds a waitable event HANDLE and the according signal.

You can feed in here HANDLEs of thread handles, console inputs, mutexes, processes, semaphores etc. (see Win32-API on MsgWaitForMultipleObjects) you acquired in your program, together with an according boost::signal. The signal contains the callback functions in your code which are invoked when Windows signals the HANDLE. (Since boost::signal is noncopyable we actually need here a smart pointer to the signal.)

static void checkCorruptOrMemleak ( bool &  corruptMemMemLeak  )  [static]

Calls various leak and memory corruption routines.

Used after the message loop completes in WinMain.

void generateLocalClassName ( Seed  ) 

Generates a new class name.

Use this function to generate a class name guaranteed to be unique within the application. The result is written back in the Seed passed. This should be the preferred method to generate class names for local classes. Global classes, on the other hand, require unique names across the operative system.

HINSTANCE getAppHandle (  ) 

Returns the HINSTANCE to the process.

Returns the handle to the process.

const CommandLine & getCommandLine (  ) 

Returns the command line object.

The command line object contains the parameters given to the process during startup.
Use this function to retrieve the command line object

SmartUtil::tstring getModuleFileName (  )  const

Returns the full filename to the process.

NOTE!
This function returns the full filename to the application WITH the process image name.
If you want to have only the path you must use Application::getModulePath.

SmartUtil::tstring getModulePath (  )  const

Returns the path to the process.

NOTE!
This function returns the PATH to the application WITHOUT the process image name.
If you want to have the path AND the FILENAME of the image process you must use Application::getModuleFileName.

Application & instance (  )  [static]

Returns the Application object.

Use this static function to access the Application object.

bool isAppAlreadyRunning (  ) 

Determine if is an application is already running or not.

Returns true if this application have another instance running!

bool lastWidget ( const Widget This  )  const

Returns true if we have only one registered Widget left in the application.

Used e.g. in the handling of WM_DESTROY to verify if we're supposed to return from the process or not.
Probably not of very much interest for the final user of the library.

static void neededSmartWinInit (  )  [static]

The initialization that must be done first.

Used internally by the WinMain function, and externally for DLL initialization.

void removeWaitEvent ( HANDLE  hEvent  ) 

Removes the waitable event HANDLE and the according signal.

Remove the event HANDLE in case we are not longer interested in being notified. (more info see addWaitEvent)

static unsigned int reportErr ( xCeption err,
bool  corruptMemMemLeak 
) [static]

Shows the xCeption.

Used if an exception occurs in the message loop in WinMain.

int run (  ) 

Starts the application.

Normally this function will be called from your "SmartWinMain(SmartWin::Application & app )" function as the last function.
E.g. return myApp.run();

void setHeartBeatFunction ( HeartBeat mainHeartBeatObject  ) 

Sets the Heart Beat object.

If you set this function before calling Application::run the library will go into "Game Mode" meaning that instead of waiting for next message it will peek for messages and after returning if it did find a message it will dispatch that message but anyway call your HeartBeat::tick() function after dispatching (or not!) your message. Normally the HeartBeat object would be the main Widget or something in which would be your primary rendering surface.

void setSystemClassName ( Seed ,
const SmartUtil::tstring &   
)

Set the class name.

It sets the class name to the string passed. It is useful for systemwide window classes (as opposed to local window classes). A unique name is part of the requirements to write systemwide window classes (e.g. a library of widgets to be used in other languages). The registration of a systemwide class in the operative system must be done with the appropriate style. SmartWin uses this function for those classes that do not need registration (e.g. STATIC).

Back to SmartWin website
SourceForge.net Logo