diff --git a/.clang-format b/.clang-format index 15a8040..ba05ad6 100644 --- a/.clang-format +++ b/.clang-format @@ -1,10 +1,27 @@ +--- BasedOnStyle: Google + IndentWidth: 4 -TabWidth: 4 AccessModifierOffset: -3 -UseTab: Never -SortIncludes: Never ColumnLimit: 120 -AllowShortFunctionsOnASingleLine: Empty + PointerAlignment: Right -BreakConstructorInitializers: AfterColon +DerivePointerAlignment: false + +AllowShortBlocksOnASingleLine: Empty +AllowShortFunctionsOnASingleLine: Inline +AllowShortIfStatementsOnASingleLine: WithoutElse + +BreakStringLiterals: false +ReflowComments: false + +SpaceAfterTemplateKeyword: false + +SortIncludes: Never +IncludeBlocks: Preserve + +AlignConsecutiveMacros: Consecutive + +BinPackParameters: false +BinPackArguments: false +... diff --git a/.clang-format-ignore b/.clang-format-ignore new file mode 100644 index 0000000..7526d71 --- /dev/null +++ b/.clang-format-ignore @@ -0,0 +1 @@ +src/scope/command-line/parsing/options.hpp diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index e489f8b..8097d82 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -5,5 +5,22 @@ "workspaceFolder": "/workspace", "overrideCommand": true, "postCreateCommand": "git config --global user.name \"${GIT_AUTHOR_NAME:-Your Name}\" && git config --global user.email \"${GIT_AUTHOR_EMAIL:-you@example.com}\" && /workspace/build.sh cmake", - "shutdownAction": "stopCompose" + "shutdownAction": "stopCompose", + "customizations": { + "vscode": { + "extensions": [ + "twxs.cmake", + "ms-vscode.cpptools" + ], + "settings": { + "[cpp]": { + "editor.defaultFormatter": "ms-vscode.cpptools", + "editor.formatOnSave": true, + "editor.formatOnSaveMode": "modifications" + }, + "C_Cpp.formatting": "clangFormat", + "C_Cpp.clang_format_style": "file" + } + } + } } \ No newline at end of file diff --git a/src/scope/command-line/execution/executors.cpp b/src/scope/command-line/execution/executors.cpp index f2edb85..5a7177a 100644 --- a/src/scope/command-line/execution/executors.cpp +++ b/src/scope/command-line/execution/executors.cpp @@ -13,11 +13,11 @@ namespace scope { -PrimaryScopePipelineExecutor::PrimaryScopePipelineExecutor( - RecalibrationOptions &&options, std::unique_ptr noiseFilterAlgorithm, - std::unique_ptr starCentroidAlgorithm, - std::unique_ptr optimizationAlgorithm) : - options_(std::move(options)) { +PrimaryScopePipelineExecutor::PrimaryScopePipelineExecutor(RecalibrationOptions &&options, + std::unique_ptr noiseFilterAlgorithm, + std::unique_ptr starCentroidAlgorithm, + std::unique_ptr optimizationAlgorithm) + : options_(std::move(options)) { // TODO: change inputs + outputs of stages to actual values we will use std::unique_ptr> noiseFilterStage(std::move(noiseFilterAlgorithm)); std::unique_ptr>> starCentroidStage( diff --git a/src/scope/command-line/parsing/options.hpp b/src/scope/command-line/parsing/options.hpp index 3c8fbf1..6dfdf31 100644 --- a/src/scope/command-line/parsing/options.hpp +++ b/src/scope/command-line/parsing/options.hpp @@ -37,9 +37,7 @@ SCOPE_CLI_OPTION("input-images", scope::Images, images, {}, scope::strtoimages(o /** Parsed CLI options driving a recalibration run. */ class RecalibrationOptions { public: -#define SCOPE_CLI_OPTION(name, type, prop, defaultVal, converter, defaultArg, \ - ASSIGN, doc) \ - type prop = defaultVal; +#define SCOPE_CLI_OPTION(name, type, prop, defaultVal, converter, defaultArg, ASSIGN, doc) type prop = defaultVal; RECALIBRATE #undef SCOPE_CLI_OPTION }; diff --git a/src/scope/command-line/parsing/parser.cpp b/src/scope/command-line/parsing/parser.cpp index d6e795a..f26d57a 100644 --- a/src/scope/command-line/parsing/parser.cpp +++ b/src/scope/command-line/parsing/parser.cpp @@ -8,18 +8,17 @@ int optind = 2; -#define OPTIONAL_OPTARG() \ - ((optarg == NULL && optind < argc && argv[optind][0] != '-') \ - ? static_cast(optarg = argv[optind++]) \ - : (optarg != NULL)) +#define OPTIONAL_OPTARG() \ + ((optarg == NULL && optind < argc && argv[optind][0] != '-') ? static_cast(optarg = argv[optind++]) \ + : (optarg != NULL)) #define REQ_ASSIGN(options, prop, value, default) options.prop = (value); -#define OPT_ASSIGN(options, prop, value, default) \ - if (OPTIONAL_OPTARG()) { \ - options.prop = value; \ - } else { \ - options.prop = default; \ +#define OPT_ASSIGN(options, prop, value, default) \ + if (OPTIONAL_OPTARG()) { \ + options.prop = value; \ + } else { \ + options.prop = default; \ } namespace scope { @@ -31,19 +30,17 @@ RecalibrationOptions ParseRecalibrationOptions(int argc, char **argv) { // Each block below re-expands RECALIBRATE to derive a piece of getopt // wiring from the option table in options.hpp. enum class ClientOption { -#define SCOPE_CLI_OPTION(name, type, prop, defaultVal, converter, defaultArg, \ - ASSIGN, doc) \ - prop, +#define SCOPE_CLI_OPTION(name, type, prop, defaultVal, converter, defaultArg, ASSIGN, doc) prop, RECALIBRATE #undef SCOPE_CLI_OPTION }; static option long_options[] = { -#define SCOPE_CLI_OPTION(name, type, prop, defaultVal, converter, defaultArg, \ - ASSIGN, doc) \ - {name, \ - defaultArg == kNoDefaultArgument ? required_argument : optional_argument, \ - 0, static_cast(ClientOption::prop)}, +#define SCOPE_CLI_OPTION(name, type, prop, defaultVal, converter, defaultArg, ASSIGN, doc) \ + {name, \ + defaultArg == kNoDefaultArgument ? required_argument : optional_argument, \ + 0, \ + static_cast(ClientOption::prop)}, RECALIBRATE #undef SCOPE_CLI_OPTION {0}}; @@ -54,17 +51,16 @@ RecalibrationOptions ParseRecalibrationOptions(int argc, char **argv) { while ((option = getopt_long(argc, argv, "", long_options, &index)) != -1) { switch (option) { -#define SCOPE_CLI_OPTION(name, type, prop, defaultVal, converter, defaultArg, \ - ASSIGN, doc) \ - case static_cast(ClientOption::prop): \ - ASSIGN(options, prop, converter, defaultArg) \ +#define SCOPE_CLI_OPTION(name, type, prop, defaultVal, converter, defaultArg, ASSIGN, doc) \ + case static_cast(ClientOption::prop): \ + ASSIGN(options, prop, converter, defaultArg) \ break; RECALIBRATE #undef SCOPE_CLI_OPTION - default: - LOG_ERROR("Illegal flag detected. " << HELP_MSG); - exit(EXIT_FAILURE); - break; + default: + LOG_ERROR("Illegal flag detected. " << HELP_MSG); + exit(EXIT_FAILURE); + break; } } diff --git a/src/scope/command-line/scope-main.cpp b/src/scope/command-line/scope-main.cpp index ca42702..24092ef 100644 --- a/src/scope/command-line/scope-main.cpp +++ b/src/scope/command-line/scope-main.cpp @@ -15,18 +15,15 @@ namespace scope { namespace { void PrintHelp() { - std::cout << "Usage: ./scope