| 1 | /******************************************************************************* |
| 2 | * Copyright (c) 2015 EfficiOS Inc., Alexandre Montplaisir |
| 3 | * |
| 4 | * All rights reserved. This program and the accompanying materials |
| 5 | * are made available under the terms of the Eclipse Public License v1.0 |
| 6 | * which accompanies this distribution, and is available at |
| 7 | * http://www.eclipse.org/legal/epl-v10.html |
| 8 | * |
| 9 | * Contributors: |
| 10 | * Alexandre Montplaisir - Initial API and implementation |
| 11 | *******************************************************************************/ |
| 12 | |
| 13 | package org.eclipse.tracecompass.segmentstore.core; |
| 14 | |
| 15 | import java.util.Collection; |
| 16 | |
| 17 | /** |
| 18 | * Interface for segment-storing backends. |
| 19 | * |
| 20 | * @param <E> |
| 21 | * The type of {@link ISegment} element that will be stored in this |
| 22 | * database. |
| 23 | * |
| 24 | * @author Alexandre Montplaisir |
| 25 | */ |
| 26 | public interface ISegmentStore<E extends ISegment> extends Collection<E> { |
| 27 | |
| 28 | /** |
| 29 | * Retrieve all elements that inclusively cross the given position. |
| 30 | * |
| 31 | * @param position |
| 32 | * The target position. This would represent a timestamp, if the |
| 33 | * tree's X axis represents time. |
| 34 | * @return The intervals that cross this position |
| 35 | */ |
| 36 | Iterable<E> getIntersectingElements(long position); |
| 37 | |
| 38 | /** |
| 39 | * Retrieve all elements that inclusively cross another segment. We define |
| 40 | * this target segment by its start and end positions. |
| 41 | * |
| 42 | * This effectively means, all elements that respect *both* conditions: |
| 43 | * |
| 44 | * <ul> |
| 45 | * <li>Their end is after the 'start' parameter</li> |
| 46 | * <li>Their start is before the 'end' parameter</li> |
| 47 | * </ul> |
| 48 | * |
| 49 | * @param start |
| 50 | * The target start position |
| 51 | * @param end |
| 52 | * The target end position |
| 53 | * @return The elements overlapping with this segment |
| 54 | */ |
| 55 | Iterable<E> getIntersectingElements(long start, long end); |
| 56 | |
| 57 | /** |
| 58 | * Dispose the data structure and release any system resources associated |
| 59 | * with it. |
| 60 | */ |
| 61 | void dispose(); |
| 62 | } |