Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
mitk::PropertyKeyPath Class Referencefinal

Class that can be used to specify nested or wild carded property keys. E.g. for the use in context of the property persistence service or the property relation service.
Following assumptions are made /preconditions are defined: More...

#include <mitkPropertyKeyPath.h>

Collaboration diagram for mitk::PropertyKeyPath:

Classes

struct  NodeInfo
 

Public Types

using ItemSelectionIndex = std::vcl_size_t
 
using ElementNameType = std::string
 
using NodeInfoVectorType = std::vector< NodeInfo >
 
using PathIndexType = NodeInfoVectorType::size_type
 

Public Member Functions

bool IsEmpty () const
 
bool IsExplicit () const
 
bool HasItemSelectionWildcardsOnly () const
 
PathIndexType GetSize () const
 
PathIndexType AddNode (const NodeInfo &newNode)
 
const NodeInfoGetNode (const PathIndexType &index) const
 
NodeInfoGetNode (const PathIndexType &index)
 
NodeInfoGetFirstNode ()
 
const NodeInfoGetFirstNode () const
 
NodeInfoGetLastNode ()
 
const NodeInfoGetLastNode () const
 
const NodeInfoVectorTypeGetNodes () const
 
bool operator== (const PropertyKeyPath &path) const
 
bool operator< (const PropertyKeyPath &right) const
 
bool operator<= (const PropertyKeyPath &right) const
 
bool operator>= (const PropertyKeyPath &right) const
 
bool operator> (const PropertyKeyPath &right) const
 
bool Equals (const PropertyKeyPath &path) const
 
PropertyKeyPathoperator= (const PropertyKeyPath &path)
 
PropertyKeyPathAddAnyElement ()
 
PropertyKeyPathAddElement (const ElementNameType &name)
 
PropertyKeyPathAddAnySelection (const ElementNameType &name)
 
PropertyKeyPathAddSelection (const ElementNameType &name, ItemSelectionIndex index)
 
 PropertyKeyPath ()
 
 PropertyKeyPath (const PropertyKeyPath &path)
 
 ~PropertyKeyPath ()
 
void Reset ()
 

Static Protected Member Functions

static bool PropertyKeyPathsMatch (const PropertyKeyPath &left, const PropertyKeyPath &right)
 

Protected Attributes

NodeInfoVectorType m_NodeInfos
 

Detailed Description

Class that can be used to specify nested or wild carded property keys. E.g. for the use in context of the property persistence service or the property relation service.
Following assumptions are made /preconditions are defined:

  • A property key is partitioned by "." into nodes (c.f. visualization of property keys in the PropertyView).
  • A node can either be an element or a selection.
  • An element has a name (alphanumric, - and space; "A-Za-z0-9- ") or is wildcarded ("*")
  • A selection is either an index (e.g. "[1]") or a wildcard ("[*]").

Selections are used to indicate that the preceding element has multiple occurences and which occurence is meant. Example property keys would be:

  • prop : A simple property key
  • prop.subprop1 : A property key consting of two nodes
  • prop.* : Any property key that starts with a node "prop"
  • prop.sub.[2] : A property key that starts with a node "prop" and a has a second node that is selection and has the index 2.
  • prop.sub.[*] : Any property key that starts with a node "prop" and a has a second node that is selection (with any index).

To build a path one may use the Add* method to build up the PropertyKeyPath element by element.
"first.*.third.[3]" would be equivalent to propKeyPath.AddElement("first"); propKeyPath.AddAnyElement(); propKeyPath.AddSelection("third",3);
or the inline version propKeyPath.AddElement("first").AddAnyElement().AddSelection("third",3);

Definition at line 51 of file mitkPropertyKeyPath.h.

Member Typedef Documentation

◆ ElementNameType

Definition at line 55 of file mitkPropertyKeyPath.h.

◆ ItemSelectionIndex

Definition at line 54 of file mitkPropertyKeyPath.h.

◆ NodeInfoVectorType

Definition at line 79 of file mitkPropertyKeyPath.h.

◆ PathIndexType

using mitk::PropertyKeyPath::PathIndexType = NodeInfoVectorType::size_type

Definition at line 80 of file mitkPropertyKeyPath.h.

Constructor & Destructor Documentation

◆ PropertyKeyPath() [1/2]

mitk::PropertyKeyPath::PropertyKeyPath ( )

Definition at line 277 of file mitkPropertyKeyPath.cpp.

References Reset().

