PixelLightAPI  .
Pipe.h
Go to the documentation of this file.
00001 /*********************************************************\
00002  *  File: Pipe.h                                         *
00003  *
00004  *  Copyright (C) 2002-2012 The PixelLight Team (http://www.pixellight.org/)
00005  *
00006  *  This file is part of PixelLight.
00007  *
00008  *  PixelLight is free software: you can redistribute it and/or modify
00009  *  it under the terms of the GNU Lesser General Public License as published by
00010  *  the Free Software Foundation, either version 3 of the License, or
00011  *  (at your option) any later version.
00012  *
00013  *  PixelLight is distributed in the hope that it will be useful,
00014  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00016  *  GNU Lesser General Public License for more details.
00017  *
00018  *  You should have received a copy of the GNU Lesser General Public License
00019  *  along with PixelLight. If not, see <http://www.gnu.org/licenses/>.
00020 \*********************************************************/
00021 
00022 
00023 #ifndef __PLCORE_PIPE_H__
00024 #define __PLCORE_PIPE_H__
00025 #pragma once
00026 
00027 
00028 //[-------------------------------------------------------]
00029 //[ Includes                                              ]
00030 //[-------------------------------------------------------]
00031 #include "PLCore/String/String.h"
00032 
00033 
00034 //[-------------------------------------------------------]
00035 //[ Namespace                                             ]
00036 //[-------------------------------------------------------]
00037 namespace PLCore {
00038 
00039 
00040 //[-------------------------------------------------------]
00041 //[ Classes                                               ]
00042 //[-------------------------------------------------------]
00043 /**
00044 *  @brief
00045 *    Class to create and access system pipes (named or unnamed)
00046 */
00047 class Pipe {
00048 
00049 
00050     //[-------------------------------------------------------]
00051     //[ Public functions                                      ]
00052     //[-------------------------------------------------------]
00053     public:
00054         /**
00055         *  @brief
00056         *    Constructor
00057         */
00058         inline Pipe();
00059 
00060         /**
00061         *  @brief
00062         *    Copy constructor
00063         *
00064         *  @param[in] cSource
00065         *    Source to copy
00066         */
00067         inline Pipe(const Pipe &cSource);
00068 
00069         /**
00070         *  @brief
00071         *    Destructor
00072         */
00073         inline ~Pipe();
00074 
00075         /**
00076         *  @brief
00077         *    Assignment operator
00078         *
00079         *  @param[in] cSource
00080         *    Source to copy
00081         *
00082         *  @return
00083         *    Reference to this Pipe
00084         */
00085         inline Pipe &operator =(const Pipe &cSource);
00086 
00087         /**
00088         *  @brief
00089         *    Comparison operator
00090         *
00091         *  @param[in] cSource
00092         *    Pipe to compare with
00093         *
00094         *  @return
00095         *    'true', if both Pipe's are equal, else 'false'
00096         */
00097         inline bool operator ==(const Pipe &cSource) const;
00098 
00099         /**
00100         *  @brief
00101         *    Comparison operator
00102         *
00103         *  @param[in] cSource
00104         *    Pipe to compare with
00105         *
00106         *  @return
00107         *    'true', if the Pipe's are different, else 'false'
00108         */
00109         inline bool operator !=(const Pipe &cSource) const;
00110 
00111         /**
00112         *  @brief
00113         *    Creates a new unnamend pipe
00114         *
00115         *  @return
00116         *    'true', if the pipe could be created, else 'false'
00117         */
00118         PLCORE_API bool Create();
00119 
00120         /**
00121         *  @brief
00122         *    Creates a new namend pipe
00123         *
00124         *  @param[in] sName
00125         *    Name of the pipe
00126         *
00127         *  @return
00128         *    'true', if the pipe could be created, else 'false'
00129         */
00130         PLCORE_API bool Create(const String &sName);
00131 
00132         /**
00133         *  @brief
00134         *    Open a pipe by file handles
00135         *
00136         *  @param[in] hRead
00137         *    Handle to the read end of the pipe
00138         *  @param[in] hWrite
00139         *    Handle to the write end of the pipe
00140         *
00141         *  @return
00142         *    'true', if the pipe could be opened, else 'false'
00143         */
00144         inline bool Open(handle hRead, handle hWrite);
00145 
00146         /**
00147         *  @brief
00148         *    Close read side of the pipe
00149         *
00150         *  @return
00151         *    'true', if the read side could be closed, else 'false'
00152         */
00153         PLCORE_API bool CloseRead();
00154 
00155         /**
00156         *  @brief
00157         *    Close write side of the pipe
00158         *
00159         *  @return
00160         *    'true', if the write side could be closed, else 'false'
00161         */
00162         PLCORE_API bool CloseWrite();
00163 
00164         /**
00165         *  @brief
00166         *    Close both sides of the pipe
00167         *
00168         *  @return
00169         *    'true', if the pipe could be closed, else 'false'
00170         */
00171         inline bool Close();
00172 
00173         /**
00174         *  @brief
00175         *    Get name of pipe
00176         *
00177         *  @return
00178         *    Name of the pipe
00179         */
00180         inline String GetName() const;
00181 
00182         /**
00183         *  @brief
00184         *    Get read handle for the pipe
00185         *
00186         *  @return
00187         *    Handle for the read-end of the pipe
00188         *
00189         *  @note
00190         *    - On Linux, the handle is a file handle of type int
00191         *    - On Windows, the handle is a file handle of type HANDLE
00192         */
00193         inline handle GetReadHandle() const;
00194 
00195         /**
00196         *  @brief
00197         *    Get write handle for the pipe
00198         *
00199         *  @return
00200         *    Handle for the write-end of the pipe
00201         *
00202         *  @see
00203         *    - GetReadHandle()
00204         */
00205         inline handle GetWriteHandle() const;
00206 
00207 
00208     //[-------------------------------------------------------]
00209     //[ Private data                                          ]
00210     //[-------------------------------------------------------]
00211     private:
00212         // Pipe data
00213         String  m_sName;    /**< Name of the pipe */
00214         handle  m_hPipe[2]; /**< Pipe handles (0 = read end, 1 = write end) */
00215 
00216 
00217 };
00218 
00219 
00220 //[-------------------------------------------------------]
00221 //[ Namespace                                             ]
00222 //[-------------------------------------------------------]
00223 } // PLCore
00224 
00225 
00226 //[-------------------------------------------------------]
00227 //[ Implementation                                        ]
00228 //[-------------------------------------------------------]
00229 #include "PLCore/System/Pipe.inl"
00230 
00231 
00232 #endif // __PLCORE_PIPE_H__


PixelLight PixelLight 0.9.11-R1
Copyright (C) 2002-2012 by The PixelLight Team
Last modified Thu Feb 23 2012 14:08:58
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported