| 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 | /** |
| 16 | * Interface for segment-storing backends. |
| 17 | * |
| 18 | * @param <T> |
| 19 | * The type of {@link ISegment} element that will be stored in this |
| 20 | * database. |
| 21 | * |
| 22 | * @author Alexandre Montplaisir |
| 23 | */ |
| 24 | public interface ISegmentStore<T extends ISegment> extends Iterable<T> { |
| 25 | |
| 26 | /** |
| 27 | * Add an element to the database. |
| 28 | * |
| 29 | * @param elem The element to add. |
| 30 | */ |
| 31 | void addElement(T elem); |
| 32 | |
| 33 | /** |
| 34 | * Get the number of element currently existing in the database. |
| 35 | * |
| 36 | * @return The number of elements. |
| 37 | */ |
| 38 | long getNbElements(); |
| 39 | |
| 40 | /** |
| 41 | * Retrieve all elements that inclusively cross the given position. |
| 42 | * |
| 43 | * @param position |
| 44 | * The target position. This would represent a timestamp, if the |
| 45 | * tree's X axis represents time. |
| 46 | * @return The intervals that cross this position |
| 47 | */ |
| 48 | Iterable<T> getIntersectingElements(long position); |
| 49 | |
| 50 | /** |
| 51 | * Retrieve all elements that inclusively cross another segment. We define |
| 52 | * this target segment by its start and end positions. |
| 53 | * |
| 54 | * This effectively means, all elements that respect *both* conditions: |
| 55 | * |
| 56 | * <ul> |
| 57 | * <li>Their end is after the 'start' parameter</li> |
| 58 | * <li>Their start is before the 'end' parameter</li> |
| 59 | * </ul> |
| 60 | * |
| 61 | * @param start |
| 62 | * The target start position |
| 63 | * @param end |
| 64 | * The target end position |
| 65 | * @return The elements overlapping with this segment |
| 66 | */ |
| 67 | Iterable<T> getIntersectingElements(long start, long end); |
| 68 | |
| 69 | /** |
| 70 | * Dispose the data structure and release any system resources associated |
| 71 | * with it. |
| 72 | */ |
| 73 | void dispose(); |
| 74 | } |