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

Add a registered documentation set.

This commit is contained in:
Danila Fedorin 2017-08-08 11:09:46 -07:00
parent ea5ff08c09
commit 61f40c72aa

View File

@ -1,6 +1,8 @@
package org.nwapw.abacus.plugin; package org.nwapw.abacus.plugin;
import org.nwapw.abacus.Abacus; import org.nwapw.abacus.Abacus;
import org.nwapw.abacus.function.Documentation;
import org.nwapw.abacus.function.DocumentationType;
import org.nwapw.abacus.function.Function; import org.nwapw.abacus.function.Function;
import org.nwapw.abacus.function.Operator; import org.nwapw.abacus.function.Operator;
import org.nwapw.abacus.number.NumberInterface; import org.nwapw.abacus.number.NumberInterface;
@ -34,6 +36,10 @@ public class PluginManager {
* The map of number implementations registered by the plugins. * The map of number implementations registered by the plugins.
*/ */
private Map<String, NumberImplementation> registeredNumberImplementations; private Map<String, NumberImplementation> registeredNumberImplementations;
/**
* The map of documentation for functions registered by the plugins.
*/
private Set<Documentation> registeredDocumentation;
/** /**
* The list of number implementations that have been * The list of number implementations that have been
* found by their implementation class. * found by their implementation class.
@ -65,6 +71,7 @@ public class PluginManager {
registeredFunctions = new HashMap<>(); registeredFunctions = new HashMap<>();
registeredOperators = new HashMap<>(); registeredOperators = new HashMap<>();
registeredNumberImplementations = new HashMap<>(); registeredNumberImplementations = new HashMap<>();
registeredDocumentation = new HashSet<>();
cachedInterfaceImplementations = new HashMap<>(); cachedInterfaceImplementations = new HashMap<>();
cachedPi = new HashMap<>(); cachedPi = new HashMap<>();
listeners = new HashSet<>(); listeners = new HashSet<>();
@ -97,6 +104,15 @@ public class PluginManager {
registeredNumberImplementations.put(name, implementation); registeredNumberImplementations.put(name, implementation);
} }
/**
* Registers the given documentation with the plugin manager,
* making it accessible to the plugin manager etc.
* @param documentation the documentation to register.
*/
public void registerDocumentation(Documentation documentation){
registeredDocumentation.add(documentation);
}
/** /**
* Gets the function registered under the given name. * Gets the function registered under the given name.
* @param name the name of the function. * @param name the name of the function.
@ -124,6 +140,19 @@ public class PluginManager {
return registeredNumberImplementations.get(name); return registeredNumberImplementations.get(name);
} }
/**
* Gets the documentation for the given entity of the given type.
* @param name the name of the entity to search for.
* @param type the type that this entity is, to filter out similarly named documentation.
* @return the documentation object.
*/
public Documentation documentationFor(String name, DocumentationType type){
for(Documentation entry : registeredDocumentation){
if(entry.getCodeName().equals(name) && entry.getType() == type) return entry;
}
return null;
}
/** /**
* Gets the number implementation for the given implementation class. * Gets the number implementation for the given implementation class.
* *
@ -212,6 +241,7 @@ public class PluginManager {
registeredFunctions.clear(); registeredFunctions.clear();
registeredOperators.clear(); registeredOperators.clear();
registeredNumberImplementations.clear(); registeredNumberImplementations.clear();
registeredDocumentation.clear();
cachedInterfaceImplementations.clear(); cachedInterfaceImplementations.clear();
cachedPi.clear(); cachedPi.clear();
listeners.forEach(e -> e.onUnload(this)); listeners.forEach(e -> e.onUnload(this));