Commit | Line | Data |
---|---|---|
bcec0116 AM |
1 | /******************************************************************************* |
2 | * Copyright (c) 2014 Ericsson | |
3 | * | |
4 | * All rights reserved. This program and the accompanying materials are | |
5 | * made available under the terms of the Eclipse Public License v1.0 which | |
6 | * 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 | ||
e894a508 | 13 | package org.eclipse.tracecompass.statesystem.core; |
bcec0116 AM |
14 | |
15 | import java.io.IOException; | |
16 | ||
17 | import org.eclipse.jdt.annotation.NonNullByDefault; | |
e894a508 AM |
18 | import org.eclipse.tracecompass.internal.statesystem.core.StateSystem; |
19 | import org.eclipse.tracecompass.statesystem.core.backend.IStateHistoryBackend; | |
bcec0116 AM |
20 | |
21 | /** | |
22 | * Factory to create state systems. | |
23 | * | |
24 | * Since state system are meant to be accessed using the {@link ITmfStateSystem} | |
25 | * and {@link ITmfStateSystemBuilder} interfaces, you can use this factory to | |
26 | * instantiate new ones. | |
27 | * | |
28 | * @author Alexandre Montplaisir | |
bcec0116 AM |
29 | */ |
30 | @NonNullByDefault | |
31 | public final class StateSystemFactory { | |
32 | ||
33 | private StateSystemFactory() {} | |
34 | ||
35 | /** | |
36 | * New-file factory method. For when you build a state system with a new | |
37 | * file, or if the back-end does not require a file on disk. | |
38 | * | |
bcec0116 AM |
39 | * @param backend |
40 | * Back-end plugin to use | |
41 | * @return The new state system | |
dbc7991d | 42 | * @since 1.0 |
bcec0116 | 43 | */ |
b2f62cb5 AM |
44 | public static ITmfStateSystemBuilder newStateSystem(IStateHistoryBackend backend) { |
45 | return new StateSystem(backend); | |
bcec0116 AM |
46 | } |
47 | ||
48 | /** | |
49 | * General factory method. The backend may try to open or create a file on | |
50 | * disk (the file contents and location are defined by the backend). | |
51 | * | |
bcec0116 AM |
52 | * @param backend |
53 | * The "state history storage" back-end to use. | |
54 | * @param newFile | |
55 | * Put true if this is a new history started from scratch (any | |
56 | * existing file will be overwritten). | |
57 | * @return The new state system | |
58 | * @throws IOException | |
59 | * If there was a problem creating the new history file | |
dbc7991d | 60 | * @since 1.0 |
bcec0116 | 61 | */ |
b2f62cb5 AM |
62 | public static ITmfStateSystemBuilder newStateSystem(IStateHistoryBackend backend, |
63 | boolean newFile) throws IOException { | |
64 | return new StateSystem(backend, newFile); | |
bcec0116 AM |
65 | } |
66 | ||
67 | } |