Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 5cc665aebb3cdd4ba3de00e55bc6d50163ae05be (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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/*******************************************************************************
 * 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.debug.service;

import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
import org.eclipse.cdt.dsf.datamodel.AbstractDMContext;
import org.eclipse.cdt.dsf.datamodel.IDMContext;
import org.eclipse.cdt.dsf.datamodel.IDMData;
import org.eclipse.cdt.dsf.datamodel.IDMService;

public interface IFormattedValues extends IDMService {
    
    /** Marker interface for a DMC that has a formatted value. */
    public interface IFormattedDataDMContext extends IDMContext {}

    /**
     * These strings represent the standard known formats for any bit stream
     * which needs to be formatted. These ID's as well as others which may be
     * specifically available from the backend are what is returned from the
     * getID() method.
     */
    public final static String HEX_FORMAT     = "HEX.Format"     ; //$NON-NLS-1$
    public final static String OCTAL_FORMAT   = "OCTAL.Format"   ; //$NON-NLS-1$
    public final static String NATURAL_FORMAT = "NATURAL.Format" ; //$NON-NLS-1$
    public final static String BINARY_FORMAT  = "BINARY.Format"  ; //$NON-NLS-1$
    public final static String DECIMAL_FORMAT = "DECIMAL.Format" ; //$NON-NLS-1$
    public final static String STRING_FORMAT = "STRING.Format" ; //$NON-NLS-1$
    
    /**
     * Retrieves the  formats that the given data is available in.  
     * This method is asynchronous because the service may need to retrieve     
     * information from the backend in order to determine what formats are 
     * available for the given data context.
     * 
     * @param dmc Context for which to retrieve available formats.
     * @param rm Completion monitor returns an array of support formatIds.  
     */
    public void getAvailableFormats(IFormattedDataDMContext dmc, DataRequestMonitor<String[]> rm);
        
    /**
     * Creates a FormattedValueDMContext representing the given formatId.  
     * 
     * @param dmc Parent context for the context that is being created
     * @param formatId Defines format to be used for the returned context.
     */
    public FormattedValueDMContext getFormattedValueContext(IFormattedDataDMContext dmc, String formatId);
    
    /**
     * Retrieves the DM data associated with given formatted value context.
     * @param dmc Context to retrieve the value for.
     * @param rm Completion monitor returns the formatted value.
     */
    public void getFormattedExpressionValue(FormattedValueDMContext dmc, DataRequestMonitor<FormattedValueDMData> rm); 

    
    /**
     * DMC that represents a value with specific format.  The format ID can be
     * persisted and used for comparison. 
     */

    public static class FormattedValueDMContext extends AbstractDMContext 
    {
        private final String fFormatID;
        
        public FormattedValueDMContext(IDMService service, IDMContext parent, String formatId) {
            super(service, new IDMContext[] { parent });
            fFormatID = formatId;
        }

        public FormattedValueDMContext(String sessionId, IDMContext parent, String formatId) {
            super(sessionId, new IDMContext[] { parent });
            fFormatID = formatId;
        }
        
        public String getFormatID() {
            return fFormatID;
        }
        
        @Override
        public boolean equals(Object obj) {
            return baseEquals(obj) && ((FormattedValueDMContext)obj).getFormatID().equals(getFormatID());
        }

        @Override
        public int hashCode() {
            return baseHashCode() + getFormatID().hashCode();
        }
        
        @Override
        public String toString() {
            return baseToString() + ".format(" + getFormatID() + ")"; //$NON-NLS-1$ //$NON-NLS-2$
        }
    }

    public static class FormattedValueDMData implements IDMData {

        private final String fValue;
        
        public FormattedValueDMData(String value) {
            fValue = value;
        }
        
        public String getFormattedValue() {
            return fValue;
        }
        
        
    }
}

Back to the top