Changeset 37:8d2fd5139a06 in rrlib_serialization-java


Ignore:
Timestamp:
30.07.2018 19:58:16 (12 months ago)
Author:
Max Reichardt <max.reichardt@…>
Branch:
17.03
Phase:
public
Message:

Adds ArrayBuffer interface and makes MemoryBuffer implement it (import from default branch)

Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • MemoryBuffer.java

    r26 r37  
    2121//---------------------------------------------------------------------- 
    2222package org.rrlib.serialization; 
     23 
     24import java.nio.ByteBuffer; 
    2325 
    2426import org.rrlib.logging.Log; 
     
    3941 * Writing and reading concurrently is not supported - due to resize. 
    4042 */ 
    41 public class MemoryBuffer implements BinarySerializable, Source, Sink, Copyable<MemoryBuffer>, GenericChangeable<MemoryBuffer> { 
     43public class MemoryBuffer implements BinarySerializable, Source, Sink, Copyable<MemoryBuffer>, GenericChangeable<MemoryBuffer>, ArrayBuffer { 
    4244 
    4345    /** Size of temporary array */ 
     
    337339        curSize = size; 
    338340    } 
     341 
     342    @Override 
     343    public ByteBuffer getByteBuffer() { 
     344        return getBuffer().getBuffer(); 
     345    } 
     346 
     347    @Override 
     348    public int[] getArrayDimensions() { 
     349        dimensions[0] = getSize(); 
     350        return dimensions; 
     351    } 
     352 
     353    @Override 
     354    public Channel[] getChannels() { 
     355        return CHANNELS; 
     356    } 
     357 
     358    private final int[] dimensions = { 0 }; 
     359    private static final Channel[] CHANNELS = { new Channel(AttributeType.UNSIGNED_BYTE, 0, 1, "Data") }; 
    339360} 
Note: See TracChangeset for help on using the changeset viewer.