home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
cset21v1.zip
/
IBMCPP
/
IBMCLASS
/
IAPP.HPP
< prev
next >
Wrap
C/C++ Source or Header
|
1993-10-22
|
13KB
|
260 lines
#ifndef _IAPP_
#define _IAPP_
/*******************************************************************************
* FILE NAME: iapp.hpp *
* *
* DESCRIPTION: *
* Declaration of the class(es): *
* IApplication - class of objects representing OS/2 "executables" *
* ICurrentApplication - class of the single instance of the "current" *
* executable *
* *
* COPYRIGHT: *
* (C) Copyright IBM Corporation 1992 *
* All Rights Reserved *
* Licensed Materials * Property of IBM *
* *
*******************************************************************************/
#ifndef _IVBASE_
#include <ivbase.hpp>
#endif
#ifndef _IHANDLE_
#include <ihandle.hpp>
#endif
/*----------------------------------------------------------------------------*/
/* Align classes on four byte boundary. */
/*----------------------------------------------------------------------------*/
#pragma pack(4)
struct pib_s;
class IResourceLibrary;
class IString;
class ICurrentApplication;
class IApplication : public IVBase {
typedef IVBase
Inherited;
/*******************************************************************************
* The IApplication class's objects represent OS/2 processes. *
* *
* User Interface Class Library supports only the currently executing *
* application, the single instance of the derived class ICurrentApplication. *
* The static member function current provides access to that instance. *
*******************************************************************************/
public:
/*-------------------------------- Accessors -----------------------------------
| These functions provide means of getting and setting the accessible |
| attributes of instances of this class: |
| id - Returns the object's process identifier value. |
| current - Returns a reference to the current application, an instance |
| of the ICurrentApplication class. |
| asString - Returns the string "IApplication(process identifier value)." |
| asDebugInfo - Returns a representation of the application as debug |
| information. |
| currentPID - Returns the current process identifier. |
------------------------------------------------------------------------------*/
virtual IProcessId
id ( ) const;
static ICurrentApplication
¤t ( );
virtual IString
asString ( ) const,
asDebugInfo ( ) const;
static IProcessId
currentPID ( );
/*--------------------------------- Priority -----------------------------------
| You can use the following members to control the priority of the application |
| (and its threads). Note: While you can set priorities using the IApplication|
| class, only threads actually have a priority. As a result, you need to use |
| functions of the IThread class to query the priority of an application's |
| threads. |
| PriorityClass - Enumeration of the various priority classes: |
| noChange |
| idleTime |
| regular |
| timeCritical |
| foregroundServer |
| adjustPriority - Adjusts the priority level of all the application's |
| threads by some amount. An optional flag indicates |
| whether or not to also adjust the priority of |
| threads of descendent processes. |
| setPriority - Sets the priority class and level of all the |
| application's threads to the argument value. An |
| optional Boolean argument specifies whether the |
| priority of descendent processes should also be |
| modified. |
------------------------------------------------------------------------------*/
enum PriorityClass
{
noChange,
idleTime,
regular,
timeCritical,
foregroundServer
};
IApplication
&adjustPriority ( int adjustment,
Boolean setDescendents = false ),
&setPriority ( PriorityClass priorityClass,
unsigned priorityLevel = 0,
Boolean setDescendents = false );
protected:
/*------------------------------- Constructor ----------------------------------
| You can only construct an instance of this class with the process identifier |
| for the process that the object will represent. The constructor is |
| protected; only the derived class ICurrentApplication utilizes it. |
------------------------------------------------------------------------------*/
IApplication ( const IProcessId &id );
~IApplication ( );
/*------------------------------ Implementation --------------------------------
| This function provides utilities used to implement this class: |
| setId - Sets the process identifier. This function is called by |
| derived classes when processes are started. |
------------------------------------------------------------------------------*/
virtual IApplication
&setId ( const IProcessId &id );
private:
/*--------------------------------- PRIVATE ----------------------------------*/
static ICurrentApplication
*pCurrent;
IProcessId
pid;
}; // IApplication
class ICurrentApplication : public IApplication {
typedef IApplication
Inherited;
/*******************************************************************************
* The ICurrentApplication class's objects represent the OS/2 program that is *
* currently running. *
* *
* There is a single instance of this class. You can obtain a reference to it *
* by using the static member function IApplication::current. The instance of *
* this class contains information that must be maintained for each application *
* and must be accessible to the objects executing in the process. *
*******************************************************************************/
public:
/*-------------------------------- Arguments -----------------------------------
| These functions provide means for accessing the program arguments: |
| argc - Obtains the number of application arguments. |
| argv - Obtains the nth argument to the application. |
| setArgs - Sets the program arguments. You should call this member |
| function from your application's main function, passing |
| its argc and argv argument values. |
------------------------------------------------------------------------------*/
virtual int
argc ( ) const;
virtual IString
argv ( int argNo ) const;
virtual ICurrentApplication
&setArgs ( int argc,
const char * const argv[] );
/*---------------------------- Resource Libraries ------------------------------
| These functions provide access to the user's default application resource |
| library and the ICLUI library's resource library: |
| userResourceLibrary - Obtains a reference to the default user resource |
| library for this application. The default is the |
| .exe itself. IResourceId will use this resource |
| library if one is not specified explicitly. |
| setUserResourceLibrary - Sets the user resource library from which |
| application resources will be obtained. The |
| default is IResourceId. An input argument of 0 |
| implies that the .exe should be used. |
| resourceLibrary - Obtains a reference to the User Interface Class |
| Library resource library from which resources |
| required by the base library code are loaded. |
| If setResourceLibrary has been called with the |
| name of a dynamic-link library (DLL), the handle |
| of this library will be returned. Otherwise, the |
| environment variable "ICLUI RESLIB" is checked |
| for the name of a DLL and its handle is returned. |
| Set the environment variable using |
| "SET ICLUI RESLIB=myappdll". |
| Finally, if the environment variable has not been |
| set, the default DDE4U001.DLL will be used. |
| setResourceLibrary - Sets the resource library from which the class |
| library resources are loaded. The resource |
| library is specified as the name of the DLL |
| without the file extension. If 0 is passed, the |
| resources are loaded from the application .exe. |
------------------------------------------------------------------------------*/
virtual IResourceLibrary
&userResourceLibrary ( ) const,
&resourceLibrary ( ) const;
virtual ICurrentApplication
&setUserResourceLibrary ( const char *resLibName ),
&setResourceLibrary ( const char *resLibName );
/*---------------------------- Starting/Stopping -------------------------------
| These functions provide support for beginning and ending the current |
| process: |
| run - Initiates the processing of Presentation Manager messages in the |
| current process. |
| exit - Ends the current process. |
------------------------------------------------------------------------------*/
virtual ICurrentApplication
&run ( ),
&exit ( );
/*-------------------------------- Overrides -----------------------------------
| This class overrides the following inherited function: |
| asDebugInfo - Returns a diagnostic representation of the object. |
------------------------------------------------------------------------------*/
virtual IString
asDebugInfo ( ) const;
protected:
friend class IApplication;
/*------------------------------- Constructor ----------------------------------
| The constructor for this class is protected to ensure that the static |
| member pCurrent of the IApplication class points to the only instance. |
------------------------------------------------------------------------------*/
ICurrentApplication ( );
~ICurrentApplication ( );
/*------------------------------ Implementation --------------------------------
This function provides utilities used to implement this class:
pib - Returns pointer to the current process's process information block.
------------------------------------------------------------------------------*/
struct pib_s
&pib ( );
private:
/*--------------------------------- PRIVATE ----------------------------------*/
IResourceLibrary
*icluiLib,
*userLib;
Boolean
exeResource;
int
argCount;
IString
*argValue;
struct pib_s
*pPIB;
}; // ICurrentAppliction
/*----------------------------------------------------------------------------*/
/* Resume compiler default packing. */
/*----------------------------------------------------------------------------*/
#pragma pack()
#endif /* _IAPP_ */