| 56 | } |
| 57 | |
| 58 | mitk::BaseProperty::ConstPointer GetConstProperty(const mitk::DataNode* node, const std::string& propertyKey, |
| 59 | const std::optional<std::string>& context, const mitk::PropertyScope scope) |
| 60 | { |
| 61 | if (nullptr == node) |
| 62 | mitkThrow() << "Wrong use of GetConstProperty. Node is nullptr."; |
| 63 | |
| 64 | std::string contextName = context.has_value() ? context.value() : ""; |
| 65 | |
| 66 | mitk::BaseProperty::ConstPointer allResult = node->GetConstProperty(propertyKey, contextName, false); |
| 67 | |
| 68 | if (scope == mitk::PropertyScope::All) |
| 69 | { |
| 70 | return allResult; |
| 71 | } |
| 72 | |
| 73 | // scope is not all, we have to check explicit because the node implementation has a automatic |
| 74 | // fall trough... |
| 75 | mitk::BaseProperty::ConstPointer dataResult; |
| 76 | if (nullptr != node->GetData()) |
| 77 | { |
| 78 | dataResult = node->GetData()->GetConstProperty(propertyKey, contextName, false); |
| 79 | } |
| 80 | |
| 81 | if (scope == mitk::PropertyScope::Data) |
| 82 | { |
| 83 | return dataResult; |
| 84 | } |
| 85 | |
| 86 | // scope is Node only. If dataResult and allResult are different pointer, |
| 87 | // then there is a property defined at node level. |
| 88 | if (allResult != dataResult) |
| 89 | { |
| 90 | return allResult; |
| 91 | } |
| 92 | |
| 93 | return nullptr; |
| 94 | } |
| 95 | |
| 96 | /** |
| 97 | * @brief Get the correct set of property keys for a given scope. |
no test coverage detected