|
| 1 | +#include "ReadNotesFileFilter.hpp" |
| 2 | + |
| 3 | +#include "SimplnxCore/Filters/Algorithms/ReadNotesFile.hpp" |
| 4 | + |
| 5 | +#include "simplnx/DataStructure/DataPath.hpp" |
| 6 | +#include "simplnx/Filter/Actions/EmptyAction.hpp" |
| 7 | + |
| 8 | +// TODO: PARAMETER_INCLUDES |
| 9 | + |
| 10 | +#include <vector> |
| 11 | + |
| 12 | +using namespace nx::core; |
| 13 | + |
| 14 | +namespace nx::core |
| 15 | +{ |
| 16 | +//------------------------------------------------------------------------------ |
| 17 | +std::string ReadNotesFileFilter::name() const |
| 18 | +{ |
| 19 | + return FilterTraits<ReadNotesFileFilter>::name.str(); |
| 20 | +} |
| 21 | + |
| 22 | +//------------------------------------------------------------------------------ |
| 23 | +std::string ReadNotesFileFilter::className() const |
| 24 | +{ |
| 25 | + return FilterTraits<ReadNotesFileFilter>::className; |
| 26 | +} |
| 27 | + |
| 28 | +//------------------------------------------------------------------------------ |
| 29 | +Uuid ReadNotesFileFilter::uuid() const |
| 30 | +{ |
| 31 | + return FilterTraits<ReadNotesFileFilter>::uuid; |
| 32 | +} |
| 33 | + |
| 34 | +//------------------------------------------------------------------------------ |
| 35 | +std::string ReadNotesFileFilter::humanName() const |
| 36 | +{ |
| 37 | + return "@FILTER_HUMAN_NAME@"; |
| 38 | +} |
| 39 | + |
| 40 | +//------------------------------------------------------------------------------ |
| 41 | +std::vector<std::string> ReadNotesFileFilter::defaultTags() const |
| 42 | +{ |
| 43 | + return {""}; |
| 44 | +} |
| 45 | + |
| 46 | +//------------------------------------------------------------------------------ |
| 47 | +Parameters ReadNotesFileFilter::parameters() const |
| 48 | +{ |
| 49 | + Parameters params; |
| 50 | + // Create the parameter descriptors that are needed for this filter |
| 51 | + params.insertSeparator(Parameters::Separator{"Input Parameter(s)"}); |
| 52 | + |
| 53 | + /** |
| 54 | + * Please separate the parameters into groups generally of the following: |
| 55 | + * |
| 56 | + * params.insertSeparator(Parameters::Separator{"Input Parameters"}); |
| 57 | + * params.insertSeparator(Parameters::Separator{"Required Input Cell Data"}); |
| 58 | + * params.insertSeparator(Parameters::Separator{"Required Input Feature Data"}); |
| 59 | + * params.insertSeparator(Parameters::Separator{"Created Cell Data"}); |
| 60 | + * params.insertSeparator(Parameters::Separator{"Created Cell Feature Data"}); |
| 61 | + * |
| 62 | + * .. or create appropriate separators as needed. The UI in COMPLEX no longer |
| 63 | + * does this for the developer by using catgories as in SIMPL |
| 64 | + */ |
| 65 | + |
| 66 | + // Create the parameter descriptors that are needed for this filter |
| 67 | + |
| 68 | + // TODO: PARAMETER_DEFS |
| 69 | + return params; |
| 70 | +} |
| 71 | + |
| 72 | +//------------------------------------------------------------------------------ |
| 73 | +IFilter::VersionType ReadNotesFileFilter::parametersVersion() const |
| 74 | +{ |
| 75 | + return 1; |
| 76 | +} |
| 77 | + |
| 78 | +//------------------------------------------------------------------------------ |
| 79 | +IFilter::UniquePointer ReadNotesFileFilter::clone() const |
| 80 | +{ |
| 81 | + return std::make_unique<ReadNotesFileFilter>(); |
| 82 | +} |
| 83 | + |
| 84 | +//------------------------------------------------------------------------------ |
| 85 | +IFilter::PreflightResult ReadNotesFileFilter::preflightImpl(const DataStructure& dataStructure, const Arguments& filterArgs, const MessageHandler& messageHandler, const std::atomic_bool& shouldCancel, |
| 86 | + const ExecutionContext& executionContext) const |
| 87 | +{ |
| 88 | + /**************************************************************************** |
| 89 | + * Write any preflight sanity checking codes in this function |
| 90 | + ***************************************************************************/ |
| 91 | + |
| 92 | + /** |
| 93 | + * These are the values that were gathered from the UI or the pipeline file or |
| 94 | + * otherwise passed into the filter. These are here for your convenience. If you |
| 95 | + * do not need some of them remove them. |
| 96 | + */ |
| 97 | + |
| 98 | + // TODO: PREFLIGHT_DEFS |
| 99 | + |
| 100 | + // Declare the preflightResult variable that will be populated with the results |
| 101 | + // of the preflight. The PreflightResult type contains the output Actions and |
| 102 | + // any preflight updated values that you want to be displayed to the user, typically |
| 103 | + // through a user interface (UI). |
| 104 | + PreflightResult preflightResult; |
| 105 | + |
| 106 | + // If your filter is making structural changes to the DataStructure then the filter |
| 107 | + // is going to create OutputActions subclasses that need to be returned. This will |
| 108 | + // store those actions. |
| 109 | + nx::core::Result<OutputActions> resultOutputActions; |
| 110 | + |
| 111 | + // If your filter is going to pass back some `preflight updated values` then this is where you |
| 112 | + // would create the code to store those values in the appropriate object. Note that we |
| 113 | + // in line creating the pair (NOT a std::pair<>) of Key:Value that will get stored in |
| 114 | + // the std::vector<PreflightValue> object. |
| 115 | + std::vector<PreflightValue> preflightUpdatedValues; |
| 116 | + |
| 117 | + // If the filter needs to pass back some updated values via a key:value string:string set of values |
| 118 | + // you can declare and update that string here. |
| 119 | + |
| 120 | + // TODO: PREFLIGHT_UPDATED_DEFS |
| 121 | + // If this filter makes changes to the DataStructure in the form of |
| 122 | + // creating/deleting/moving/renaming DataGroups, Geometries, DataArrays then you |
| 123 | + // will need to use one of the `*Actions` classes located in complex/Filter/Actions |
| 124 | + // to relay that information to the preflight and execute methods. This is done by |
| 125 | + // creating an instance of the Action class and then storing it in the resultOutputActions variable. |
| 126 | + // This is done through a `push_back()` method combined with a `std::move()`. For the |
| 127 | + // newly initiated to `std::move` once that code is executed what was once inside the Action class |
| 128 | + // instance variable is *no longer there*. The memory has been moved. If you try to access that |
| 129 | + // variable after this line you will probably get a crash or have subtle bugs. To ensure that this |
| 130 | + // does not happen we suggest using braces `{}` to scope each of the action's declaration and store |
| 131 | + // so that the programmer is not tempted to use the action instance past where it should be used. |
| 132 | + // You have to create your own Actions class if there isn't something specific for your filter's needs |
| 133 | + |
| 134 | + // TODO: PROPOSED_ACTIONS |
| 135 | + // Store the preflight updated value(s) into the preflightUpdatedValues vector using |
| 136 | + // the appropriate methods. |
| 137 | + |
| 138 | + // TODO: PREFLIGHT_UPDATED_VALUES |
| 139 | + // Return both the resultOutputActions and the preflightUpdatedValues via std::move() |
| 140 | + return {std::move(resultOutputActions), std::move(preflightUpdatedValues)}; |
| 141 | +} |
| 142 | + |
| 143 | +//------------------------------------------------------------------------------ |
| 144 | +Result<> ReadNotesFileFilter::executeImpl(DataStructure& dataStructure, const Arguments& filterArgs, const PipelineFilter* pipelineNode, const MessageHandler& messageHandler, |
| 145 | + const std::atomic_bool& shouldCancel, const ExecutionContext& executionContext) const |
| 146 | +{ |
| 147 | + |
| 148 | + ReadNotesFileInputValues inputValues; |
| 149 | + |
| 150 | + // TODO: INPUT_VALUES_DEF |
| 151 | + |
| 152 | + return ReadNotesFile(dataStructure, messageHandler, shouldCancel, &inputValues)(); |
| 153 | +} |
| 154 | + |
| 155 | +namespace |
| 156 | +{ |
| 157 | +namespace SIMPL |
| 158 | +{ |
| 159 | + |
| 160 | +// TODO: PARAMETER_JSON_CONSTANTS |
| 161 | +} // namespace SIMPL |
| 162 | +} // namespace |
| 163 | + |
| 164 | +//------------------------------------------------------------------------------ |
| 165 | +Result<Arguments> ReadNotesFileFilter::FromSIMPLJson(const nlohmann::json& json) |
| 166 | +{ |
| 167 | + Arguments args = ReadNotesFileFilter().getDefaultArguments(); |
| 168 | + |
| 169 | + std::vector<Result<>> results; |
| 170 | + |
| 171 | + /* This is a NEW filter and not ported so this section does not matter */ |
| 172 | + |
| 173 | + Result<> conversionResult = MergeResults(std::move(results)); |
| 174 | + |
| 175 | + return ConvertResultTo<Arguments>(std::move(conversionResult), std::move(args)); |
| 176 | +} |
| 177 | + |
| 178 | +} // namespace nx::core |
0 commit comments