Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: dd377c11b021af3f45489dee9a74d2a386d67f5d (plain) (blame)
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/*******************************************************************************
 * Copyright (c) 2011, 2014 Mentor Graphics and others.
 *
 * 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
 *
 * Contributors:
 *     Vladimir Prus (Mentor Graphics) - initial API and implementation
 *******************************************************************************/

package org.eclipse.cdt.dsf.gdb.service;

import java.util.Hashtable;

import org.eclipse.cdt.dsf.concurrent.ConfinedToDsfExecutor;
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
import org.eclipse.cdt.dsf.concurrent.ImmediateExecutor;
import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
import org.eclipse.cdt.dsf.datamodel.IDMContext;
import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
import org.eclipse.cdt.dsf.gdb.service.command.IGDBControl;
import org.eclipse.cdt.dsf.mi.service.command.CommandFactory;
import org.eclipse.cdt.dsf.mi.service.command.output.MIInfoOsInfo;
import org.eclipse.cdt.dsf.service.DsfSession;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;

/**
 * @since 4.2
 */
public class GDBHardwareAndOS_7_5 extends GDBHardwareAndOS {

	public GDBHardwareAndOS_7_5(DsfSession session) {
		super(session);
	}

	@Override
	public void initialize(final RequestMonitor requestMonitor) {
		super.initialize(new RequestMonitor(ImmediateExecutor.getInstance(), requestMonitor) {
			@Override
			protected void handleSuccess() {
				register(new String[] { IGDBHardwareAndOS2.class.getName() }, new Hashtable<String, String>());

				requestMonitor.done();
			}
		});
	}

	@Override
	public void getResourceClasses(final IDMContext dmc, final DataRequestMonitor<IResourceClass[]> rm) {

		IGDBControl control = getServicesTracker().getService(IGDBControl.class);
		if (control == null) {
			rm.done(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INVALID_STATE, "Service not available", null)); //$NON-NLS-1$
			return;
		}

		CommandFactory factory = control.getCommandFactory();
		control.queueCommand(factory.createMIInfoOS(dmc), new DataRequestMonitor<MIInfoOsInfo>(getExecutor(), rm) {
			@Override
			@ConfinedToDsfExecutor("fExecutor")
			protected void handleSuccess() {
				rm.setData(getData().getResourceClasses());
				rm.done();
			}
		});
	}

	@Override
	public void getResourcesInformation(final IDMContext dmc, final String resourceClass,
			final DataRequestMonitor<IResourcesInformation> rm) {

		IGDBControl control = getServicesTracker().getService(IGDBControl.class);
		if (control == null) {
			rm.done(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INVALID_STATE, "Service not available", null)); //$NON-NLS-1$
			return;
		}

		CommandFactory factory = control.getCommandFactory();
		control.queueCommand(factory.createMIInfoOS(dmc, resourceClass),
				new DataRequestMonitor<MIInfoOsInfo>(getExecutor(), rm) {

					@Override
					protected void handleSuccess() {
						rm.setData(getData().getResourcesInformation());
						rm.done();
					}
				});
	}
}

Back to the top