Medical Imaging Interaction Toolkit
2018.4.99-389bf124
Medical Imaging Interaction Toolkit
|
#include <mitkPropertyRelationRuleBase.h>
Public Types | |
enum | RelationType { RelationType::None, RelationType::Implicit_Data, RelationType::Connected_Data, RelationType::Connected_ID } |
typedef PropertyRelationRuleBase | Self |
typedef itk::Object | Superclass |
typedef itk::SmartPointer< Self > | Pointer |
typedef itk::SmartPointer< const Self > | ConstPointer |
using | RuleIDType = std::string |
using | RelationUIDType = Identifiable::UIDType |
using | RelationUIDVectorType = std::vector< RelationUIDType > |
Static Public Member Functions | |
static const char * | GetStaticNameOfClass () |
static PropertyKeyPath | GetRootKeyPath () |
Protected Types | |
using | InstanceIDType = std::string |
using | InstanceIDVectorType = std::vector< InstanceIDType > |
Static Protected Member Functions | |
static InstanceIDType | NULL_INSTANCE_ID () |
static InstanceIDType | GetInstanceIDByPropertyName (const std::string propName) |
static std::vector< std::string > | GetPropertyKeys (const mitk::IPropertyProvider *owner) |
Base class to standardize/abstract/encapsulate rules and business logic to detect and define (property/data based) relations in MITK. Following important definitions must be regarded when using/implementing/specifing rule classes:
The basic concept of the rule design is that we have two layers of relation identification: Layer 1 is the ID-layer which uses the IIdentifiable interface and UIDs if available to encode "hard" relations. Layer 2 is the Data-layer which uses the properties of Source and Destination to deduce if there is a relation of the rule type. The ID-layer is completely implemented by this base class. The base class only falls back to the Data-layer (implemented by the concrete rule class) if the ID-layer is not sufficient or it is explicitly stated. Reasons for the introduction of the ID-layer are: 1st, data-defined relations may be weak (several Destinations are possible; e.g. DICOM source images may point to several loaded mitk images). But if explicitly a relation was connected it should be deduceable. 2nd, checks on a UID are faster then unnecessary data deduction.
Rules use relation instance identifing (RII) properties in order to manage their relations that are stored in the Source. The RII-properties follow the following naming schema: "MITK.Relations.<InstanceID>.<RuleID>.[relationUID|destinationUID|ruleID|<data-layer-specific>]"
Definition at line 73 of file mitkPropertyRelationRuleBase.h.
typedef itk::SmartPointer<const Self> mitk::PropertyRelationRuleBase::ConstPointer |
Definition at line 76 of file mitkPropertyRelationRuleBase.h.
|
protected |
Definition at line 211 of file mitkPropertyRelationRuleBase.h.
|
protected |
Definition at line 212 of file mitkPropertyRelationRuleBase.h.
Definition at line 76 of file mitkPropertyRelationRuleBase.h.
Definition at line 81 of file mitkPropertyRelationRuleBase.h.
using mitk::PropertyRelationRuleBase::RelationUIDVectorType = std::vector<RelationUIDType> |
Definition at line 82 of file mitkPropertyRelationRuleBase.h.
using mitk::PropertyRelationRuleBase::RuleIDType = std::string |
Definition at line 80 of file mitkPropertyRelationRuleBase.h.
Definition at line 76 of file mitkPropertyRelationRuleBase.h.
typedef itk::Object mitk::PropertyRelationRuleBase::Superclass |
Definition at line 76 of file mitkPropertyRelationRuleBase.h.
|
strong |
Enum class for different types of relations.
Enumerator | |
---|---|
None | Two IPropertyOwner have no relation under the rule. |
Implicit_Data | Two IPropertyOwner have a relation, but it is only deduced from the Data-layer and they were never explicitly connected. |
Connected_Data | Two IPropertyOwner have a relation and there where connected on the Data-layer (so a bit "weaker" as ID). Reasons for the missing ID connection could be that Destintination has not IIdentifiable implemented. |
Connected_ID | Two IPropertyOwner have a relation and are fully explictly connected. |
Definition at line 85 of file mitkPropertyRelationRuleBase.h.
|
protecteddefault |
|
overrideprotecteddefault |
Pointer mitk::PropertyRelationRuleBase::Clone | ( | ) | const |
|
protected |
Explicitly connects the passed instances. Afterwards they have a relation of Connected_Data or Connected_ID (if a destination implements IIdentifiable). If the passed instance are already connected the old connection will be overwritten (and raised to the highest possible connection level).
Definition at line 386 of file mitkPropertyRelationRuleBase.cpp.
References Connect_datalayer(), GetInstanceID_datalayer(), GetInstanceID_IDLayer(), GetRootKeyPath(), GetRuleID(), IsAbstract(), MITK_WARN, mitkThrow, mitk::StringProperty::New(), mitk::PropertyKeyPathToPropertyName(), and mitk::IPropertyOwner::SetProperty().
Referenced by mitk::GenericIDRelationRule::Connect(), and mitk::SourceImageRelationRule::Connect().
|
protectedpure virtual |
Is called by Connect() to ensure that source has correctly set properties to resemble the relation on the data layer. This means that the method should set the properties that describe and encode the relation on the data layer (data-layer-specific relation properties). If the passed instance are already connected, the old settings should be overwritten. Connect() will ensure that source and destination are valid pointers.
instanceID | is the ID for the relation instance that should be connected. Existance of the relation instance is ensured. |
Implemented in mitk::SourceImageRelationRule, and mitk::GenericIDRelationRule.
Referenced by Connect().
void mitk::PropertyRelationRuleBase::Disconnect | ( | IPropertyOwner * | source, |
const IPropertyProvider * | destination | ||
) | const |
Disconnect the passed instances. Afterwards they have a relation of None or Implicit_Data. All RII-properties in the source for the passed destination will be removed.
Definition at line 475 of file mitkPropertyRelationRuleBase.cpp.
References GetRelationUIDs().
void mitk::PropertyRelationRuleBase::Disconnect | ( | IPropertyOwner * | source, |
RelationUIDType | relationUID | ||
) | const |
Disconnect the source from the passed relationUID (usefull for "zombie relations"). All RII-properties in the source for the passed relationUID will be removed. If the relationUID is not part of the source. Nothing will be changed.
Definition at line 491 of file mitkPropertyRelationRuleBase.cpp.
References Disconnect_datalayer(), GetInstanceIDByRelationUID(), GetPropertyKeys(), GetRootKeyPath(), mitk::UIDGenerator::GetUID(), NULL_INSTANCE_ID(), mitk::PropertyKeyPathToPropertyName(), and mitk::IPropertyOwner::RemoveProperty().
|
protectedpure virtual |
This method is called by Disconnect() to remove all properties of the relation from the source that are set by Connect_datalayer().
Implemented in mitk::SourceImageRelationRule, and mitk::GenericIDRelationRule.
Referenced by Disconnect().
|
inlinevirtual |
Reimplemented in mitk::SourceImageRelationRule, and mitk::GenericIDRelationRule.
Definition at line 76 of file mitkPropertyRelationRuleBase.h.
|
virtual |
Reimplemented in mitk::SourceImageRelationRule, and mitk::GenericIDRelationRule.
mitk::NodePredicateBase::ConstPointer mitk::PropertyRelationRuleBase::GetConnectedSourcesDetector | ( | ) | const |
Predicate that can be used to find nodes that are Sources of that rule and explicitly connected. Thus all nodes where IsSource() returns true.
Definition at line 681 of file mitkPropertyRelationRuleBase.cpp.
mitk::NodePredicateBase::ConstPointer mitk::PropertyRelationRuleBase::GetDestinationCandidateIndicator | ( | ) | const |
Predicate that can be used to find nodes that qualify as destination for that rule (but must not be a destination yet). Thus all nodes where IsDestinationCandidate() returns true.
Definition at line 672 of file mitkPropertyRelationRuleBase.cpp.
mitk::NodePredicateBase::ConstPointer mitk::PropertyRelationRuleBase::GetDestinationDetector | ( | const IPropertyProvider * | source, |
RelationUIDType | relationUID | ||
) | const |
Returns a predicate that can be used to find the Destination of the passed Source for a given relationUID.
source | Pointer to the Source instance that should be used for detection. |
minimalRelation | Defines the minimal strength of the relation type that should be detected. |
Definition at line 723 of file mitkPropertyRelationRuleBase.cpp.
References GetExistingRelations(), and mitkThrow.
|
pure virtual |
Returns a human readable string that can be used to describe the role of a destionation in context of the rule instance.
Implemented in mitk::SourceImageRelationRule, and mitk::GenericIDRelationRule.
mitk::NodePredicateBase::ConstPointer mitk::PropertyRelationRuleBase::GetDestinationsDetector | ( | const IPropertyProvider * | source, |
RelationType | minimalRelation = RelationType::Implicit_Data |
||
) | const |
Predicate that can be used to find nodes that are as Destination related to the passed Source under the rule
source | Pointer to the Source instance that should be used for detection. |
minimalRelation | Defines the minimal strength of the relation type that should be detected. |
Definition at line 707 of file mitkPropertyRelationRuleBase.cpp.
References mitkThrow.
|
pure virtual |
Returns a human readable string that can be used to describe the rule. Does not need to be unique.
Implemented in mitk::SourceImageRelationRule, and mitk::GenericIDRelationRule.
mitk::PropertyRelationRuleBase::RelationUIDVectorType mitk::PropertyRelationRuleBase::GetExistingRelations | ( | const IPropertyProvider * | source | ) | const |
Returns a vector of relation UIDs for all relations of this rule instance that are defined for the passed source (so relations of type Connected_Data and Connected_ID).
Definition at line 170 of file mitkPropertyRelationRuleBase.cpp.
References mitk::IPropertyProvider::GetConstProperty(), GetInstanceIDByPropertyName(), GetPropertyKeys(), GetRelationUIDByInstanceID(), GetRIIPropertyRegEx(), IsSupportedRuleID(), and mitkThrow.
Referenced by GetDestinationDetector().
|
protectedpure virtual |
Is called if an instance ID cannot be deduced on the ID-layer. Implement this method to check which existing relation(s) as Connected_Data exists between both passed instances. If the passed instances have no explicit relation of type Connected_Data, an empty vector will be returned.
Implemented in mitk::SourceImageRelationRule, and mitk::GenericIDRelationRule.
Referenced by Connect(), GetRelationUIDs(), and HasRelation().
|
protected |
Returns the instance IDs for the passed source and destination for this rule instance. If the passed source and destination instances has no explicit relation on the ID layer (Connected_ID), an empty vector will be returned.
Definition at line 324 of file mitkPropertyRelationRuleBase.cpp.
References mitk::IPropertyProvider::GetConstProperty(), GetPropertyKeys(), GetRIIPropertyRegEx(), GetRuleIDByInstanceID(), IsSupportedRuleID(), and mitkThrow.
Referenced by Connect(), GetRelationUIDs(), and HasRelation().
|
staticprotected |
Helper function that deduces the instance ID out of a property name. If it cannot be deduced an MITK exception is thrown.
Definition at line 584 of file mitkPropertyRelationRuleBase.cpp.
References GetRootKeyPath(), mitkThrow, and mitk::PropertyNameToPropertyKeyPath().
Referenced by GetExistingRelations(), and mitk::SourceImageRelationRule::GetInstanceID_datalayer().
|
protected |
Helper function that deduces the relation instance ID given the relation UID. If it cannot be deduced an NoPropertyRelationException is thrown.
Definition at line 286 of file mitkPropertyRelationRuleBase.cpp.
References mitk::IPropertyProvider::GetConstProperty(), GetPropertyKeys(), GetRootKeyPath(), mitkThrow, NULL_INSTANCE_ID(), and mitk::PropertyKeyPathToPropertyRegEx().
Referenced by Disconnect().
|
staticprotected |
Definition at line 72 of file mitkPropertyRelationRuleBase.cpp.
References mitk::DataNode::GetData(), and mitk::IPropertyProvider::GetPropertyKeys().
Referenced by mitk::SourceImageRelationRule::CreateNewSourceImageSequenceItem(), Disconnect(), mitk::SourceImageRelationRule::Disconnect_datalayer(), GetExistingRelations(), mitk::SourceImageRelationRule::GetInstanceID_datalayer(), GetInstanceID_IDLayer(), GetInstanceIDByRelationUID(), mitk::SourceImageRelationRule::GetReferenceSequenceIndices(), and IsSource().
mitk::PropertyRelationRuleBase::RelationUIDType mitk::PropertyRelationRuleBase::GetRelationUID | ( | const IPropertyProvider * | source, |
const IPropertyProvider * | destination | ||
) | const |
Returns the relation UID for the passed source and destination of this rule instance. If the passed instances have no explicit relation (so of type Connected_Data or Connected_ID), no ID can be deduced and an exception will be thrown. If more then one relation is found, also an exception will be thrown. Thus only use this convinience method, if you are sure that one(!) relation UID can exist.
Definition at line 241 of file mitkPropertyRelationRuleBase.cpp.
References GetRelationUIDs(), mitkThrow, and mitkThrowException.
|
protected |
Helper function that deduces the relation UID of the given relation instance. If it cannot be deduced an NoPropertyRelationException is thrown.
Definition at line 262 of file mitkPropertyRelationRuleBase.cpp.
References mitk::IPropertyProvider::GetConstProperty(), GetRootKeyPath(), mitkThrowException, NULL_INSTANCE_ID(), and mitk::PropertyKeyPathToPropertyName().
Referenced by GetExistingRelations(), and GetRelationUIDs().
mitk::PropertyRelationRuleBase::RelationUIDVectorType mitk::PropertyRelationRuleBase::GetRelationUIDs | ( | const IPropertyProvider * | source, |
const IPropertyProvider * | destination | ||
) | const |
Returns the relation UID(s) for the passed source and destination of this rule instance. If the rule is abstract multiple relation UIDs might be returned. In case of concrete rule only one relation UID. If the passed instances have no explicit relation (so of type Connected_Data or Connected_ID), no ID can be deduced and an empty relation UID vector is returned.
Definition at line 204 of file mitkPropertyRelationRuleBase.cpp.
References GetInstanceID_datalayer(), GetInstanceID_IDLayer(), GetRelationUIDByInstanceID(), IsAbstract(), and mitkThrow.
Referenced by Disconnect(), and GetRelationUID().
|
protected |
Helper function that generates a reg ex that can be used to find a specific RII property for the rule instance.
propName | If not empty a PropertyPath element will added (with the passed value) after the <RuleID> element. |
instanceID | If not empty only for the reg ex will only valid for the passed instanceID. Otherwise for all. |
Definition at line 50 of file mitkPropertyRelationRuleBase.cpp.
References GetRootKeyPath(), and mitk::PropertyKeyPathToPropertyRegEx().
Referenced by GetExistingRelations(), mitk::SourceImageRelationRule::GetInstanceID_datalayer(), GetInstanceID_IDLayer(), and IsSource().
|
static |
Returns the generic root path for relation rules ("MITK.Relations").
Definition at line 39 of file mitkPropertyRelationRuleBase.cpp.
References mitk::PropertyKeyPath::AddElement().
Referenced by Connect(), mitk::SourceImageRelationRule::Connect_datalayer(), Disconnect(), mitk::SourceImageRelationRule::Disconnect_datalayer(), GetInstanceIDByPropertyName(), GetInstanceIDByRelationUID(), GetRelationUIDByInstanceID(), GetRIIPropertyRegEx(), and GetRuleIDByInstanceID().
|
pure virtual |
Returns an ID string that identifies the rule class.
Implemented in mitk::SourceImageRelationRule, and mitk::GenericIDRelationRule.
Referenced by mitk::PropertyRelations::AddRule(), Connect(), and IsSupportedRuleID().
|
protected |
Helper function that retrives the rule ID of a relation instance of a passed source.
Definition at line 597 of file mitkPropertyRelationRuleBase.cpp.
References mitk::PropertyKeyPath::AddElement(), mitk::IPropertyProvider::GetConstProperty(), GetRootKeyPath(), mitkClassMacro, mitkNewMacro2Param, mitkThrow, mitkThrowException, and mitk::PropertyKeyPathToPropertyName().
Referenced by mitk::SourceImageRelationRule::GetInstanceID_datalayer(), and GetInstanceID_IDLayer().
mitk::NodePredicateBase::ConstPointer mitk::PropertyRelationRuleBase::GetSourceCandidateIndicator | ( | ) | const |
Predicate that can be used to find nodes that qualify as source for that rule (but must not be a source yet). Thus all nodes where IsSourceCandidate() returns true.
Definition at line 663 of file mitkPropertyRelationRuleBase.cpp.
|
pure virtual |
Returns a human readable string that can be used to describe the role of a source in context of the rule instance.
Implemented in mitk::SourceImageRelationRule, and mitk::GenericIDRelationRule.
mitk::NodePredicateBase::ConstPointer mitk::PropertyRelationRuleBase::GetSourcesDetector | ( | const IPropertyProvider * | destination, |
RelationType | minimalRelation = RelationType::Implicit_Data |
||
) | const |
Predicate that can be used to find nodes that are as source related to the passed Destination under the rule
destination | Pointer to the Destination instance that should be used for detection. |
minimalRelation | Defines the minimal strength of the relation type that should be detected. |
Definition at line 691 of file mitkPropertyRelationRuleBase.cpp.
References mitkThrow.
|
inlinestatic |
Definition at line 76 of file mitkPropertyRelationRuleBase.h.
|
protectedpure virtual |
Is called by HasRelation() if no relation of type Connected_ID (GetInstanceID_IDLayer()) or Connected_Data (GetInstanceID_datalayer()) is evident. Implement this method to deduce if the passed instances have a relation of type Implicit_Data.
Implemented in mitk::SourceImageRelationRule, and mitk::GenericIDRelationRule.
Referenced by HasRelation().
mitk::PropertyRelationRuleBase::RelationType mitk::PropertyRelationRuleBase::HasRelation | ( | const IPropertyProvider * | source, |
const IPropertyProvider * | destination | ||
) | const |
Returns the relation type of the passed IPropertyOwner instances.
Definition at line 124 of file mitkPropertyRelationRuleBase.cpp.
References Connected_Data, Connected_ID, GetInstanceID_datalayer(), GetInstanceID_IDLayer(), HasImplicitDataRelation(), Implicit_Data, MITK_WARN, mitkThrow, None, and NULL_INSTANCE_ID().
|
overrideprotected |
Definition at line 578 of file mitkPropertyRelationRuleBase.cpp.
|
virtual |
Returns if the instance is a abstract rule (true). Default implementation is true. Overwrite and reimplement if another behavior is needed.
Reimplemented in mitk::SourceImageRelationRule, and mitk::GenericIDRelationRule.
Definition at line 24 of file mitkPropertyRelationRuleBase.cpp.
Referenced by Connect(), and GetRelationUIDs().
|
virtual |
This method checks if owner is eligible to be a Destination for the rule. The default implementation returns a True for every valid IPropertyProvider (so only a null_ptr results into false). May be reimplement by derived rules if they have requirements on potential Sources).
Reimplemented in mitk::SourceImageRelationRule.
Definition at line 34 of file mitkPropertyRelationRuleBase.cpp.
bool mitk::PropertyRelationRuleBase::IsSource | ( | const IPropertyProvider * | owner | ) | const |
Returns true if the passed owner is a Source of a relation defined by the rule so has at least one relation of type Connected_Data or Connected_ID.
Definition at line 93 of file mitkPropertyRelationRuleBase.cpp.
References mitk::IPropertyProvider::GetConstProperty(), GetPropertyKeys(), GetRIIPropertyRegEx(), IsSupportedRuleID(), and mitkThrow.
|
virtual |
This method checks if owner is eligible to be a Source for the rule. The default implementation returns a True for every valid IPropertyProvider (so only a null_ptr results into false). May be reimplement by derived rules if they have requirements on potential Sources).
Definition at line 29 of file mitkPropertyRelationRuleBase.cpp.
|
protectedvirtual |
Returns if the passed rule ID is supported/relevant for the rule. Either because it is the very ID of the rule (default implementation) or because it is an abstract rule which also supports the rule ID.
Reimplemented in mitk::SourceImageRelationRule, and mitk::GenericIDRelationRule.
Definition at line 44 of file mitkPropertyRelationRuleBase.cpp.
References GetRuleID().
Referenced by GetExistingRelations(), GetInstanceID_IDLayer(), and IsSource().
mitk::PropertyRelationRuleBase::itkCreateAnotherMacro | ( | Self | ) |
|
staticprotected |
Definition at line 257 of file mitkPropertyRelationRuleBase.cpp.
Referenced by Disconnect(), GetInstanceIDByRelationUID(), GetRelationUIDByInstanceID(), and HasRelation().