Referenced by mitk::PropertyNameToPropertyKeyPath().

◆ PropertyKeyPath() [2/2]

mitk::PropertyKeyPath::PropertyKeyPath ( const PropertyKeyPath path)

Definition at line 279 of file mitkPropertyKeyPath.cpp.

◆ ~PropertyKeyPath()

mitk::PropertyKeyPath::~PropertyKeyPath ( )

Definition at line 281 of file mitkPropertyKeyPath.cpp.

Member Function Documentation

◆ AddAnyElement()

PropertyKeyPath & mitk::PropertyKeyPath::AddAnyElement ( )

Appends an "any element" to the path instance.

Definition at line 253 of file mitkPropertyKeyPath.cpp.

References mitk::PropertyKeyPath::NodeInfo::AnyElement, and m_NodeInfos.

Referenced by mitk::SourceImageRelationRule::Disconnect_datalayer(), and mitk::PropertyNameToPropertyKeyPath().

◆ AddAnySelection()

PropertyKeyPath & mitk::PropertyKeyPath::AddAnySelection ( const ElementNameType name)

◆ AddElement()

◆ AddNode()

PropertyKeyPath::PathIndexType mitk::PropertyKeyPath::AddNode ( const NodeInfo newNode)

Adds a new node to the end of the path.

Parameters
[in]newNodeReference to the node that should be added.
Returns
Returns the index of the newly added node.

Definition at line 96 of file mitkPropertyKeyPath.cpp.

References m_NodeInfos.

◆ AddSelection()

◆ Equals()

bool mitk::PropertyKeyPath::Equals ( const PropertyKeyPath path) const

Checks if two PropertyKeyPaths specify the same node. Hence all wildcards will be processed.
E.G.: "item1.child1.grandChild2" == "item1.*.grandChild2" is true.

Remarks
If you want to check if two paths are "truly" equal and not only equal in terms of pointing to the same node, use the member function operator ==().

Definition at line 241 of file mitkPropertyKeyPath.cpp.

References PropertyKeyPathsMatch().

◆ GetFirstNode() [1/2]

PropertyKeyPath::NodeInfo & mitk::PropertyKeyPath::GetFirstNode ( )

Function returns the node info of the first path node within the PropertyKeyPath.

Precondition
PropertyKeyPath must not be empty.
Returns
Info of the first path node. If the path is empty, an InvalidPathNode exception will be thrown.

Definition at line 135 of file mitkPropertyKeyPath.cpp.

References GetNode(), m_NodeInfos, and mitkThrowException.

◆ GetFirstNode() [2/2]

const PropertyKeyPath::NodeInfo & mitk::PropertyKeyPath::GetFirstNode ( ) const

Function returns the node info of the first path node within the PropertyKeyPath.

Precondition
PropertyKeyPath must not be empty.
Returns
Info of the first path node. If the path is empty, an InvalidPathNode exception will be thrown.

Definition at line 126 of file mitkPropertyKeyPath.cpp.

References GetNode(), m_NodeInfos, and mitkThrowException.

◆ GetLastNode() [1/2]

PropertyKeyPath::NodeInfo & mitk::PropertyKeyPath::GetLastNode ( )

Function returns the node info of the last path node within the PropertyKeyPath.

Precondition
PropertyKeyPath must not be empty.
Returns
Info of the first path node. If the path is empty, an InvalidPathNode exception will be thrown.

Definition at line 153 of file mitkPropertyKeyPath.cpp.

References GetNode(), GetSize(), m_NodeInfos, and mitkThrowException.

◆ GetLastNode() [2/2]

const PropertyKeyPath::NodeInfo & mitk::PropertyKeyPath::GetLastNode ( ) const

Function returns the node info of the last path node within the PropertyKeyPath.

Precondition
PropertyKeyPath must not be empty.
Returns
Info of the first path node. If the path is empty, an InvalidPathNode exception will be thrown.

Definition at line 144 of file mitkPropertyKeyPath.cpp.

References GetNode(), GetSize(), m_NodeInfos, and mitkThrowException.

◆ GetNode() [1/2]

const PropertyKeyPath::NodeInfo & mitk::PropertyKeyPath::GetNode ( const PathIndexType index) const

Function returns the node info of a path node specified by the index within the PropertyKeyPath.

Precondition
Passed index must not be out of bounds.
Parameters
[in]indexIndex of the node whose info should be retrieved.
Returns
Info of the specified path node. If the index is out of bound an InvalidPathNode exception will be thrown.

