Pipe.cpp 884 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. //
  2. // Pipe.cpp
  3. //
  4. // $Id: //poco/1.4/Foundation/src/Pipe.cpp#1 $
  5. //
  6. // Library: Foundation
  7. // Package: Processes
  8. // Module: Pipe
  9. //
  10. // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
  11. // and Contributors.
  12. //
  13. // SPDX-License-Identifier: BSL-1.0
  14. //
  15. #include "Poco/Pipe.h"
  16. namespace Poco {
  17. Pipe::Pipe():
  18. _pImpl(new PipeImpl)
  19. {
  20. }
  21. Pipe::Pipe(const Pipe& pipe):
  22. _pImpl(pipe._pImpl)
  23. {
  24. _pImpl->duplicate();
  25. }
  26. Pipe::~Pipe()
  27. {
  28. _pImpl->release();
  29. }
  30. Pipe& Pipe::operator = (const Pipe& pipe)
  31. {
  32. if (this != &pipe)
  33. {
  34. _pImpl->release();
  35. _pImpl = pipe._pImpl;
  36. _pImpl->duplicate();
  37. }
  38. return *this;
  39. }
  40. void Pipe::close(CloseMode mode)
  41. {
  42. switch (mode)
  43. {
  44. case CLOSE_READ:
  45. _pImpl->closeRead();
  46. break;
  47. case CLOSE_WRITE:
  48. _pImpl->closeWrite();
  49. break;
  50. default:
  51. _pImpl->closeRead();
  52. _pImpl->closeWrite();
  53. break;
  54. }
  55. }
  56. } // namespace Poco