From f066eeac977a65302a53ac65b72348ced6f8c5e1 Mon Sep 17 00:00:00 2001 From: Pavel Kulik Date: Tue, 24 Dec 2024 12:59:23 -0800 Subject: [PATCH] Add isRequired flag to PathParameter --- Source/Processors/DataThreads/DataThread.cpp | 3 ++- Source/Processors/DataThreads/DataThread.h | 1 + Source/Processors/FileReader/FileReader.cpp | 2 +- Source/Processors/GenericProcessor/GenericProcessor.cpp | 2 ++ Source/Processors/GenericProcessor/GenericProcessor.h | 1 + Source/Processors/Parameter/Parameter.cpp | 8 +++++++- Source/Processors/Parameter/Parameter.h | 2 ++ Source/Processors/RecordNode/RecordNode.cpp | 2 +- 8 files changed, 17 insertions(+), 4 deletions(-) diff --git a/Source/Processors/DataThreads/DataThread.cpp b/Source/Processors/DataThreads/DataThread.cpp index 26ff6528e..770d7eb79 100644 --- a/Source/Processors/DataThreads/DataThread.cpp +++ b/Source/Processors/DataThreads/DataThread.cpp @@ -120,9 +120,10 @@ void DataThread::addPathParameter (Parameter::ParameterScope scope, const String& defaultValue, const StringArray& validFileExtensions, bool isDirectory, + bool isRequired, bool deactivateDuringAcquisition) { - sn->addPathParameter (scope, name, displayName, description, defaultValue, validFileExtensions, isDirectory, deactivateDuringAcquisition); + sn->addPathParameter (scope, name, displayName, description, defaultValue, validFileExtensions, isDirectory, isRequired, deactivateDuringAcquisition); } void DataThread::addSelectedStreamParameter (Parameter::ParameterScope scope, diff --git a/Source/Processors/DataThreads/DataThread.h b/Source/Processors/DataThreads/DataThread.h index 2b823faad..8813d109b 100755 --- a/Source/Processors/DataThreads/DataThread.h +++ b/Source/Processors/DataThreads/DataThread.h @@ -193,6 +193,7 @@ class PLUGIN_API DataThread : public Thread const String& defaultValue, const StringArray& validFileExtensions, bool isDirectory, + bool isRequired, bool deactivateDuringAcquisition = true); /** Adds a selected stream parameter which holds the currentlu selected stream */ diff --git a/Source/Processors/FileReader/FileReader.cpp b/Source/Processors/FileReader/FileReader.cpp index e28baea1c..cb8c4bb26 100644 --- a/Source/Processors/FileReader/FileReader.cpp +++ b/Source/Processors/FileReader/FileReader.cpp @@ -109,7 +109,7 @@ FileReader::~FileReader() void FileReader::registerParameters() { /* Add parameters */ - addPathParameter (Parameter::PROCESSOR_SCOPE, "selected_file", "Selected File", "File to load data from", defaultFile, getSupportedExtensions(), false); + addPathParameter (Parameter::PROCESSOR_SCOPE, "selected_file", "Selected File", "File to load data from", defaultFile, getSupportedExtensions(), false, true); addSelectedStreamParameter (Parameter::PROCESSOR_SCOPE, "active_stream", "Active Stream", "Currently active stream", {}, 0); addTimeParameter (Parameter::PROCESSOR_SCOPE, "start_time", "Start Time", "Time to start playback"); addTimeParameter (Parameter::PROCESSOR_SCOPE, "end_time", "Stop Time", "Time to end playback"); diff --git a/Source/Processors/GenericProcessor/GenericProcessor.cpp b/Source/Processors/GenericProcessor/GenericProcessor.cpp index 531fdcb7e..54fbeebdc 100755 --- a/Source/Processors/GenericProcessor/GenericProcessor.cpp +++ b/Source/Processors/GenericProcessor/GenericProcessor.cpp @@ -422,6 +422,7 @@ void GenericProcessor::addPathParameter ( const File& defaultValue, const StringArray& validFileExtensions, bool isDirectory, + bool isRequired, bool deactivateDuringAcquisition) { PathParameter* p = @@ -433,6 +434,7 @@ void GenericProcessor::addPathParameter ( defaultValue, validFileExtensions, isDirectory, + isRequired, deactivateDuringAcquisition); if (scope == Parameter::PROCESSOR_SCOPE) diff --git a/Source/Processors/GenericProcessor/GenericProcessor.h b/Source/Processors/GenericProcessor/GenericProcessor.h index 72024af7f..41ae2ae48 100755 --- a/Source/Processors/GenericProcessor/GenericProcessor.h +++ b/Source/Processors/GenericProcessor/GenericProcessor.h @@ -377,6 +377,7 @@ class PLUGIN_API GenericProcessor : public GenericProcessorBase, public PluginCl const File& defaultValue, const StringArray& validFileExtensions, bool isDirectory, + bool isRequired, bool deactivateDuringAcquisition = true); /** Adds a selected stream parameter which holds the currentlu selected stream */ diff --git a/Source/Processors/Parameter/Parameter.cpp b/Source/Processors/Parameter/Parameter.cpp index 1b976e8fa..6b3e3fc37 100755 --- a/Source/Processors/Parameter/Parameter.cpp +++ b/Source/Processors/Parameter/Parameter.cpp @@ -1184,6 +1184,7 @@ PathParameter::PathParameter (ParameterOwner* owner, const File& defaultValue_, const StringArray& fileExtensions_, bool isDirectory_, + bool isRequired_, bool deactivateDuringAcquisition) : Parameter (owner, ParameterType::PATH_PARAM, @@ -1194,7 +1195,8 @@ PathParameter::PathParameter (ParameterOwner* owner, defaultValue_.getFullPathName(), deactivateDuringAcquisition), filePatternsAllowed (fileExtensions_), - isDirectory (isDirectory_) + isDirectory (isDirectory_), + isRequired (isRequired_) { currentValue = defaultValue; } @@ -1257,6 +1259,10 @@ bool PathParameter::isValid() { return true; } + else if (! isRequired) + { + return true; + } return false; } diff --git a/Source/Processors/Parameter/Parameter.h b/Source/Processors/Parameter/Parameter.h index ee2d528a8..604ab66fc 100755 --- a/Source/Processors/Parameter/Parameter.h +++ b/Source/Processors/Parameter/Parameter.h @@ -883,6 +883,7 @@ class PLUGIN_API PathParameter : public Parameter const File& defaultValue, const StringArray& filePatternsAllowed, const bool isDirectory, + const bool isRequired = true, bool deactivateDuringAcquisition = true); /** Sets the current value*/ @@ -912,6 +913,7 @@ class PLUGIN_API PathParameter : public Parameter private: StringArray filePatternsAllowed; bool isDirectory; + bool isRequired; }; /** diff --git a/Source/Processors/RecordNode/RecordNode.cpp b/Source/Processors/RecordNode/RecordNode.cpp index 8c0f1be88..7821111b0 100755 --- a/Source/Processors/RecordNode/RecordNode.cpp +++ b/Source/Processors/RecordNode/RecordNode.cpp @@ -106,7 +106,7 @@ RecordNode::~RecordNode() void RecordNode::registerParameters() { String defaultRecordDirectory = CoreServices::getRecordingParentDirectory().getFullPathName(); - addPathParameter (Parameter::PROCESSOR_SCOPE, "directory", "Directory", "Path to write data to", defaultRecordDirectory, {}, true); + addPathParameter (Parameter::PROCESSOR_SCOPE, "directory", "Directory", "Path to write data to", defaultRecordDirectory, {}, true, true); Array recordEngines; std::vector engines = getAvailableRecordEngines();