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 | ||
13 | package org.eclipse.linuxtools.statesystem.core; | |
14 | ||
15 | import java.io.IOException; | |
16 | ||
17 | import org.eclipse.jdt.annotation.NonNullByDefault; | |
18 | import org.eclipse.linuxtools.internal.statesystem.core.StateSystem; | |
19 | import org.eclipse.linuxtools.statesystem.core.backend.IStateHistoryBackend; | |
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 | |
29 | * @since 3.0 | |
30 | */ | |
31 | @NonNullByDefault | |
32 | public final class StateSystemFactory { | |
33 | ||
34 | private StateSystemFactory() {} | |
35 | ||
36 | /** | |
37 | * New-file factory method. For when you build a state system with a new | |
38 | * file, or if the back-end does not require a file on disk. | |
39 | * | |
40 | * @param id | |
41 | * The ID of this statesystem. It should be unique. | |
42 | * @param backend | |
43 | * Back-end plugin to use | |
44 | * @return The new state system | |
45 | */ | |
46 | public static ITmfStateSystemBuilder newStateSystem(String id, | |
47 | IStateHistoryBackend backend) { | |
48 | return new StateSystem(id, backend); | |
49 | } | |
50 | ||
51 | /** | |
52 | * General factory method. The backend may try to open or create a file on | |
53 | * disk (the file contents and location are defined by the backend). | |
54 | * | |
55 | * @param id | |
56 | * The ID of this statesystem. It should be unique. | |
57 | * @param backend | |
58 | * The "state history storage" back-end to use. | |
59 | * @param newFile | |
60 | * Put true if this is a new history started from scratch (any | |
61 | * existing file will be overwritten). | |
62 | * @return The new state system | |
63 | * @throws IOException | |
64 | * If there was a problem creating the new history file | |
65 | */ | |
66 | public static ITmfStateSystemBuilder newStateSystem(String id, | |
67 | IStateHistoryBackend backend, boolean newFile) throws IOException { | |
68 | return new StateSystem(id, backend, newFile); | |
69 | } | |
70 | ||
71 | } |