Files
VisualSapfor/src/Visual_DVM_2021/Passes/All/AddMachine.java

61 lines
1.9 KiB
Java
Raw Normal View History

package Visual_DVM_2021.Passes.All;
2023-09-17 22:13:42 +03:00
import Common.Database.Database;
import Common.Utils.CommonUtils;
2024-10-09 22:21:57 +03:00
import _VisualDVM.GlobalData.Compiler.Compiler;
import _VisualDVM.GlobalData.Compiler.CompilerType;
import _VisualDVM.GlobalData.GlobalDatabase;
import _VisualDVM.GlobalData.Machine.Machine;
import _VisualDVM.GlobalData.Machine.MachineType;
import _VisualDVM.GlobalData.User.User;
import Visual_DVM_2021.Passes.AddObjectPass;
2023-09-17 22:13:42 +03:00
public class AddMachine extends AddObjectPass<Machine> {
public AddMachine() {
super(Machine.class);
}
@Override
protected Database getDb() {
return CommonUtils.db;
2023-09-17 22:13:42 +03:00
}
@Override
protected boolean canStart(Object... args) throws Exception {
if (super.canStart(args)) {
if (target.type.equals(MachineType.Local) && ((GlobalDatabase)CommonUtils.db).machines.LocalMachineExists()) {
2023-09-17 22:13:42 +03:00
Log.Writeln_("Локальная машина уже добавлена.");
return false;
}
return true;
}
return false;
}
@Override
protected void performDone() throws Exception {
super.performDone();
getDb().Insert(new Compiler(
target,
"gfortran",
CompilerType.gnu,
"gfortran",
"--version",
"--help"
));
getDb().Insert(new Compiler(
target,
"gcc",
CompilerType.gnu,
"gcc",
"--version",
"--help"
));
getDb().Insert(new Compiler(
target,
"g++",
CompilerType.gnu,
"g++",
"--version",
"--help"
));
if (target.type.equals(MachineType.Local))
getDb().Insert(new User(target, "этот пользователь", ""));
}
}