/**
 * @file
 * $Id$
 * $Revision$
 * $Author$
 * $Date$
 *
 * This file is part of The iWear Framework.
 *
 * The iWear Framework 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 as in version 2 of the License.

 * 
 * The iWear Framework 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
 * The iWear Framework; if not, write to the Free Software Foundation, Inc., 59
 * Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#ifndef __IWREMOTE_SHMSTREAM_H
#define __IWREMOTE_SHMSTREAM_H

#include <iwremote/rpcstream.h>

namespace iwear
{
    namespace net
    {
/**
 * This class implements the interface for RPCStream objects as a SHM stream
 * object, copying the data to a certain shm segment, where it then will be
 * read from another local process.
 */
class SHMStream : public RPCStream
{
private:
protected:
    void* stream;
public:
    SHMStream( size_t );
    virtual ~SHMStream();
    /**
     * Parses the next stream object and returns it as bool. Throws exception
     * when failing.
     *
     * This will return a pointer and the size to the buffer. It will be valid
     * only until another function has been called on this SHMStream (including
     * destructor of course)
     */
    virtual std::pair<char *, uint32_t> get_buffer( void );

    /**
     * This sets the buffer content. The buffer then belongs to the stream and
     * will be delete[]d as necessary (after copying to shm segment)
     */
    virtual void set_buffer( char*, uint32_t );

    virtual bool get_bool( void );
    virtual double get_double( void );
    virtual float get_float( void );
    virtual int get_int( void );
    virtual long get_long( void );
    virtual string get_string( void );
    virtual uid get_uid( void );

    virtual void put_bool( bool );
    virtual void put_double( double );
    virtual void put_float( float );
    virtual void put_int( int );
    virtual void put_long( long );
    virtual void put_string( const string& );
    virtual void put_uid( const uid& );

    virtual size_t max_size( void );
    virtual void resize( size_t );
};

}
}
#endif
