Medical Imaging Interaction Toolkit  2024.12.99-0da743f6
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 
19 #include <mitkExceptionMacro.h>
20 
21 #include <MitkCoreExports.h>
22 
23 namespace mitk
24 {
52  {
53  public:
54  using ItemSelectionIndex = std::size_t;
55  using ElementNameType = std::string;
56 
58  {
59  enum class NodeType
60  {
61  Invalid = 0, //*< Node does not exist or is invalid.
62  Element, //*< Selects an specific element given the node name.
63  ElementSelection, //*< Selects an specific item in a sequence of items and has a item selector ("[n]").
64  AnySelection, //*< Selects all items of a specific element ("[*]").
65  AnyElement //*< Selects any element/item. Node name is wildcarded ("*"); item selection as well implictily.
66  };
67 
71 
72  NodeInfo();
73  NodeInfo(const ElementNameType &name, NodeType type = NodeType::Element, ItemSelectionIndex index = 0);
74  bool Matches(const NodeInfo &right) const;
75 
76  bool operator==(const NodeInfo &right) const;
77  };
78 
79  using NodeInfoVectorType = std::vector<NodeInfo>;
80  using PathIndexType = NodeInfoVectorType::size_type;
81 
83  bool IsEmpty() const;
84 
86  bool IsExplicit() const;
87 
89  bool HasItemSelectionWildcardsOnly() const;
90 
92  PathIndexType GetSize() const;
93 
97  PathIndexType AddNode(const NodeInfo &newNode);
98 
105  const NodeInfo &GetNode(const PathIndexType &index) const;
106 
113  NodeInfo &GetNode(const PathIndexType &index);
114 
118  NodeInfo &GetFirstNode();
119 
123  const NodeInfo &GetFirstNode() const;
124 
128  NodeInfo &GetLastNode();
129 
133  const NodeInfo &GetLastNode() const;
134 
135  const NodeInfoVectorType &GetNodes() const;
136 
138  bool operator==(const PropertyKeyPath &path) const;
139 
141  bool operator<(const PropertyKeyPath &right) 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 
156  bool Equals(const PropertyKeyPath &path) const;
157 
158  PropertyKeyPath &operator=(const PropertyKeyPath &path);
159 
161  PropertyKeyPath &AddAnyElement();
163  PropertyKeyPath &AddElement(const ElementNameType &name);
165  PropertyKeyPath &AddAnySelection(const ElementNameType &name);
167  PropertyKeyPath &AddSelection(const ElementNameType &name, ItemSelectionIndex index);
168 
169  PropertyKeyPath();
170  PropertyKeyPath(const PropertyKeyPath &path);
172  PropertyKeyPath(const std::initializer_list< ElementNameType >& list);
173 
174  ~PropertyKeyPath();
175 
176  void Reset();
177 
178  protected:
180 
181  static bool PropertyKeyPathsMatch(const PropertyKeyPath &left, const PropertyKeyPath &right);
182  };
183 
185  {
186  public:
188  };
189 
190  MITKCORE_EXPORT std::ostream &operator<<(std::ostream &os, const PropertyKeyPath &path);
191 
208 
211  MITKCORE_EXPORT PropertyKeyPath PropertyNameToPropertyKeyPath(const std::string &propertyName);
214 } // namespace mitk
215 
216 #endif
mitk::Exception
An object of this class represents an exception of MITK. Please don't instantiate exceptions manually...
Definition: mitkException.h:45
mitk::PropertyKeyPathToPersistenceKeyTemplate
MITKCORE_EXPORT std::string PropertyKeyPathToPersistenceKeyTemplate(const PropertyKeyPath &tagPath)
mitk::PropertyKeyPathToPropertyRegEx
MITKCORE_EXPORT std::string PropertyKeyPathToPropertyRegEx(const PropertyKeyPath &tagPath)
mitk::InvalidPathNodeException
Definition: mitkPropertyKeyPath.h:184
mitk::PropertyKeyPath::NodeInfo::name
ElementNameType name
Definition: mitkPropertyKeyPath.h:69
mitk::PropertyKeyPath::ItemSelectionIndex
std::size_t ItemSelectionIndex
Definition: mitkPropertyKeyPath.h:54
mitk::PropertyKeyPath::ElementNameType
std::string ElementNameType
Definition: mitkPropertyKeyPath.h:55
mitk::modelFit::operator<
bool operator<(const StaticParameterMap::ValueType &a, const StaticParameterMap::ValueType &b)
Compares two var lists and returns true if the first list's first item is lower than the second one's...
Definition: mitkModelFitStaticParameterMap.h:139
mitk::PropertyNameToPropertyKeyPath
MITKCORE_EXPORT PropertyKeyPath PropertyNameToPropertyKeyPath(const std::string &propertyName)
mitk::operator<<
MITKCORE_EXPORT std::ostream & operator<<(std::ostream &o, DataNode::Pointer &dtn)
mitk::PropertyKeyPath
Class that can be used to specify nested or wild carded property keys. E.g. for the use in context of...
Definition: mitkPropertyKeyPath.h:51
mitk
Find image slices visible on a given plane.
Definition: RenderingTests.dox:1
mitk::PropertyKeyPath::NodeInfoVectorType
std::vector< NodeInfo > NodeInfoVectorType
Definition: mitkPropertyKeyPath.h:79
mitk::PropertyKeyPath::NodeInfo::type
NodeType type
Definition: mitkPropertyKeyPath.h:68
mitkExceptionMacro.h
mitk::operator==
MITKCORE_EXPORT bool operator==(const InteractionEvent &a, const InteractionEvent &b)
MitkCoreExports.h
mitk::PropertyKeyPath::NodeInfo
Definition: mitkPropertyKeyPath.h:57
mitk::PropertyKeyPathToPersistenceNameTemplate
MITKCORE_EXPORT std::string PropertyKeyPathToPersistenceNameTemplate(const PropertyKeyPath &tagPath)
operator>=
bool operator>=(const mitk::WeakPointer< T > &left, const mitk::WeakPointer< T > &right) noexcept
Definition: mitkWeakPointer.h:246
operator>
bool operator>(const mitk::WeakPointer< T > &left, const mitk::WeakPointer< T > &right) noexcept
Definition: mitkWeakPointer.h:240
mitk::PropertyKeyPathToPropertyName
MITKCORE_EXPORT std::string PropertyKeyPathToPropertyName(const PropertyKeyPath &tagPath)
mitk::PropertyKeyPath::NodeInfo::NodeType
NodeType
Definition: mitkPropertyKeyPath.h:59
mitk::PropertyKeyPath::NodeInfo::selection
ItemSelectionIndex selection
Definition: mitkPropertyKeyPath.h:70
operator<=
bool operator<=(const mitk::WeakPointer< T > &left, const mitk::WeakPointer< T > &right) noexcept
Definition: mitkWeakPointer.h:234
mitkExceptionClassMacro
#define mitkExceptionClassMacro(ClassName, SuperClassName)
Definition: mitkExceptionMacro.h:62
mitk::PropertyKeyPath::m_NodeInfos
NodeInfoVectorType m_NodeInfos
Definition: mitkPropertyKeyPath.h:179
mitk::PropertyKeyPath::PathIndexType
NodeInfoVectorType::size_type PathIndexType
Definition: mitkPropertyKeyPath.h:80
MITKCORE_EXPORT
#define MITKCORE_EXPORT
Definition: MitkCoreExports.h:15
mitk::PropertyKeyPathToPersistenceKeyRegEx
MITKCORE_EXPORT std::string PropertyKeyPathToPersistenceKeyRegEx(const PropertyKeyPath &tagPath)