1 /* 2 * Copyright 2015 The Netty Project 3 * 4 * The Netty Project licenses this file to you under the Apache License, 5 * version 2.0 (the "License"); you may not use this file except in compliance 6 * with the License. You may obtain a copy of the License at: 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" ~BASIS, WITHOUT 12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 * License for the specific language governing permissions and limitations 14 * under the License. 15 */ 16 module hunt.net.buffer.UnpooledDuplicatedByteBuf; 17 18 import hunt.net.buffer.AbstractByteBuf; 19 import hunt.net.buffer.DuplicatedByteBuf; 20 import hunt.util.ByteOrder; 21 22 /** 23 * {@link DuplicatedByteBuf} implementation that can do optimizations because it knows the duplicated buffer 24 * is of type {@link AbstractByteBuf}. 25 */ 26 class UnpooledDuplicatedByteBuf : DuplicatedByteBuf { 27 28 this(AbstractByteBuf buffer) { 29 super(buffer); 30 } 31 32 override 33 AbstractByteBuf unwrap() { 34 return cast(AbstractByteBuf) super.unwrap(); 35 } 36 37 override 38 protected byte _getByte(int index) { 39 return unwrap()._getByte(index); 40 } 41 42 override 43 protected short _getShort(int index) { 44 return unwrap()._getShort(index); 45 } 46 47 override 48 protected short _getShortLE(int index) { 49 return unwrap()._getShortLE(index); 50 } 51 52 override 53 protected int _getUnsignedMedium(int index) { 54 return unwrap()._getUnsignedMedium(index); 55 } 56 57 override 58 protected int _getUnsignedMediumLE(int index) { 59 return unwrap()._getUnsignedMediumLE(index); 60 } 61 62 override 63 protected int _getInt(int index) { 64 return unwrap()._getInt(index); 65 } 66 67 override 68 protected int _getIntLE(int index) { 69 return unwrap()._getIntLE(index); 70 } 71 72 override 73 protected long _getLong(int index) { 74 return unwrap()._getLong(index); 75 } 76 77 override 78 protected long _getLongLE(int index) { 79 return unwrap()._getLongLE(index); 80 } 81 82 override 83 protected void _setByte(int index, int value) { 84 unwrap()._setByte(index, value); 85 } 86 87 override 88 protected void _setShort(int index, int value) { 89 unwrap()._setShort(index, value); 90 } 91 92 override 93 protected void _setShortLE(int index, int value) { 94 unwrap()._setShortLE(index, value); 95 } 96 97 override 98 protected void _setMedium(int index, int value) { 99 unwrap()._setMedium(index, value); 100 } 101 102 override 103 protected void _setMediumLE(int index, int value) { 104 unwrap()._setMediumLE(index, value); 105 } 106 107 override 108 protected void _setInt(int index, int value) { 109 unwrap()._setInt(index, value); 110 } 111 112 override 113 protected void _setIntLE(int index, int value) { 114 unwrap()._setIntLE(index, value); 115 } 116 117 override 118 protected void _setLong(int index, long value) { 119 unwrap()._setLong(index, value); 120 } 121 122 override 123 protected void _setLongLE(int index, long value) { 124 unwrap()._setLongLE(index, value); 125 } 126 }