Medical Imaging Interaction Toolkit  2018.4.99-dcb22cd7
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
bool operator>(const mitk::WeakPointer< T > &left, const mitk::WeakPointer< T > &right) noexcept
MITKCORE_EXPORT std::string PropertyKeyPathToPropertyName(const PropertyKeyPath &tagPath)
#define MITKCORE_EXPORT
bool operator>=(const mitk::WeakPointer< T > &left, const mitk::WeakPointer< T > &right) noexcept
bool operator<(const StaticParameterMap::ValueType &a, const StaticParameterMap::ValueType &b)
Compares two var lists and returns true if the first list&#39;s first item is lower than the second one&#39;s...
DataCollection - Class to facilitate loading/accessing structured data.
MITKCORE_EXPORT bool operator==(const InteractionEvent &a, const InteractionEvent &b)
std::vector< NodeInfo > NodeInfoVectorType
#define AddNode(name)
An object of this class represents an exception of MITK. Please don&#39;t instantiate exceptions manually...
Definition: mitkException.h:45
#define mitkExceptionClassMacro(ClassName, SuperClassName)
MITKCORE_EXPORT PropertyKeyPath PropertyNameToPropertyKeyPath(const std::string &propertyName)
std::vcl_size_t ItemSelectionIndex
MITKCORE_EXPORT std::string PropertyKeyPathToPersistenceNameTemplate(const PropertyKeyPath &tagPath)
MITKCORE_EXPORT std::string PropertyKeyPathToPersistenceKeyTemplate(const PropertyKeyPath &tagPath)
NodeInfoVectorType m_NodeInfos
NodeInfoVectorType::size_type PathIndexType
bool operator<=(const mitk::WeakPointer< T > &left, const mitk::WeakPointer< T > &right) noexcept
Class that can be used to specify nested or wild carded property keys. E.g. for the use in context of...
MITKCORE_EXPORT std::string PropertyKeyPathToPropertyRegEx(const PropertyKeyPath &tagPath)
MITKCORE_EXPORT std::ostream & operator<<(std::ostream &o, DataNode::Pointer &dtn)
MITKCORE_EXPORT std::string PropertyKeyPathToPersistenceKeyRegEx(const PropertyKeyPath &tagPath)