1
0
mirror of https://github.com/DanilaFe/abacus synced 2024-12-22 07:20:09 -08:00

Add registering TreeValueOperators.

This commit is contained in:
Danila Fedorin 2017-08-25 17:31:47 -07:00
parent 5b1a48c02e
commit 73075c57b9
2 changed files with 60 additions and 0 deletions

View File

@ -89,6 +89,18 @@ public abstract class Plugin {
manager.registerOperator(name, operator); manager.registerOperator(name, operator);
} }
/**
* To be used in load(). Registers an operator
* with the plugin internally, which makes it accessible
* to the plugin manager.
*
* @param name the name of the tree value operator.
* @param operator the tree value operator to register.
*/
protected final void registerTreeValueOperator(String name, TreeValueOperator operator){
manager.registerTreeValueOperator(name, operator);
}
/** /**
* To be used in load(). Registers a new number implementation with the plugin. * To be used in load(). Registers a new number implementation with the plugin.
* This makes it accessible to the plugin manager. * This makes it accessible to the plugin manager.
@ -146,6 +158,18 @@ public abstract class Plugin {
return manager.operatorFor(name); return manager.operatorFor(name);
} }
/**
* Searches the PluginManager for the given tree value operator name.
* This can be used by the plugins internally in order to call
* operations they do not provide.
*
* @param name the name for which to search.
* @return the resulting tree value operator, or null if none was found for that name.
*/
protected final TreeValueOperator treeValueOperatorFor(String name) {
return manager.treeValueOperatorFor(name);
}
/** /**
* Searches the PluginManager for the given number implementation * Searches the PluginManager for the given number implementation
* name. This can be used by the plugins internally in order to find * name. This can be used by the plugins internally in order to find

View File

@ -36,6 +36,10 @@ public class PluginManager {
* The map of operators registered by the plugins * The map of operators registered by the plugins
*/ */
private Map<String, NumberOperator> registeredOperators; private Map<String, NumberOperator> registeredOperators;
/**
* The map of tree value operators registered by the plugins.
*/
private Map<String, TreeValueOperator> registeredTreeValueOperators;
/** /**
* The map of number implementations registered by the plugins. * The map of number implementations registered by the plugins.
*/ */
@ -75,6 +79,7 @@ public class PluginManager {
registeredFunctions = new HashMap<>(); registeredFunctions = new HashMap<>();
registeredTreeValueFunctions = new HashMap<>(); registeredTreeValueFunctions = new HashMap<>();
registeredOperators = new HashMap<>(); registeredOperators = new HashMap<>();
registeredTreeValueOperators = new HashMap<>();
registeredNumberImplementations = new HashMap<>(); registeredNumberImplementations = new HashMap<>();
registeredDocumentation = new HashSet<>(); registeredDocumentation = new HashSet<>();
cachedInterfaceImplementations = new HashMap<>(); cachedInterfaceImplementations = new HashMap<>();
@ -112,6 +117,16 @@ public class PluginManager {
registeredOperators.put(name, operator); registeredOperators.put(name, operator);
} }
/**
* Registers a tree value operator under the given name.
*
* @param name the name of the tree value operator.
* @param operator the tree value operator to register.
*/
public void registerTreeValueOperator(String name, TreeValueOperator operator){
registeredTreeValueOperators.put(name, operator);
}
/** /**
* Registers a number implementation under the given name. * Registers a number implementation under the given name.
* *
@ -162,6 +177,16 @@ public class PluginManager {
return registeredOperators.get(name); return registeredOperators.get(name);
} }
/**
* Gets the tree value operator registered under the given name.
*
* @param name the name of the tree value operator.
* @return the operator, or null if it was not found.
*/
public TreeValueOperator treeValueOperatorFor(String name) {
return registeredTreeValueOperators.get(name);
}
/** /**
* Gets the number implementation registered under the given name. * Gets the number implementation registered under the given name.
* *
@ -299,7 +324,9 @@ public class PluginManager {
plugin.disable(); plugin.disable();
} }
registeredFunctions.clear(); registeredFunctions.clear();
registeredTreeValueFunctions.clear();
registeredOperators.clear(); registeredOperators.clear();
registeredTreeValueOperators.clear();
registeredNumberImplementations.clear(); registeredNumberImplementations.clear();
registeredDocumentation.clear(); registeredDocumentation.clear();
cachedInterfaceImplementations.clear(); cachedInterfaceImplementations.clear();
@ -342,6 +369,15 @@ public class PluginManager {
return registeredOperators.keySet(); return registeredOperators.keySet();
} }
/**
* Gets all the tree value operators loaded by the PluginManager.
*
* @return the set of all tree value operators that were loaded.
*/
public Set<String> getAllTreeValueOperators(){
return registeredTreeValueOperators.keySet();
}
/** /**
* Gets all the number implementations loaded by the Plugin Manager. * Gets all the number implementations loaded by the Plugin Manager.
* *