Definition at line 102 of file mitkPropertyKeyPath.cpp.

References GetSize(), m_NodeInfos, mitkThrowException, and mitk::PropertyKeyPathToPropertyName().

Referenced by GetFirstNode(), and GetLastNode().

◆ GetNode() [2/2]

PropertyKeyPath::NodeInfo & mitk::PropertyKeyPath::GetNode ( const PathIndexType index)

Function returns the node info of a path node specified by the index within the PropertyKeyPath.

Precondition
Passed index must not be out of bounds.
Parameters
[in]indexIndex of the node whose info should be retrieved.
Returns
Info of the specified path node. If the index is out of bound an InvalidPathNode exception will be thrown.

Definition at line 114 of file mitkPropertyKeyPath.cpp.

References GetSize(), m_NodeInfos, mitkThrowException, and mitk::PropertyKeyPathToPropertyName().

◆ GetNodes()

◆ GetSize()

PropertyKeyPath::PathIndexType mitk::PropertyKeyPath::GetSize ( ) const

Number of path nodes the PropertyKeyPath contains.

Definition at line 94 of file mitkPropertyKeyPath.cpp.

References m_NodeInfos.

Referenced by GetLastNode(), and GetNode().

◆ HasItemSelectionWildcardsOnly()

bool mitk::PropertyKeyPath::HasItemSelectionWildcardsOnly ( ) const

Returns if the path has any nodes with item selection wild cards ([*]).

Definition at line 79 of file mitkPropertyKeyPath.cpp.

References mitk::PropertyKeyPath::NodeInfo::AnyElement, mitk::PropertyKeyPath::NodeInfo::AnySelection, and m_NodeInfos.

◆ IsEmpty()

bool mitk::PropertyKeyPath::IsEmpty ( ) const

Returns if the PropertyKeyPath is empty.

Definition at line 64 of file mitkPropertyKeyPath.cpp.

References m_NodeInfos.

◆ IsExplicit()

bool mitk::PropertyKeyPath::IsExplicit ( ) const

Returns if the path is explicit (has no wildcards).

Definition at line 66 of file mitkPropertyKeyPath.cpp.

References mitk::PropertyKeyPath::NodeInfo::AnyElement, mitk::PropertyKeyPath::NodeInfo::AnySelection, and m_NodeInfos.

◆ operator<()

bool mitk::PropertyKeyPath::operator< ( const PropertyKeyPath right) const

Operation equals like comparing the ToStr() results with operator <.

Definition at line 166 of file mitkPropertyKeyPath.cpp.

References m_NodeInfos.

◆ operator<=()

bool mitk::PropertyKeyPath::operator<= ( const PropertyKeyPath right) const

Operation equals like comparing the ToStr() results with operator <=.

Definition at line 239 of file mitkPropertyKeyPath.cpp.

◆ operator=()

PropertyKeyPath & mitk::PropertyKeyPath::operator= ( const PropertyKeyPath path)

Definition at line 243 of file mitkPropertyKeyPath.cpp.

References m_NodeInfos.

◆ operator==()

bool mitk::PropertyKeyPath::operator== ( const PropertyKeyPath path) const

Compares two PropertyKeyPaths for real equality. So it is a string comparison of their string conversion.

Definition at line 164 of file mitkPropertyKeyPath.cpp.

References m_NodeInfos.

◆ operator>()

bool mitk::PropertyKeyPath::operator> ( const PropertyKeyPath right) const

Operation equals like comparing the ToStr() results with operator >.

Definition at line 209 of file mitkPropertyKeyPath.cpp.

References m_NodeInfos.

◆ operator>=()

bool mitk::PropertyKeyPath::operator>= ( const PropertyKeyPath right) const

Operation equals like comparing the ToStr() results with operator >=.

Definition at line 237 of file mitkPropertyKeyPath.cpp.

◆ PropertyKeyPathsMatch()

bool mitk::PropertyKeyPath::PropertyKeyPathsMatch ( const PropertyKeyPath left,
const PropertyKeyPath right 
)
staticprotected

Definition at line 285 of file mitkPropertyKeyPath.cpp.

References GetNodes().

Referenced by Equals().

◆ Reset()

void mitk::PropertyKeyPath::Reset ( )

Definition at line 283 of file mitkPropertyKeyPath.cpp.

References m_NodeInfos.

Referenced by PropertyKeyPath().

Member Data Documentation

◆ m_NodeInfos


The documentation for this class was generated from the following files: