Stream.h
Go to the documentation of this file.
//-----------------------------------------------------------------------------
//
// Stream.h
//
// Cross-platform circular buffer with signalling
//
// Copyright (c) 2010 Mal Lansell <mal@lansell.org>
// All rights reserved.
//
// SOFTWARE NOTICE AND LICENSE
//
// This file is part of OpenZWave.
//
// OpenZWave is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published
// by the Free Software Foundation, either version 3 of the License,
// or (at your option) any later version.
//
// OpenZWave 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 Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenZWave. If not, see <http://www.gnu.org/licenses/>.
//
//-----------------------------------------------------------------------------
#ifndef _Stream_H
#define _Stream_H
#include "Defs.h"
#include "platform/Wait.h"
#include <string>
namespace OpenZWave
{
class Mutex;
class Stream: public Wait
{
friend class Wait;
public:
Stream( uint32 _bufferSize );
void SetSignalThreshold( uint32 _size );
bool Get( uint8* _buffer, uint32 _size );
bool Put( uint8* _buffer, uint32 _size );
uint32 GetDataSize()const{ return m_dataSize; }
void Purge();
protected:
void LogData( uint8* _buffer, uint32 _size, const string &_function );
virtual bool IsSignalled();
~Stream();
private:
Stream( Stream const& ); // prevent copy
Stream& operator = ( Stream const& ); // prevent assignment
uint8* m_buffer;
uint32 m_bufferSize;
uint32 m_signalSize;
uint32 m_dataSize;
uint32 m_head;
uint32 m_tail;
Mutex* m_mutex;
};
} // namespace OpenZWave
#endif //_Event_H
OpenZWave
Definition: Bitfield.h:34
OpenZWave::Stream::Put
bool Put(uint8 *_buffer, uint32 _size)
Definition: Stream.cpp:133
Wait.h
OpenZWave::Stream::LogData
void LogData(uint8 *_buffer, uint32 _size, const string &_function)
Definition: Stream.cpp:208
OpenZWave::Stream
Platform-independent definition of a circular buffer.
Definition: Stream.h:42
OpenZWave::Stream::SetSignalThreshold
void SetSignalThreshold(uint32 _size)
Definition: Stream.cpp:74
Defs.h
OpenZWave::Stream::GetDataSize
uint32 GetDataSize() const
Definition: Stream.h:90
OpenZWave::Stream::IsSignalled
virtual bool IsSignalled()
Definition: Stream.cpp:197
OpenZWave::Stream::Stream
Stream(uint32 _bufferSize)
Definition: Stream.cpp:43
uint32
unsigned int uint32
Definition: Defs.h:80
OpenZWave::Stream::~Stream
~Stream()
Definition: Stream.cpp:62
OpenZWave::Wait
Platform-independent definition of Wait objects.
Definition: Wait.h:41
OpenZWave::Mutex
Implements a platform-independent mutex–for serializing access to a shared resource.
Definition: Mutex.h:39
OpenZWave::Stream::Purge
void Purge()
Definition: Stream.cpp:184
OpenZWave::Stream::Get
bool Get(uint8 *_buffer, uint32 _size)
Definition: Stream.cpp:91
uint8
unsigned char uint8
Definition: Defs.h:74