Medical Imaging Interaction Toolkit  2025.12.02
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 
61  {
62  enum class NodeType
63  {
64  Invalid = 0, //*< Node does not exist or is invalid.
65  Element, //*< Selects an specific element given the node name.
66  ElementSelection, //*< Selects an specific item in a sequence of items and has a item selector ("[n]").
67  AnySelection, //*< Selects all items of a specific element ("[*]").
68  AnyElement //*< Selects any element/item. Node name is wildcarded ("*"); item selection as well implictily.
69  };
70 
74 
76  NodeInfo(const ElementNameType &name, NodeType type = NodeType::Element, ItemSelectionIndex index = 0);
77  bool Matches(const NodeInfo &right) const;
78 
79  bool operator==(const NodeInfo &right) const;
80  };
81 
82  using NodeInfoVectorType = std::vector<NodeInfo>;
83  using PathIndexType = NodeInfoVectorType::size_type;
84 
86  bool IsEmpty() const;
87 
89  bool IsExplicit() const;
90 
93 
96 
100  PathIndexType AddNode(const NodeInfo &newNode);
101 
108  const NodeInfo &GetNode(const PathIndexType &index) const;
109 
117 
122 
126  const NodeInfo &GetFirstNode() const;
127 
132 
136  const NodeInfo &GetLastNode() const;
137 
138  const NodeInfoVectorType &GetNodes() const;
139 
141  bool operator==(const PropertyKeyPath &path) const;
142 
144  bool operator<(const PropertyKeyPath &right) const;
145 
147  bool operator<=(const PropertyKeyPath &right) const;
148 
150  bool operator>=(const PropertyKeyPath &right) const;
151 
153  bool operator>(const PropertyKeyPath &right) const;
154 
159  bool Equals(const PropertyKeyPath &path) const;
160 
162 
171 
175  PropertyKeyPath(const std::initializer_list< ElementNameType >& list);
176 
178 
179  void Reset();
180 
181  protected:
183 
184  static bool PropertyKeyPathsMatch(const PropertyKeyPath &left, const PropertyKeyPath &right);
185  };
186 
188  {
189  public:
191  };
192 
193  MITKCORE_EXPORT std::ostream &operator<<(std::ostream &os, const PropertyKeyPath &path);
194 
211 
217 
225  MITKCORE_EXPORT std::map<PropertyKeyPath::ItemSelectionIndex, std::string>
227 
228 } // namespace mitk
229 
230 #endif
#define MITKCORE_EXPORT
An object of this class represents an exception of MITK. Please don't instantiate exceptions manually...
Definition: mitkException.h:46
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...
NodeInfoVectorType m_NodeInfos
bool operator<(const PropertyKeyPath &right) const
bool Equals(const PropertyKeyPath &path) const
const NodeInfoVectorType & GetNodes() const
PropertyKeyPath & AddElement(const ElementNameType &name)
bool operator==(const PropertyKeyPath &path) const
static bool PropertyKeyPathsMatch(const PropertyKeyPath &left, const PropertyKeyPath &right)
bool HasItemSelectionWildcardsOnly() const
PropertyKeyPath(const std::initializer_list< ElementNameType > &list)
PropertyKeyPath & AddSelection(const ElementNameType &name, ItemSelectionIndex index)
bool IsEmpty() const
bool operator>(const PropertyKeyPath &right) const
NodeInfoVectorType::size_type PathIndexType
std::vector< NodeInfo > NodeInfoVectorType
PropertyKeyPath & AddAnySelection(const ElementNameType &name)
PropertyKeyPath(const PropertyKeyPath &path)
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)
PropertyKeyPath & AddAnyElement()
bool operator>=(const PropertyKeyPath &right) const
bool IsExplicit() const
const NodeInfo & GetNode(const PathIndexType &index) const
bool operator<=(const PropertyKeyPath &right) const
NodeInfo & GetNode(const PathIndexType &index)
Find image slices visible on a given plane.
MITKCORE_EXPORT std::string PropertyKeyPathToPersistenceKeyTemplate(const PropertyKeyPath &tagPath)
MITKCORE_EXPORT PropertyKeyPath PropertyNameToPropertyKeyPath(const std::string &propertyName)
MITKCORE_EXPORT std::string PropertyKeyPathToPersistenceKeyRegEx(const PropertyKeyPath &tagPath)
MITKCORE_EXPORT std::string PropertyKeyPathToPropertyRegEx(const PropertyKeyPath &tagPath)
MITKCORE_EXPORT std::ostream & operator<<(std::ostream &o, DataNode::Pointer &dtn)
MITKCORE_EXPORT std::map< PropertyKeyPath::ItemSelectionIndex, std::string > FindIndexedPropertyNames(const IPropertyProvider *provider, const PropertyKeyPath &path)
Helper function to find indexed entries for a PropertyKeyPath in a property provider.
MITKCORE_EXPORT std::string PropertyKeyPathToPersistenceNameTemplate(const PropertyKeyPath &tagPath)
MITKCORE_EXPORT std::string PropertyKeyPathToPropertyName(const PropertyKeyPath &tagPath)
NodeInfo(const ElementNameType &name, NodeType type=NodeType::Element, ItemSelectionIndex index=0)
bool operator==(const NodeInfo &right) const
bool Matches(const NodeInfo &right) const