-
Notifications
You must be signed in to change notification settings - Fork 10
/
ModelManager.java
56 lines (46 loc) · 1.61 KB
/
ModelManager.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*******************************************************************************
* Copyright (c) 2016 École Polytechnique de Montréal
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License 2.0 which
* accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
package org.eclipse.tracecompass.incubator.analysis.core.model;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.tracecompass.incubator.internal.analysis.core.model.CompositeHostModel;
/**
* Utility class to manage the models for the hosts
*
* @author Geneviève Bastien
*/
public final class ModelManager {
private static final Map<String, IHostModel> MODELS_FOR_HOST = new HashMap<>();
private ModelManager() {
}
/**
* Get the model for a given host ID.
*
* @param hostId
* The ID of the host for which to retrieve the model
* @return The model for the host
*/
public static synchronized IHostModel getModelFor(String hostId) {
IHostModel model = MODELS_FOR_HOST.get(hostId);
if (model == null) {
model = new CompositeHostModel(hostId);
MODELS_FOR_HOST.put(hostId, model);
}
return model;
}
/**
* Dispose all the models
*/
public static synchronized void disposeModels() {
MODELS_FOR_HOST.values().forEach(IHostModel::dispose);
MODELS_FOR_HOST.clear();
}
}