Class AvailableSearchManagers

java.lang.Object
edu.tufts.hrilab.vision.stm.AvailableSearchManagers

public final class AvailableSearchManagers extends Object
Factory class to manage all SearchManagers (i.e., face, teabox, cube) in the system. Contains the information needed to instantiate each SearchManager and also contains a reference to each instantiated SearchManager that has been handed out to clients. Thread-safe, although thread-safety is naively implemented with synchronized methods.
  • Constructor Details

    • AvailableSearchManagers

      public AvailableSearchManagers(String configFile)
  • Method Details

    • getAllSearchManagers

      public AbstractListModel getAllSearchManagers()
      Only to be used by GUI to get all instantiated SearchManagers.
      Returns:
    • getSimpleSearchManagers

      public AbstractListModel getSimpleSearchManagers()
      Only to be used by GUI to get all instantiate SingleSearchManagers.
      Returns:
    • updateGuiEntry

      public void updateGuiEntry(SearchManager entry)
      Used by instantiated SearchManagers to update GUI of any changes to itself.
      Parameters:
      entry -
    • getTestingInstance

      public SearchManager getTestingInstance(Object client)
      Create a new empty SimpleSearchManager. This should only be used from the GUI for debugging and testing purposes only!
      Returns:
      SearchManager
    • stopAllSearches

      public void stopAllSearches(Object caller)
      Attempt to stop all searches that are currently running. Only searches that were started by the caller can be stopped.
      Parameters:
      caller - - requesting object (usually "this")
    • restartAllStoppedSearches

      public void restartAllStoppedSearches(Object caller)
      Restart all searches that were stopped by the most recent call to stopAllSearches. This method should be thought of as a pair with stopAllSearches.
      Parameters:
      caller - - requesting object (usually "this")
    • hasExistingSearchManager

      public boolean hasExistingSearchManager(List<? extends Term> descriptors)
      Find out if a SearchManager already exists that is capable of detecting objects that meet the specified descriptors/constraints.
      Parameters:
      descriptors - - list of Terms describing search constraints
      Returns:
      - boolean
    • canCreateCapableSearchManager

      public boolean canCreateCapableSearchManager(List<? extends Term> descriptors)
      Find out if a SearchManager can be built (without actually building one) that is capable of detecting objects that meet the specified descriptors/constraints.
      Parameters:
      descriptors - - list of Terms describing search constraints
      Returns:
      - boolean
    • getUnsatisfiableConstraints

      public List<Term> getUnsatisfiableConstraints(List<? extends Term> descriptors)
      Check if there are any unsatisfiable constraints contained in the passed in descriptors/constraints.
      Parameters:
      descriptors - - list of Terms describing search constraints
      Returns:
      list of (possibly empty) descriptors/constraints
    • getInstance

      public SearchManager getInstance(Object client)
      Create a new empty SearchManager. This is useful for creating SearchManager incrementally and from the GUI. Clients must call release on a SearchManager instance when finished using it, so that SearchManager can be properly managed and garbage collected.
      Parameters:
      client - java object requesting the instance
      Returns:
      SearchManager
    • getInstance

      public SearchManager getInstance(Object client, List<? extends Term> descriptors, boolean useExistingSearches)
      Get SearchManager matching description. First tries to find an existing SearchManager. If one cannot be found, the creation of a new SearchManager is attempted. Clients must call release on a SearchManager instance when finished using it, so that SearchManager can be properly managed and garbage collected.
      Parameters:
      client - - calling object, usually "this"
      descriptors - - Predicate description of desired SearchManager
      Returns:
      SearchManager, or null if one could not be found or created
    • getInstance

      public SearchManager getInstance(Object client, long searchTypeId)
      Tries to get SearchManager with specified ID. If the SearchManager doesn't exist, null is returned. Clients must call release on a SearchManager instance when finished using it, so that SearchManager can be properly managed and garbage collected.
      Parameters:
      client -
      searchTypeId - SearchManager ID
      Returns:
      SearchManager or null
    • getAll

      public List<SearchManager> getAll()
      Get all instantiated top-level SearchManagers.
      Returns:
      List of SearchManagers
    • getTypeIds

      public List<Long> getTypeIds()
      Get IDs of all instantiated SearchManagers. The SearchManagers are not necessarily running.
      Returns:
      List of SearchManager IDs
    • addTypeName

      public void addTypeName(Long searchTypeId, Term searchTypeName)
      Name an existing SearchManager. Name does not have to be unique, and a single SearchManager can have multiple names. This is useful so that collections of predicates that describe a particular search can be named (e.g., white box with red cross can be named medkit).
      Parameters:
      searchTypeId -
      searchTypeName -
    • nameDescriptors

      public void nameDescriptors(List<? extends Term> descriptors, Term typeName)
      Name a list of descriptors. E.g., assign the list of descriptors "red(Y),cross(Y),white(X),box(X),on(Y,X)" the name "medkit(X)".
      Parameters:
      descriptors -
      typeName -
    • removeNamedDescriptors

      public void removeNamedDescriptors(List<? extends Term> descriptors, Term typeName)
      Remove a list of descriptors from the named descriptors. E.g., remove the list of descriptors "red(Y),cross(Y),white(X),box(X),on(Y,X)" from the name "medkit(X)".
      Parameters:
      descriptors -
      typeName -
    • replaceNamedDescriptors

      protected List<Term> replaceNamedDescriptors(List<? extends Term> descriptors)
      Replace descriptors that have been learned via nameDescriptors with their corresponding description. E.g., replace "medkit(X)" with "red(Y),cross(Y),white(X),box(X),on(Y,X)".
      Parameters:
      descriptors -
      Returns:
    • appendNamedDescriptors

      protected List<Term> appendNamedDescriptors(List<? extends Term> descriptors)
    • getTypeNames

      public Set<String> getTypeNames()
      Get names of all searches that have been named. Not all searches are required to be named. Performs a shallow copy.
      Returns:
      Set of Strings
    • getDefinitions

      public List<NamedDescription> getDefinitions()
      Get definition (name plus definition) of all searches that have been named. Performs a shallow copy.
      Returns:
      List of NamedDescription
    • release

      public void release(Object client, SearchManager searchType)
      Client needs to let managing factory know when it's done using a SearchManager instance, so that SearchManager can be properly managed and garbage collected.