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

  1. // OCL - OS/2 Class Library
  2. // (c) Cubus 1995
  3. // All Rights Reserved
  4. // OPipe_streamable.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/OPipe_streamable.cpp 1.50 1996/08/11 23:49:28 B.STEIN Release $
  32.  
  33. #define __OCL_SOURCE__
  34.  
  35. #define OINCL_OSTRING
  36. #define OINCL_BASE
  37.  
  38. #include <ocl.hpp>
  39. #include <OPipe.hpp>
  40.  
  41.  
  42. OPipe_streamable::OPipe_streamable()
  43.  : ifh(NULLHANDLE),
  44.    ofh(NULLHANDLE),
  45.    wasCreator(FALSE)
  46.  {}
  47.  
  48.  
  49. OPipe_streamable::OPipe_streamable(ULONG storage)
  50.  : ifh(NULLHANDLE),
  51.    ofh(NULLHANDLE),
  52.    wasCreator(TRUE)
  53. {
  54.  APIRET rc;
  55.  
  56.  if ((rc = DosCreatePipe(&ifh, &ofh, storage)) != 0)
  57.    throw OVioException("OPipe_streamable Error", 
  58.                        rc, 
  59.                        OException::unrecoverable);
  60. }
  61.  
  62. OPipe_streamable::OPipe_streamable(pOPipe_streamable pipe)
  63.  : ifh(pipe->ifh),
  64.    ofh(pipe->ofh),
  65.    wasCreator(FALSE)
  66.  {}
  67.  
  68.  
  69. OPipe_streamable::OPipe_streamable(OPipe_streamable& pipe)
  70.  : ifh(pipe.ifh),
  71.    ofh(pipe.ofh),
  72.    wasCreator(FALSE)
  73.  {}
  74.  
  75.  
  76. OPipe_streamable::OPipe_streamable(HFILE in, HFILE out)
  77.  : ifh(in),
  78.    ofh(out),
  79.    wasCreator(FALSE)
  80.  {}
  81.  
  82. OPipe_streamable::~OPipe_streamable()
  83. {
  84.  if (wasCreator)
  85.    closePipe();
  86. }
  87.  
  88. PSZ OPipe_streamable::isOfType() const
  89.  return("OPipe_streamable"); 
  90. }
  91.  
  92.  
  93. void OPipe_streamable::closePipe()
  94. {
  95.  DosClose(ifh); 
  96.  DosClose(ofh);
  97.  ifh = NULLHANDLE;
  98.  ofh = NULLHANDLE;
  99. }
  100.  
  101.  
  102. // end of source
  103.