home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ocl150a.zip / OCL / Source / OXApp.cpp < prev    next >
C/C++ Source or Header  |  1996-08-12  |  3KB  |  133 lines

  1. // OCL - OS/2 Class Library
  2. // (c) Cubus 1995
  3. // All Rights Reserved
  4. // OApp.cpp
  5.  
  6.  
  7. /*
  8.  * Redistribution and use in source and binary forms, with or without
  9.  * modification, are permitted provided that the following conditions
  10.  * are met:
  11.  * 1. Redistributions of source code must retain the above copyright
  12.  *    notice, this list of conditions and the following disclaimer.
  13.  * 2. Neither the name Cubus nor the name Team OCL may be used to
  14.  *    endorse or promote products derived from this software
  15.  *    without specific prior written permission.
  16.  * 3. See OCL.INF for a detailed copyright notice.
  17.  *
  18.  *              THIS SOFTWARE IS PROVIDED ``AS IS'' AND
  19.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  20.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  21.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  22.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  23.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  24.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  25.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  26.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  27.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  28.  * SUCH DAMAGE.
  29.  */
  30.  
  31. // $Header: W:/Projects/OCL/Source/rcs/OXApp.cpp 1.50 1996/08/11 23:49:36 B.STEIN Release $
  32.  
  33. #define __OCL_SOURCE__
  34.  
  35. #define OINCL_OSTRING
  36. #define OINCL_BASE
  37.  
  38. #include <ocl.hpp>
  39. #include <OXApp.hpp>
  40. #include <OMsgs.hpp>
  41. #include <OVioException.hpp>
  42. #include <OPMException.hpp>
  43.  
  44. // OXApp
  45.  
  46.  
  47.  
  48. OXApp::OXApp(ULONG queueSize)
  49.   : OApp(queueSize)
  50.   {}
  51.  
  52.  
  53. OXApp::OXApp(const ULONG num, CHAR *Parms[], ULONG queueSize)
  54.   : OApp(num, Parms, queueSize)
  55.   {}
  56.  
  57.  
  58. OXApp::~OXApp()
  59.   {}
  60.  
  61.  
  62. PSZ OXApp::isOfType() const
  63.  return("OXApp"); 
  64.  
  65.  
  66. // message loop
  67.  
  68. void OXApp::run()
  69. {
  70.  OMsgs msg;
  71.  BOOL  continuable = TRUE;
  72.  
  73.  while(continuable)
  74.   {
  75.    continuable = FALSE;
  76.  
  77.    try 
  78.     {
  79.      OApp::run(); 
  80.     }
  81.  
  82.    catch(OException& except) 
  83.     {
  84.      OString message(except.description);
  85.       
  86.      message + "\n"
  87.              + OMessage(200, OCL::MSGFILE, except.isOfType());
  88.  
  89.      switch(except.severity())
  90.       {
  91.        case OException::recoverable:
  92.        case OException::unrecoverable:
  93.         {
  94.          continuable = TRUE;
  95.          msg.info(OMessage(205, OCL::MSGFILE), message);
  96.          break;
  97.         }
  98.  
  99.        case OException::fatal:
  100.         {
  101.          message + "\n"
  102.                  + OMessage(201, OCL::MSGFILE)
  103.                  + OMessage(202, OCL::MSGFILE);
  104.          msg.info(OMessage(205, OCL::MSGFILE), message);
  105.          break;
  106.         } 
  107.       }
  108.     }
  109.  
  110.    catch(OCLObject& except)
  111.     {
  112.      OString message(OMessage(203, OCL::MSGFILE));
  113.       
  114.      message + "\n"
  115.              + OMessage(200, OCL::MSGFILE, except.isOfType())
  116.              + OMessage(202, OCL::MSGFILE),
  117.      msg.info(OMessage(205, OCL::MSGFILE), message);
  118.     }
  119.  
  120.    catch(...)
  121.     {
  122.      OString message(OMessage(204, OCL::MSGFILE));
  123.    
  124.      message + OMessage(202, OCL::MSGFILE);
  125.      msg.info(OMessage(205, OCL::MSGFILE), message);
  126.     }
  127.   }
  128. }
  129.  
  130. // end of source
  131.