home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional Developers Kit 1992 November / Disc01 / Disc01.mdf / cppbeta / ibmcli / iapp.hp_ / IAPP.HPP
Encoding:
C/C++ Source or Header  |  1992-10-26  |  8.9 KB  |  179 lines

  1. #ifndef _IAPP_
  2. #define _IAPP_
  3. /*******************************************************************************
  4. * FILE NAME: iapp.hpp                                                          *
  5. *                                                                              *
  6. * DESCRIPTION:                                                                 *
  7. *   Declaration of the class(es):                                              *
  8. *     IApplication        - class of objects representing OS/2 "executables"   *
  9. *     ICurrentApplication - class of the single instance of the "current"      *
  10. *                           executable                                         *
  11. *                                                                              *
  12. * COPYRIGHT:                                                                   *
  13. *   (C) Copyright IBM Corporation 1992                                         *
  14. *   All Rights Reserved                                                        *
  15. *   Licensed Materials * Property of IBM                                       *
  16. *                                                                              *
  17. *$Log:   I:/ibmclass/ibaseapp/vcs/iapp.hpv  $                                                                         *
  18. //
  19. //   Rev 1.4   19 Oct 1992 16:15:00   law
  20. //Removed excess security classification.
  21. // 
  22. //    Rev 1.3   12 Oct 1992 12:51:12   law
  23. // Changed per new IBase.
  24. // 
  25. //    Rev 1.2   25 Sep 1992 23:53:48   law
  26. // Add initializePM() to ctor and terminatePM() to dtor for ICurrentApplication
  27. // 
  28. //    Rev 1.1   25 Sep 1992 22:09:52   law
  29. // Major revision 
  30. *******************************************************************************/
  31. #ifndef _IBASE_
  32.   #include <ibase.hpp>
  33. #endif
  34.  
  35. #ifndef _IHANDLE_
  36.   #include <ihandle.hpp>
  37. #endif
  38.  
  39. class IResourceLibrary;
  40. #if !defined( _IRESLIB_ ) && !defined( I_NO_RELATED_HPP )
  41.   #include <ireslib.hpp>
  42. #endif
  43.  
  44. class ICurrentApplication;
  45.  
  46. class IApplication : public virtual IBase {
  47. /*******************************************************************************
  48. * Objects of this class represent OS/2 executables.  Such objects are used to  *
  49. * launch child processes/applications/session.                                 *
  50. *                                                                              *
  51. * Currently, support is not provided for any of the OS/2 or PM session APIs.   *
  52. * At some point, support will be added for the following system APIs, plus     *
  53. * others to be determined:                                                     *
  54. *   DosExecPgm                                                                 *
  55. *   DosWaitChild                                                               *
  56. *   DosKillProcess                                                             *
  57. *   DosExit                                                                    *
  58. *   DosStartSession                                                            *
  59. *   DosSelectSession                                                           *
  60. *   DosSetSession                                                              *
  61. *   DosStopSession                                                             *
  62. *   WinStartApp                                                                *
  63. *   WinTerminateApp                                                            *
  64. *******************************************************************************/
  65. public:
  66. /*------------------------ CONSTRUCTORS/DESTRUCTORS ----------------------------
  67. | There are n ways to construct instances of this class:                       |
  68. |   1. For applicatoin with given program name and arguments (default)         |
  69. |     Constructs a new IApplication object that will be subsequently started   |
  70. |     via a call to IApplication::start.  Both arguments default to null.      |
  71. |   2. For a previously started application with a given PID.                  |
  72. |     Used to apply IApplication functionality to processes startd via native  |
  73. |     OS/2 APIs.                                                               |
  74. ------------------------------------------------------------------------------*/
  75.   IApplication ( const char *progName = 0,
  76.                  const char *args     = 0 );
  77.   IApplication ( IProcessID  pid );
  78.  
  79. virtual
  80.   ~IApplication ( );
  81.  
  82. /*-------------------------------- ACCESSORS -----------------------------------
  83. | These function provide means of getting and setting the accessible           |
  84. | attributes of instances of this class:                                       |
  85. |   id      - returns the object's "process id" value                          |
  86. |   current - reference to the "current" process                               |
  87. ------------------------------------------------------------------------------*/
  88. virtual IProcessID
  89.   id ( ) const;
  90.  
  91. static ICurrentApplication
  92.  ¤t;
  93.  
  94. protected:
  95.  
  96. private:
  97. /*--------------------------------- PRIVATE ----------------------------------*/
  98. IProcessID
  99.   pid;
  100. }; // IApplication
  101.  
  102. class ICurrentApplication : public IApplication {
  103. /*******************************************************************************
  104. * Objects of this class represent the "current" OS/2 executing program.        *
  105. *                                                                              *
  106. * There is a single instance of this class.  A reference to it is obtained via *
  107. * the static member IApplication::current.                                     *
  108. *                                                                              *
  109. * The instance of this class contains information that must be maintained on   *
  110. * a per-application basis and must be accessible to code (objects) executing   *
  111. * in the process.                                                              *
  112. *******************************************************************************/
  113. public:
  114. /*-------------------------------- ACCESSORS -----------------------------------
  115. | These function provide means for getting and setting the accessible          |
  116. | attributes of instances of this class:                                       |
  117. |   resourceLib    - obtains a reference to the default resource library for   |
  118. |                    this application                                          |
  119. |   setResourceLib - sets the resource library from which default application  |
  120. |                    resources will be obtained; this library can be specified |
  121. |                    directly, or implicitly via codepage/resource .dll name   |
  122. |   argc           - obtains the number of application arguments               |
  123. |   argv           - obtains the n-th argument to the application              |
  124. |   setArgs        - sets the program arguments (argc/argv from main())        |
  125. ------------------------------------------------------------------------------*/
  126. virtual IResourceLibrary
  127.  &resourceLib    ( ) const,
  128.  &setResourceLib ( const char *resLibName );
  129.  
  130. virtual int
  131.   argc ( ) const;
  132.  
  133. virtual const char
  134.  *argv ( int argNo ) const;
  135.  
  136. virtual void
  137.   setArgs ( int   argc,
  138.             char *argv[] );
  139.  
  140. /*---------------------------- STARTING/STOPPING -------------------------------
  141. | These functions provide support for executing and terminating the current    |
  142. | process:                                                                     |
  143. |   run  - initiate the processing of PM messages in the current process       |
  144. |   exit - terminate the current process                                       |
  145. ------------------------------------------------------------------------------*/
  146. virtual void
  147.   run  ( ),
  148.   exit ( );
  149.  
  150. /*------------------------ CONSTRUCTORS/DESTRUCTORS ----------------------------
  151. | The desstructor for the "current process" cleans up application state.       |
  152. ------------------------------------------------------------------------------*/
  153.   ~ICurrentApplication ( );
  154.  
  155. protected:
  156. friend class IApplication;
  157. /*------------------------ CONSTRUCTORS/DESTRUCTORS ----------------------------
  158. | The constructor for this class is protected to ensure that the static        |
  159. | member "current" is the only instance.                                       |
  160. ------------------------------------------------------------------------------*/
  161.   ICurrentApplication ( );
  162.  
  163. /*----------------------------- IMPLEMENTATION ---------------------------------
  164. | These function are used to implement this class:                             |
  165. |   currentPID - static function returning current process ID                  |
  166. ------------------------------------------------------------------------------*/
  167. static IProcessID
  168.   currentPID ( );
  169.  
  170. private:
  171. /*--------------------------------- PRIVATE ----------------------------------*/
  172. IResourceLibrary
  173.  *resLib;
  174. static ICurrentApplication
  175.   current;
  176. }; // ICurrentAppliction
  177.  
  178. #endif /* _IAPP_ */
  179.