MCPcopy Create free account
hub / github.com/MITK/MITK / GetConstProperty

Function GetConstProperty

Modules/RESTAPI/src/mitkDataStorageBridge.cpp:58–94  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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.

Callers 4

BuildNodePredicateMethod · 0.70
GetNodePropertiesMethod · 0.70
GetNodePropertyMethod · 0.70
DeleteNodePropertyMethod · 0.70

Calls 3

valueMethod · 0.45
GetConstPropertyMethod · 0.45
GetDataMethod · 0.45

Tested by

no test coverage detected