/* Network-Integrated Multimedia Middleware (NMM)
 * http://www.motama.com/nmm.html
 *  
 * Copyright (C) 2006-2007
 * Motama GmbH, Saarbruecken, Germany
 * http://www.motama.com
 *  
 * This file is part of NMM. 
 * 
 * NMM is free software; you can redistribute it and/or modify it    
 * under the terms of the GNU General Public License as published by 
 * the Free Software Foundation; only version 2 of the License.      
 * 
 * NMM is distributed in the hope that it will be useful, but WITHOUT 
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public 
 * License for more details.  
 * 
 * You should have received a copy of the GNU General Public License 
 * along with NMM; if not, write to the Free Software Foundation,    
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 */

#ifndef NMM_UNBUFFERED_I_NET_STREAM_HPP
#define NMM_UNBUFFERED_I_NET_STREAM_HPP NMM_UNBUFFERED_I_NET_STREAM_HPP

#include "nmm/nmm_prefix.hpp"

#include "INetStream.hpp"

#include "visibility.hpp"

namespace NMM {

  /** Unbuffered network input stream.
   * This class is a network input stream which directly reads from a socket.
   */
  class DLLEXPORT UnbufferedINetStream
    : public INetStream
  {
  public:
    /** @name Constructor & Destructor
     */
    //@{
    /** Constructor.
     */
    UnbufferedINetStream();

    /** Virtual destructor.
     */
    virtual ~UnbufferedINetStream();

    /** Virtual copy constructor.
     *
     * @return A copy of this object which has the same type
     */
    virtual UnbufferedINetStream* copy() const;
    //@}

    /** Check if this stream is empty.
     * This method checks if this stream contains no data to read.
     * If this method returns @c true, serialization operations will fail.
     *
     * This implementation always returns @c true.
     *
     * @return @c true if this stream is empty, @c false otherwise
     */
    virtual bool isEmpty() const { return true; }

  protected:
    /** Subclass constructor.
     * This constructor must be used by subclasses when initializing the base class.
     * Every subclass must also define this subclass constructor as a protected constructor.
     *
     * @param ti Type information for this object
     */
    UnbufferedINetStream(const TypeInfo& ti);

    /** Socket read method.
     * This method performs the socket read operation. It is invoked by the implementation
     * of the serialization operators.
     *
     * This implementation directly reads data from the socket.
     *
     * @param data Binary data to be serialized
     * @param size Size of binary data to serialize (in bytes)
     */
    virtual void readValue(void* data, size_t size);
  };
  
}

#include "nmm/nmm_suffix.hpp"

#endif
