Medical Imaging Interaction Toolkit  2018.4.99-65942676
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 (const std::initializer_list< ElementNameType > &list)
 
 ~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/3]

mitk::PropertyKeyPath::PropertyKeyPath ( )

◆ PropertyKeyPath() [2/3]

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

◆ PropertyKeyPath() [3/3]

mitk::PropertyKeyPath::PropertyKeyPath ( const std::initializer_list< ElementNameType > &  list)

overload constructor that supports simple key pathes consisting only of elements.

◆ ~PropertyKeyPath()

mitk::PropertyKeyPath::~PropertyKeyPath ( )

Member Function Documentation

◆ AddAnyElement()

PropertyKeyPath& mitk::PropertyKeyPath::AddAnyElement ( )

Appends an "any element" to the path instance.

◆ AddAnySelection()

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

Appends an element with the passed name and any selection to the path instance.

◆ AddElement()

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

Appends an element with the passed name to the path instance.

◆ AddNode()

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.

◆ AddSelection()

PropertyKeyPath& mitk::PropertyKeyPath::AddSelection ( const ElementNameType name,
ItemSelectionIndex  index 
)

Appends an element with the passed name and selection index to the path instance.

◆ 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 ==().

◆ GetFirstNode() [1/2]

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.

◆ GetFirstNode() [2/2]

const 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.

◆ GetLastNode() [1/2]

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.

◆ GetLastNode() [2/2]

const 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.

◆ GetNode() [1/2]

const 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.

◆ GetNode() [2/2]

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.

◆ GetNodes()

const NodeInfoVectorType& mitk::PropertyKeyPath::GetNodes ( ) const

◆ GetSize()

PathIndexType mitk::PropertyKeyPath::GetSize ( ) const

Number of path nodes the PropertyKeyPath contains.

◆ HasItemSelectionWildcardsOnly()

bool mitk::PropertyKeyPath::HasItemSelectionWildcardsOnly ( ) const

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

◆ IsEmpty()

bool mitk::PropertyKeyPath::IsEmpty ( ) const

Returns if the PropertyKeyPath is empty.

◆ IsExplicit()

bool mitk::PropertyKeyPath::IsExplicit ( ) const

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

◆ operator<()

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

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

◆ operator<=()

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

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

◆ operator=()

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

◆ 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.

◆ operator>()

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

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

◆ operator>=()

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

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

◆ PropertyKeyPathsMatch()

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

◆ Reset()

void mitk::PropertyKeyPath::Reset ( )

Member Data Documentation

◆ m_NodeInfos

NodeInfoVectorType mitk::PropertyKeyPath::m_NodeInfos
protected

Definition at line 179 of file mitkPropertyKeyPath.h.


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