Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitkPropertyKeyPath.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #ifndef mitkPropertyKeyPath_h
14 #define mitkPropertyKeyPath_h
15 
16 #include <string>
17 #include <vector>
18 #include <map>
19 
20 #include <mitkExceptionMacro.h>
21 
22 #include <MitkCoreExports.h>
23 
24 namespace mitk
25 {
26  class IPropertyProvider;
27 
55  {
56  public:
57  using ItemSelectionIndex = std::size_t;
58  using ElementNameType = std::string;
59 
66  {
68  enum class NodeType
69  {
70  Invalid = 0,
71  Element,
72  ElementSelection,
73  AnySelection,
74  AnyElement
75  };
76 
79 
82 
85 
88 
96  NodeInfo(const ElementNameType &name, NodeType type = NodeType::Element, ItemSelectionIndex index = 0);
97 
107  bool Matches(const NodeInfo &right) const;
108 
115  bool operator==(const NodeInfo &right) const;
116  };
117 
118  using NodeInfoVectorType = std::vector<NodeInfo>;
119  using PathIndexType = NodeInfoVectorType::size_type;
120 
122  bool IsEmpty() const;
123 
125  bool IsExplicit() const;
126 
129 
132 
136  PathIndexType AddNode(const NodeInfo &newNode);
137 
144  const NodeInfo &GetNode(const PathIndexType &index) const;
145 
153 
158 
162  const NodeInfo &GetFirstNode() const;
163 
168 
172  const NodeInfo &GetLastNode() const;
173 
178  const NodeInfoVectorType &GetNodes() const;
179 
191  bool operator==(const PropertyKeyPath &path) const;
192 
201  bool operator<(const PropertyKeyPath &right) const;
202 
209  bool operator<=(const PropertyKeyPath &right) const;
210 
217  bool operator>=(const PropertyKeyPath &right) const;
218 
225  bool operator>(const PropertyKeyPath &right) const;
226 
239  bool Equals(const PropertyKeyPath &path) const;
240 
248 
257 
265 
275 
284 
287 
293 
301  PropertyKeyPath(const std::initializer_list< ElementNameType >& list);
302 
304 
308  void Reset();
309 
310  protected:
312 
313  static bool PropertyKeyPathsMatch(const PropertyKeyPath &left, const PropertyKeyPath &right);
314  };
315 
324  {
325  public:
327  };
328 
338  MITKCORE_EXPORT std::ostream &operator<<(std::ostream &os, const PropertyKeyPath &path);
339 
350 
361 
372 
383 
394 
405 
420  MITKCORE_EXPORT std::map<PropertyKeyPath::ItemSelectionIndex, std::string>
422 
423 } // namespace mitk
424 
425 #endif
#define MITKCORE_EXPORT
Base class for all MITK exceptions.
Definition: mitkException.h:53
Interface implemented by classes that provide access to property information.
Exception thrown when an invalid path node index is accessed.
mitkExceptionClassMacro(InvalidPathNodeException, mitk::Exception)
Class that can be used to specify nested or wild carded property keys. E.g. for the use in context of...
PropertyKeyPath()
Default constructor. Creates an empty path.
NodeInfoVectorType m_NodeInfos
bool operator<(const PropertyKeyPath &right) const
Lexicographic less-than comparison.
bool Equals(const PropertyKeyPath &path) const
Check if two PropertyKeyPaths match, processing wildcards.
const NodeInfoVectorType & GetNodes() const
Get a const reference to all node info entries.
PropertyKeyPath & AddElement(const ElementNameType &name)
Append a named element node to the path.
bool operator==(const PropertyKeyPath &path) const
Compare two PropertyKeyPaths for exact structural equality.
static bool PropertyKeyPathsMatch(const PropertyKeyPath &left, const PropertyKeyPath &right)
bool HasItemSelectionWildcardsOnly() const
PropertyKeyPath(const std::initializer_list< ElementNameType > &list)
Construct a path from a list of element names.
PropertyKeyPath & AddSelection(const ElementNameType &name, ItemSelectionIndex index)
Append a named element with a specific selection index to the path.
bool IsEmpty() const
bool operator>(const PropertyKeyPath &right) const
Lexicographic greater-than comparison.
NodeInfoVectorType::size_type PathIndexType
std::vector< NodeInfo > NodeInfoVectorType
PropertyKeyPath & AddAnySelection(const ElementNameType &name)
Append a named element with wildcard selection to the path.
PropertyKeyPath(const PropertyKeyPath &path)
Copy constructor.
NodeInfo & GetFirstNode()
NodeInfo & GetLastNode()
const NodeInfo & GetLastNode() const
PathIndexType AddNode(const NodeInfo &newNode)
const NodeInfo & GetFirstNode() const
PathIndexType GetSize() const
PropertyKeyPath & operator=(const PropertyKeyPath &path)
Assignment operator.
PropertyKeyPath & AddAnyElement()
Append a wildcard "any element" node to the path.
bool operator>=(const PropertyKeyPath &right) const
Lexicographic greater-than-or-equal comparison.
void Reset()
Clear the path, removing all nodes.
bool IsExplicit() const
const NodeInfo & GetNode(const PathIndexType &index) const
bool operator<=(const PropertyKeyPath &right) const
Lexicographic less-than-or-equal comparison.
NodeInfo & GetNode(const PathIndexType &index)
Find image slices visible on a given plane.
MITKCORE_EXPORT std::string PropertyKeyPathToPersistenceKeyTemplate(const PropertyKeyPath &tagPath)
Convert a PropertyKeyPath to a persistence key template string.
MITKCORE_EXPORT PropertyKeyPath PropertyNameToPropertyKeyPath(const std::string &propertyName)
Convert a property name string to a PropertyKeyPath.
MITKCORE_EXPORT std::string PropertyKeyPathToPersistenceKeyRegEx(const PropertyKeyPath &tagPath)
Convert a PropertyKeyPath to a regex string for matching persistence keys.
MITKCORE_EXPORT std::string PropertyKeyPathToPropertyRegEx(const PropertyKeyPath &tagPath)
Convert a PropertyKeyPath to a regex string for matching property keys.
MITKCORE_EXPORT std::ostream & operator<<(std::ostream &o, DataNode::Pointer &dtn)
Stream output operator for DataNode smart pointers.
MITKCORE_EXPORT std::map< PropertyKeyPath::ItemSelectionIndex, std::string > FindIndexedPropertyNames(const IPropertyProvider *provider, const PropertyKeyPath &path)
Find indexed entries matching a PropertyKeyPath in a property provider.
MITKCORE_EXPORT std::string PropertyKeyPathToPersistenceNameTemplate(const PropertyKeyPath &tagPath)
Convert a PropertyKeyPath to a persistence name template string.
MITKCORE_EXPORT std::string PropertyKeyPathToPropertyName(const PropertyKeyPath &tagPath)
Convert a PropertyKeyPath to its property name string representation.
Information about a single node in a PropertyKeyPath.
NodeInfo(const ElementNameType &name, NodeType type=NodeType::Element, ItemSelectionIndex index=0)
Construct a node with given name, type, and selection index.
NodeInfo()
Default constructor. Creates an Invalid node.
bool operator==(const NodeInfo &right) const
Check for exact equality (same type, name, and selection).
ItemSelectionIndex selection
The selection index for ElementSelection nodes.
NodeType
Types of nodes within a PropertyKeyPath.
bool Matches(const NodeInfo &right) const
Check if this node matches another, respecting wildcards.
ElementNameType name
The element name for this node (empty for AnyElement).
NodeType type
The type of this node.