From d1f51042f8afd5a6e38a23db58420cd98b0e71bf Mon Sep 17 00:00:00 2001 From: Michael Leuschel <leuschel@uni-duesseldorf.de> Date: Thu, 22 May 2025 12:52:23 +0200 Subject: [PATCH] allow optional arguments in cpp model checker Signed-off-by: Michael Leuschel <leuschel@uni-duesseldorf.de> --- .../de/hhu/stups/codegenerator/CppTemplate.stg | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/main/resources/de/hhu/stups/codegenerator/CppTemplate.stg b/src/main/resources/de/hhu/stups/codegenerator/CppTemplate.stg index a6743c3a..5ec76255 100644 --- a/src/main/resources/de/hhu/stups/codegenerator/CppTemplate.stg +++ b/src/main/resources/de/hhu/stups/codegenerator/CppTemplate.stg @@ -1732,14 +1732,14 @@ void modelCheckMultiThreaded(boost::asio::thread_pool& workers) { model_check_main_method(machine) ::= << int main(int argc, char *argv[]) { - if(argc != 4) { - cout \<\< "Number of arguments errorneous\n"; - cout \<\< "Expecting arguments: STRATEGY NR_THREADS CACHING\n"; + if(argc > 5) { + cout \<\< "Too many arguments\n"; + cout \<\< "Expecting arguments: STRATEGY NR_THREADS CACHING DEBUG\n"; return -1; } - string strategy = argv[1]; - string numberThreads = argv[2]; - string caching = argv[3]; + string strategy = (argc>=2) ? argv[1] : "mixed"; + string numberThreads = (argc>=3) ? argv[2] : "1"; + string caching = (argc>=4) ? argv[3] :"false"; <machine>::Type type; @@ -1780,7 +1780,11 @@ int main(int argc, char *argv[]) { return - 1; } - bool isDebug = false; + bool isDebug = (argc>=5 && std::string("true").compare(argv[4])) ? true : false; + + if (isDebug) { + cout \<\< "Model checking with B2Program." \<\< endl; + } ModelChecker modelchecker(type, threads, isCaching, isDebug); modelchecker.modelCheck(); -- GitLab