+ Added benchmark find command and internal structure
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
package core.benchmark;
|
||||
|
||||
import java.util.HashMap;
|
||||
import commands.benchmark.*;
|
||||
|
||||
// Based on general core structure, this registers sub-commands and keeps tabs on them.
|
||||
public class BenchmarkFramework
|
||||
{
|
||||
// Variables
|
||||
public HashMap<String, BenchmarkCommand> benchmarkCommand;
|
||||
public BenchmarkManager benchmarkManager;
|
||||
|
||||
// Constructor and command registration
|
||||
public BenchmarkFramework()
|
||||
{
|
||||
this.benchmarkManager = new BenchmarkManager();
|
||||
this.benchmarkCommand = new HashMap<String, BenchmarkCommand>();
|
||||
|
||||
RegisterCommand("find", new BenchmarkCommandFind());
|
||||
}
|
||||
|
||||
// Runs a command if possible.
|
||||
public String Run(String args)
|
||||
{
|
||||
BenchmarkInput input = new BenchmarkInput(args);
|
||||
return ExecuteCommand(input.key, input);
|
||||
}
|
||||
|
||||
// Registers a command
|
||||
private void RegisterCommand(String commandName, BenchmarkCommand command)
|
||||
{
|
||||
commandName = commandName.toLowerCase();
|
||||
if(benchmarkCommand.put(commandName, command) != null)
|
||||
BenchmarkLog.Log("Multiple registration of a command with name '" + commandName + "'!");
|
||||
|
||||
BenchmarkLog.Log("Registered " + commandName);
|
||||
}
|
||||
|
||||
// Executes a command with the specified name, and provides it with some extra input data.
|
||||
private String ExecuteCommand(String name, BenchmarkInput input)
|
||||
{
|
||||
BenchmarkCommand command = benchmarkCommand.get(name.toLowerCase());
|
||||
|
||||
if(command != null && benchmarkManager != null)
|
||||
return command.OnRun(benchmarkManager, input);
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user