UnnamedPipe.hpp

Go to the documentation of this file.
00001 /*******************************************************************************
00002 * Copyright (C) 2004 Vintela, Inc. All rights reserved.
00003 * Copyright (C) 2005 Novell, Inc. All rights reserved.
00004 *
00005 * Redistribution and use in source and binary forms, with or without
00006 * modification, are permitted provided that the following conditions are met:
00007 *
00008 *  - Redistributions of source code must retain the above copyright notice,
00009 *    this list of conditions and the following disclaimer.
00010 *
00011 *  - Redistributions in binary form must reproduce the above copyright notice,
00012 *    this list of conditions and the following disclaimer in the documentation
00013 *    and/or other materials provided with the distribution.
00014 *
00015 *  - Neither the name of Vintela, Inc., Novell, Inc., nor the names of its
00016 *    contributors may be used to endorse or promote products derived from this
00017 *    software without specific prior written permission.
00018 *
00019 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
00020 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00021 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00022 * ARE DISCLAIMED. IN NO EVENT SHALL Vintela, Inc., Novell, Inc., OR THE 
00023 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
00024 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
00025 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 
00026 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
00027 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 
00028 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
00029 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00030 *******************************************************************************/
00031 
00032 
00037 #ifndef BLOCXX_UNNAMEDPIPE_HPP_
00038 #define BLOCXX_UNNAMEDPIPE_HPP_
00039 #include "blocxx/BLOCXX_config.h"
00040 #include "blocxx/SelectableIFC.hpp"
00041 #include "blocxx/Exception.hpp"
00042 #include "blocxx/IntrusiveReference.hpp"
00043 #include "blocxx/IOIFC.hpp"
00044 #include "blocxx/CommonFwd.hpp"
00045 
00046 namespace BLOCXX_NAMESPACE
00047 {
00048 
00049 
00050 BLOCXX_DECLARE_APIEXCEPTION(UnnamedPipe, BLOCXX_COMMON_API);
00051 
00056 class BLOCXX_COMMON_API UnnamedPipe : public SelectableIFC, public IOIFC
00057 {
00058 public:
00059    virtual ~UnnamedPipe();
00060    
00069    int writeInt(int value);
00070 
00080    int writeString(const String& strData);
00081 
00090    int readInt(int* value);
00091 
00103    int readString(String& strData);
00104 
00111    void setReadTimeout(int seconds) { m_readTimeout = seconds; }
00118    int getReadTimeout() { return m_readTimeout; }
00125    void setWriteTimeout(int seconds) { m_writeTimeout = seconds; }
00132    int getWriteTimeout() { return m_writeTimeout; }
00139    void setTimeouts(int seconds) { m_readTimeout = m_writeTimeout = seconds; }
00140 
00149    String readAll();
00150 
00154    virtual void open() = 0;
00155 
00160    virtual int close() = 0;
00161 
00165    virtual bool isOpen() const = 0;
00166 
00170    virtual Select_t getWriteSelectObj() const = 0;
00171 
00172 
00173    enum EBlockingMode
00174    {
00175       E_NONBLOCKING,
00176       E_BLOCKING
00177    };
00183    virtual void setBlocking(EBlockingMode outputIsBlocking=E_BLOCKING) = 0;
00184 
00185    
00186    enum EOpen
00187    {
00188       E_DONT_OPEN,
00189       E_OPEN
00190    };
00196    static UnnamedPipeRef createUnnamedPipe(EOpen doOpen=E_OPEN);
00197 
00198 protected:
00199    UnnamedPipe()
00200       : SelectableIFC()
00201    {}
00202    int m_readTimeout;
00203    int m_writeTimeout;
00204 };
00205 BLOCXX_EXPORT_TEMPLATE(BLOCXX_COMMON_API, IntrusiveReference, UnnamedPipe);
00206 
00207 } // end namespace BLOCXX_NAMESPACE
00208 
00209 #endif   // BLOCXX_UNNAMEDPIPE_HPP_

Generated on Fri Jun 16 15:39:09 2006 for blocxx by  doxygen 1.4.6