Package edu.tufts.hrilab.vision.stm
Class AvailableSearchManagers
java.lang.Object
edu.tufts.hrilab.vision.stm.AvailableSearchManagers
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addTypeName
(Long searchTypeId, Term searchTypeName) Name an existing SearchManager.appendNamedDescriptors
(List<? extends Term> descriptors) 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.getAll()
Get all instantiated top-level SearchManagers.Only to be used by GUI to get all instantiated SearchManagers.Get definition (name plus definition) of all searches that have been named.getInstance
(Object client) Create a new empty SearchManager.getInstance
(Object client, long searchTypeId) Tries to get SearchManager with specified ID.getInstance
(Object client, List<? extends Term> descriptors, boolean useExistingSearches) Get SearchManager matching description.Only to be used by GUI to get all instantiate SingleSearchManagers.getTestingInstance
(Object client) Create a new empty SimpleSearchManager.Get IDs of all instantiated SearchManagers.Get names of all searches that have been named.getUnsatisfiableConstraints
(List<? extends Term> descriptors) Check if there are any unsatisfiable constraints contained in the passed in descriptors/constraints.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.void
nameDescriptors
(List<? extends Term> descriptors, Term typeName) Name a list of descriptors.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.void
removeNamedDescriptors
(List<? extends Term> descriptors, Term typeName) Remove a list of descriptors from the named descriptors.replaceNamedDescriptors
(List<? extends Term> descriptors) Replace descriptors that have been learned via nameDescriptors with their corresponding description.void
restartAllStoppedSearches
(Object caller) Restart all searches that were stopped by the most recent call to stopAllSearches.void
stopAllSearches
(Object caller) Attempt to stop all searches that are currently running.void
updateGuiEntry
(SearchManager entry) Used by instantiated SearchManagers to update GUI of any changes to itself.
-
Constructor Details
-
AvailableSearchManagers
-
-
Method Details
-
getAllSearchManagers
Only to be used by GUI to get all instantiated SearchManagers.- Returns:
-
getSimpleSearchManagers
Only to be used by GUI to get all instantiate SingleSearchManagers.- Returns:
-
updateGuiEntry
Used by instantiated SearchManagers to update GUI of any changes to itself.- Parameters:
entry
-
-
getTestingInstance
Create a new empty SimpleSearchManager. This should only be used from the GUI for debugging and testing purposes only!- Returns:
- SearchManager
-
stopAllSearches
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
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
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
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
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
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
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
Get all instantiated top-level SearchManagers.- Returns:
- List of SearchManagers
-
getTypeIds
Get IDs of all instantiated SearchManagers. The SearchManagers are not necessarily running.- Returns:
- List of SearchManager IDs
-
addTypeName
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
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
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
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
-
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
Get definition (name plus definition) of all searches that have been named. Performs a shallow copy.- Returns:
- List of NamedDescription
-
release
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.
-