blob: cd63bd8f7a638835d29144f0c3ba181bd87237a1 (
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
|
/*******************************************************************************
* Copyright (c) 2007, 2008 Wind River Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Wind River Systems - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.examples.dsf.pda.service.commands;
import org.eclipse.cdt.dsf.concurrent.Immutable;
import org.eclipse.cdt.dsf.datamodel.IDMContext;
import org.eclipse.cdt.dsf.debug.service.command.ICommand;
import org.eclipse.cdt.dsf.debug.service.command.ICommandResult;
/**
* Base class for PDA commands. The PDA commands consist of a text request and
* a context. Since the PDA debugger protocol is stateless, the context is only
* needed to satisfy the ICommand interface.
*/
@Immutable
abstract public class AbstractPDACommand<V extends PDACommandResult> implements ICommand<V> {
final private IDMContext fContext;
final private String fRequest;
public AbstractPDACommand(IDMContext context, String request) {
fContext = context;
fRequest = request;
}
public IDMContext getContext() {
return fContext;
}
public ICommand<? extends ICommandResult> coalesceWith(ICommand<? extends ICommandResult> command) {
return null;
}
/**
* Returns the request to be sent to PDA.
*/
public String getRequest() {
return fRequest;
}
/**
* Returns the command result based on the given PDA response. This command
* uses the class type parameter as the return type to allow the compiler to
* enforce the correct command result. This class must be implemented by
* each command to create the concrete result type.
*/
abstract public V createResult(String resultText);
@Override
public boolean equals(Object obj) {
if (obj instanceof AbstractPDACommand) {
AbstractPDACommand<?> cmd = (AbstractPDACommand<?>)obj;
return fContext.equals(cmd.fContext) && fRequest.equals(cmd.fRequest);
}
return false;
}
@Override
public int hashCode() {
return fContext.hashCode() + fRequest.hashCode();
}
}
|