Class FunctionComparisonModel


  • public class FunctionComparisonModel
    extends java.lang.Object
    A collection of function comparison objects that describe how functions may be compared. Each comparison object is a mapping of a function (source) to a list of functions (targets).

    This model is intended to be used by the FunctionComparisonProvider as the basis for its display. It should never be created manually, and should only be accessed via the FunctionComparisonService.

    Note: Subscribers may register to be informed of changes to this model via the comparison model listener interface.

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addComparison​(ghidra.app.plugin.core.functioncompare.FunctionComparison comparison)
      Adds a single comparison to the model
      void addFunctionComparisonModelListener​(ghidra.app.plugin.core.functioncompare.FunctionComparisonModelListener listener)
      Adds the given subscriber to the list of those to be notified of model changes
      void compareFunctions​(Function source, Function target)
      Compares two functions.
      void compareFunctions​(java.util.Set<Function> functions)
      Updates the model with a set of functions to compare.
      java.util.List<ghidra.app.plugin.core.functioncompare.FunctionComparison> getComparisons()
      Returns a list of all comparisons in the model, in sorted order by source function name
      java.util.Set<Function> getSourceFunctions()
      Returns all source functions in the model
      java.util.Set<Function> getTargetFunctions()
      Returns all target functions in the model
      java.util.Set<Function> getTargetFunctions​(Function source)
      Returns a set of all target functions for a given source
      java.util.Set<Function> getTargets​(Function source)
      Returns a list of all targets in the model (across all comparisons) for a given source function
      void removeFunction​(Function function)
      Removes the given function from all comparisons in the model, whether stored as a source or target
      void removeFunctions​(Program program)
      Removes all functions in the model that come from the given program
      void setComparisons​(java.util.List<ghidra.app.plugin.core.functioncompare.FunctionComparison> comparisons)
      Replaces the current model with the comparisons provided
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • FunctionComparisonModel

        public FunctionComparisonModel()
    • Method Detail

      • addFunctionComparisonModelListener

        public void addFunctionComparisonModelListener​(ghidra.app.plugin.core.functioncompare.FunctionComparisonModelListener listener)
        Adds the given subscriber to the list of those to be notified of model changes
        Parameters:
        listener - the model change subscriber
      • getComparisons

        public java.util.List<ghidra.app.plugin.core.functioncompare.FunctionComparison> getComparisons()
        Returns a list of all comparisons in the model, in sorted order by source function name
        Returns:
        a list of all comparisons in the model
      • setComparisons

        public void setComparisons​(java.util.List<ghidra.app.plugin.core.functioncompare.FunctionComparison> comparisons)
        Replaces the current model with the comparisons provided
        Parameters:
        comparisons - the new comparison model
      • addComparison

        public void addComparison​(ghidra.app.plugin.core.functioncompare.FunctionComparison comparison)
        Adds a single comparison to the model
        Parameters:
        comparison - the comparison to add
      • getTargets

        public java.util.Set<Function> getTargets​(Function source)
        Returns a list of all targets in the model (across all comparisons) for a given source function
        Parameters:
        source - the source function
        Returns:
        list of associated target functions
      • compareFunctions

        public void compareFunctions​(java.util.Set<Function> functions)
        Updates the model with a set of functions to compare. This will add the functions to any existing comparisons in the model and create new comparisons for functions not represented.

        Note: It is assumed that when using this method, all functions can be compared with all other functions; meaning each function will be added as both a source AND a target. To specify a specific source/target relationship, use compareFunctions(Function, Function).

        Parameters:
        functions - the set of functions to compare
      • compareFunctions

        public void compareFunctions​(Function source,
                                     Function target)
        Compares two functions. If a comparison already exists in the model for the given source, the target will simply be added to it; otherwise a new comparison will be created.
        Parameters:
        source - the source function
        target - the target function
      • removeFunction

        public void removeFunction​(Function function)
        Removes the given function from all comparisons in the model, whether stored as a source or target
        Parameters:
        function - the function to remove
      • removeFunctions

        public void removeFunctions​(Program program)
        Removes all functions in the model that come from the given program
        Parameters:
        program - the program to remove functions from
      • getSourceFunctions

        public java.util.Set<Function> getSourceFunctions()
        Returns all source functions in the model
        Returns:
        a set of all source functions
      • getTargetFunctions

        public java.util.Set<Function> getTargetFunctions()
        Returns all target functions in the model
        Returns:
        a set of all target functions
      • getTargetFunctions

        public java.util.Set<Function> getTargetFunctions​(Function source)
        Returns a set of all target functions for a given source
        Parameters:
        source - the source function to search for
        Returns:
        the set of associated target functions