libmoost
/home/mhx/git/github/libmoost/include/moost/service/posix_stream_stealer.h
Go to the documentation of this file.
00001 /* vim:set ts=3 sw=3 sts=3 et: */
00028 #ifndef FM_LAST_MOOST_SERVICE_POSIX_STREAM_STEALER
00029 #define FM_LAST_MOOST_SERVICE_POSIX_STREAM_STEALER
00030 
00031 #include <cstdio>
00032 
00033 #ifdef _POSIX_SOURCE
00034 # include "detail/posix_stream_stealer.h"
00035 #else
00036 # include "detail/dummy_stream_stealer.h"
00037 #endif
00038 
00039 namespace moost { namespace service {
00040 
00041 class posix_stream_stealer
00042 {
00043 public:
00044    posix_stream_stealer(bool restore = true, bool close_pipe = false)
00045       : m_impl(restore, close_pipe)
00046    {
00047    }
00048 
00049    bool steal(FILE *handle)
00050    {
00051       return m_impl.steal(handle);
00052    }
00053 
00054    bool restore(bool close_pipe = false)
00055    {
00056       return m_impl.restore(close_pipe);
00057    }
00058 
00059    int get_pipe_fd() const
00060    {
00061       return m_impl.get_pipe_fd();
00062    }
00063 
00064    int get_backup_fd() const
00065    {
00066       return m_impl.get_backup_fd();
00067    }
00068 
00069 private:
00070    detail::posix_stream_stealer m_impl;
00071 };
00072 
00073 } }
00074 
00075 #endif