Commit 90f9b0b7 authored by Malte Heithoff's avatar Malte Heithoff
Browse files

Move logic isUsed CV to ConversionHelper

parent 1fb09a32
......@@ -8,6 +8,7 @@ import de.monticore.lang.monticar.generator.FileContent;
*/
public class ConversionHelper {
public static String fileName = "ConvHelper";
private static boolean usedCV = false;
public static FileContent getConversionHelperFileContent(boolean generateTests) {
FileContent fileContent = new FileContent();
......@@ -21,4 +22,16 @@ public class ConversionHelper {
public static FileContent getConversionHelperFileContent(){
return getConversionHelperFileContent(false);
}
public static boolean isUsedCV() {
return usedCV;
}
public static void setUsedCV() {
usedCV = true;
}
public static void unsetUsedCV() {
usedCV = false;
}
}
......@@ -308,9 +308,9 @@ public class GeneratorCPP implements EMAMGenerator {
fileContents.add(OctaveHelper.getOctaveHelperFileContent());
if (MathConverter.curBackend.getBackendName().equals("ArmadilloBackend")) {
fileContents.add(ArmadilloHelper.getArmadilloHelperFileContent(isGenerateTests));
if (EMAMBluePrintCPP.usedCV) {
if (ConversionHelper.isUsedCV()) {
fileContents.add(ConversionHelper.getConversionHelperFileContent(isGenerateTests));
EMAMBluePrintCPP.usedCV = false;
ConversionHelper.unsetUsedCV();
}
}
if (shouldGenerateMainClass()) {
......
......@@ -68,5 +68,6 @@ public class BoundingRectCommand extends MathCommand{
bluePrintCPP.getGenerator().getCmakeConfig()
.addModuleDependency(new CMakeFindModule("OpenCV", true).asFindAsPackage());
ConversionHelper.setUsedCV();
}
}
......@@ -70,6 +70,7 @@ public class CvtColorCommand extends ArgumentNoReturnMathCommand{
bluePrintCPP.getGenerator().getCmakeConfig()
.addModuleDependency(new CMakeFindModule("OpenCV", true).asFindAsPackage());
ConversionHelper.setUsedCV();
}
private Method getCvtColorHelperMethod(MathMatrixNameExpressionSymbol mathMatrixNameExpressionSymbol, EMAMBluePrintCPP bluePrintCPP, MathExpressionProperties properties){
......
......@@ -69,6 +69,9 @@ public class DilateCommand extends ArgumentNoReturnMathCommand{
redefineInit(bluePrintCPP);
bluePrintCPP.getGenerator().getCmakeConfig()
.addModuleDependency(new CMakeFindModule("OpenCV", true).asFindAsPackage());
bluePrintCPP.addAdditionalNameSpaceStrings("std");
ConversionHelper.setUsedCV();
}
private Method getDilateHelperMethod(MathMatrixNameExpressionSymbol mathMatrixNameExpressionSymbol, EMAMBluePrintCPP bluePrintCPP, MathExpressionProperties properties){
......
......@@ -72,6 +72,7 @@ public class ErodeCommand extends ArgumentNoReturnMathCommand{
bluePrintCPP.getGenerator().getCmakeConfig()
.addModuleDependency(new CMakeFindModule("OpenCV", true).asFindAsPackage());
ConversionHelper.setUsedCV();
}
private Method getErodeHelperMethod(MathMatrixNameExpressionSymbol mathMatrixNameExpressionSymbol, EMAMBluePrintCPP bluePrintCPP, MathExpressionProperties properties){
......
......@@ -71,6 +71,7 @@ public class FindContoursCommand extends ArgumentNoReturnMathCommand{
bluePrintCPP.getGenerator().getCmakeConfig()
.addModuleDependency(new CMakeFindModule("OpenCV", true).asFindAsPackage());
ConversionHelper.setUsedCV();
}
private Method getFindContoursHelperMethod(MathMatrixNameExpressionSymbol mathMatrixNameExpressionSymbol, EMAMBluePrintCPP bluePrintCPP, MathExpressionProperties properties){
......
......@@ -69,6 +69,9 @@ public class GaussianBlurCommand extends ArgumentNoReturnMathCommand{
redefineInit(bluePrintCPP);
bluePrintCPP.getGenerator().getCmakeConfig()
.addModuleDependency(new CMakeFindModule("OpenCV", true).asFindAsPackage());
bluePrintCPP.addAdditionalNameSpaceStrings("std");
ConversionHelper.setUsedCV();
}
private Method getGaussianBlurHelperMethod(MathMatrixNameExpressionSymbol mathMatrixNameExpressionSymbol, EMAMBluePrintCPP bluePrintCPP, MathExpressionProperties properties){
......
......@@ -70,6 +70,7 @@ public class InRangeCommand extends ArgumentNoReturnMathCommand{
bluePrintCPP.getGenerator().getCmakeConfig()
.addModuleDependency(new CMakeFindModule("OpenCV", true).asFindAsPackage());
ConversionHelper.setUsedCV();
}
private Method getInRangeHelperMethod(MathMatrixNameExpressionSymbol mathMatrixNameExpressionSymbol, EMAMBluePrintCPP bluePrintCPP, MathExpressionProperties properties){
......
......@@ -69,6 +69,7 @@ public class LargestContourCommand extends MathCommand {
bluePrintCPP.getGenerator().getCmakeConfig()
.addModuleDependency(new CMakeFindModule("OpenCV", true).asFindAsPackage());
ConversionHelper.setUsedCV();
}
private Method getLargestContourMethod(){
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment