diff options
Diffstat (limited to 'linden/indra/llmessage/lliobuffer.cpp')
-rw-r--r-- | linden/indra/llmessage/lliobuffer.cpp | 115 |
1 files changed, 115 insertions, 0 deletions
diff --git a/linden/indra/llmessage/lliobuffer.cpp b/linden/indra/llmessage/lliobuffer.cpp new file mode 100644 index 0000000..506bd76 --- /dev/null +++ b/linden/indra/llmessage/lliobuffer.cpp | |||
@@ -0,0 +1,115 @@ | |||
1 | /** | ||
2 | * @file lliobuffer.cpp | ||
3 | * @author Phoenix | ||
4 | * @date 2005-05-04 | ||
5 | * @brief Definition of buffer based implementations of IO Pipes. | ||
6 | * | ||
7 | * Copyright (c) 2005-2007, Linden Research, Inc. | ||
8 | * | ||
9 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
10 | * to you under the terms of the GNU General Public License, version 2.0 | ||
11 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
12 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
13 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
14 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
15 | * | ||
16 | * There are special exceptions to the terms and conditions of the GPL as | ||
17 | * it is applied to this Source Code. View the full text of the exception | ||
18 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
19 | * online at http://secondlife.com/developers/opensource/flossexception | ||
20 | * | ||
21 | * By copying, modifying or distributing this software, you acknowledge | ||
22 | * that you have read and understood your obligations described above, | ||
23 | * and agree to abide by those obligations. | ||
24 | * | ||
25 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
26 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
27 | * COMPLETENESS OR PERFORMANCE. | ||
28 | */ | ||
29 | |||
30 | #include "linden_common.h" | ||
31 | #include "lliobuffer.h" | ||
32 | |||
33 | // | ||
34 | // LLIOBuffer | ||
35 | // | ||
36 | LLIOBuffer::LLIOBuffer() : | ||
37 | mBuffer(NULL), | ||
38 | mBufferSize(0L), | ||
39 | mReadHead(NULL), | ||
40 | mWriteHead(NULL) | ||
41 | { | ||
42 | } | ||
43 | |||
44 | LLIOBuffer::~LLIOBuffer() | ||
45 | { | ||
46 | if(mBuffer) | ||
47 | { | ||
48 | delete[] mBuffer; | ||
49 | } | ||
50 | } | ||
51 | |||
52 | U8* LLIOBuffer::data() const | ||
53 | { | ||
54 | return mBuffer; | ||
55 | } | ||
56 | |||
57 | S64 LLIOBuffer::size() const | ||
58 | { | ||
59 | return mBufferSize; | ||
60 | } | ||
61 | |||
62 | U8* LLIOBuffer::current() const | ||
63 | { | ||
64 | return mReadHead; | ||
65 | } | ||
66 | |||
67 | S64 LLIOBuffer::bytesLeft() const | ||
68 | { | ||
69 | return mWriteHead - mReadHead; | ||
70 | } | ||
71 | |||
72 | void LLIOBuffer::clear() | ||
73 | { | ||
74 | mReadHead = mBuffer; | ||
75 | mWriteHead = mBuffer; | ||
76 | } | ||
77 | |||
78 | LLIOPipe::EStatus LLIOBuffer::seek(LLIOBuffer::EHead head, S64 delta) | ||
79 | { | ||
80 | LLIOPipe::EStatus status = STATUS_ERROR; | ||
81 | switch(head) | ||
82 | { | ||
83 | case READ: | ||
84 | if(((delta >= 0) && ((mReadHead + delta) <= mWriteHead)) | ||
85 | || (delta < 0) && ((mReadHead + delta) >= mBuffer)) | ||
86 | { | ||
87 | mReadHead += delta; | ||
88 | status = STATUS_OK; | ||
89 | } | ||
90 | break; | ||
91 | case WRITE: | ||
92 | if(((delta >= 0) && ((mWriteHead + delta) < (mBuffer + mBufferSize))) | ||
93 | || (delta < 0) && ((mWriteHead + delta) > mReadHead)) | ||
94 | { | ||
95 | mWriteHead += delta; | ||
96 | status = STATUS_OK; | ||
97 | } | ||
98 | default: | ||
99 | break; | ||
100 | } | ||
101 | return status; | ||
102 | } | ||
103 | |||
104 | // virtual | ||
105 | LLIOPipe::EStatus LLIOBuffer::process_impl( | ||
106 | const LLChannelDescriptors& channels, | ||
107 | buffer_ptr_t& buffer, | ||
108 | bool& eos, | ||
109 | LLSD& context, | ||
110 | LLPumpIO* pump) | ||
111 | { | ||
112 | // no-op (I think) | ||
113 | llwarns << "You are using an LLIOBuffer which is deprecated." << llendl; | ||
114 | return STATUS_OK; | ||
115 | } | ||