OpenZWave Library 1.2
Stream.h
Go to the documentation of this file.
1//-----------------------------------------------------------------------------
2//
3// Stream.h
4//
5// Cross-platform circular buffer with signalling
6//
7// Copyright (c) 2010 Mal Lansell <mal@lansell.org>
8// All rights reserved.
9//
10// SOFTWARE NOTICE AND LICENSE
11//
12// This file is part of OpenZWave.
13//
14// OpenZWave is free software: you can redistribute it and/or modify
15// it under the terms of the GNU Lesser General Public License as published
16// by the Free Software Foundation, either version 3 of the License,
17// or (at your option) any later version.
18//
19// OpenZWave is distributed in the hope that it will be useful,
20// but WITHOUT ANY WARRANTY; without even the implied warranty of
21// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22// GNU Lesser General Public License for more details.
23//
24// You should have received a copy of the GNU Lesser General Public License
25// along with OpenZWave. If not, see <http://www.gnu.org/licenses/>.
26//
27//-----------------------------------------------------------------------------
28#ifndef _Stream_H
29#define _Stream_H
30
31#include "Defs.h"
32#include "platform/Wait.h"
33
34#include <string>
35
36namespace OpenZWave
37{
38 class Mutex;
39
42 class Stream: public Wait
43 {
44 friend class Wait;
45
46 public:
51 Stream( uint32 _bufferSize );
52
60 void SetSignalThreshold( uint32 _size );
61
62
72 bool Get( uint8* _buffer, uint32 _size );
73
83 bool Put( uint8* _buffer, uint32 _size );
84
90 uint32 GetDataSize()const{ return m_dataSize; }
91
97 void Purge();
98
99 protected:
106 void LogData( uint8* _buffer, uint32 _size, const string &_function );
107
111 virtual bool IsSignalled();
112
117 ~Stream();
118
119 private:
120 Stream( Stream const& ); // prevent copy
121 Stream& operator = ( Stream const& ); // prevent assignment
122
123 uint8* m_buffer;
124 uint32 m_bufferSize;
125 uint32 m_signalSize;
126 uint32 m_dataSize;
127 uint32 m_head;
128 uint32 m_tail;
129 Mutex* m_mutex;
130 };
131
132} // namespace OpenZWave
133
134#endif //_Event_H
135
unsigned int uint32
Definition: Defs.h:69
unsigned char uint8
Definition: Defs.h:63
Implements a platform-independent mutex–for serializing access to a shared resource.
Definition: Mutex.h:40
Platform-independent definition of a circular buffer.
Definition: Stream.h:43
void LogData(uint8 *_buffer, uint32 _size, const string &_function)
Definition: Stream.cpp:206
bool Get(uint8 *_buffer, uint32 _size)
Definition: Stream.cpp:90
bool Put(uint8 *_buffer, uint32 _size)
Definition: Stream.cpp:132
uint32 GetDataSize() const
Definition: Stream.h:90
Stream(uint32 _bufferSize)
Definition: Stream.cpp:43
virtual bool IsSignalled()
Definition: Stream.cpp:195
~Stream()
Definition: Stream.cpp:61
void Purge()
Definition: Stream.cpp:182
void SetSignalThreshold(uint32 _size)
Definition: Stream.cpp:73
Platform-independent definition of Wait objects.
Definition: Wait.h:42
Definition: Bitfield.h:35