Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 7292890f7d708d3093fd2d95969de0298d6df408 (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
/*******************************************************************************
 * 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.dsf.mi.service.command;

import org.eclipse.cdt.dsf.datamodel.AbstractDMContext;
import org.eclipse.cdt.dsf.datamodel.DMContexts;
import org.eclipse.cdt.dsf.datamodel.IDMContext;
import org.eclipse.cdt.dsf.debug.service.command.ICommandControl;
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlDMContext;
import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
import org.eclipse.cdt.dsf.service.IDsfService;
import org.osgi.framework.Constants;

/**
 * 
 */
public class MIControlDMContext extends AbstractDMContext 
    implements ICommandControlDMContext
{
    final static String PROP_INSTANCE_ID = GdbPlugin.PLUGIN_ID + ".miControlInstanceId";    //$NON-NLS-1$

    private final String fCommandControlFilter;
    private final String fCommandControlId;
    
    public MIControlDMContext(String sessionId, String commandControlId) {
        this(sessionId, DMContexts.EMPTY_CONTEXTS_ARRAY, commandControlId);
    }

    public MIControlDMContext(String sessionId, IDMContext[] parents, String commandControlId) {
        super(sessionId, parents);

        fCommandControlId = commandControlId;
        fCommandControlFilter = 
            "(&" +  //$NON-NLS-1$
            "(" + Constants.OBJECTCLASS + "=" + ICommandControl.class.getName() + ")" + //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
            "(" + IDsfService.PROP_SESSION_ID + "=" + sessionId + ")" + //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
            "(" + PROP_INSTANCE_ID + "=" + commandControlId + ")" + //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
            ")"; //$NON-NLS-1$
    }

    public String getCommandControlFilter() { 
        return fCommandControlFilter;
    }

    /**
     * @since 1.1
     */
    public String getCommandControlId() {
        return fCommandControlId;
    }
    
    @Override
    public boolean equals(Object obj) {
        return baseEquals(obj) && fCommandControlId.equals(((MIControlDMContext)obj).fCommandControlId);
    }

    @Override
    public int hashCode() {
        return baseHashCode() + fCommandControlId.hashCode(); 
    }
    
    @Override
    public String toString() {
        return baseToString() + fCommandControlId;
    }
}

Back to the top