Medical Imaging Interaction Toolkit
2023.12.00
Medical Imaging Interaction Toolkit
|
#include <mitkPropertyRelationRuleBase.h>
Public Types | |
enum | RelationType { RelationType::None, RelationType::Data, RelationType::ID, RelationType::Complete } |
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 > |
using | RelationVectorType = std::vector< RelationType > |
using | InstanceIDType = std::string |
Static Public Member Functions | |
static const char * | GetStaticNameOfClass () |
static PropertyKeyPath | GetRootKeyPath () |
static PropertyKeyPath | GetRIIPropertyKeyPath (const std::string propName, const InstanceIDType &instanceID) |
static PropertyKeyPath | GetRIIRelationUIDPropertyKeyPath (const InstanceIDType &instanceID="") |
static PropertyKeyPath | GetRIIRuleIDPropertyKeyPath (const InstanceIDType &instanceID="") |
static PropertyKeyPath | GetRIIDestinationUIDPropertyKeyPath (const InstanceIDType &instanceID="") |
Protected Types | |
using | InstanceIDVectorType = std::vector< InstanceIDType > |
using | DataRelationUIDVectorType = std::vector< std::pair< RelationUIDType, RuleIDType > > |
Static Protected Member Functions | |
static InstanceIDType | NULL_INSTANCE_ID () |
static InstanceIDType | GetInstanceIDByPropertyName (const std::string propName) |
static std::vector< std::string > | GetPropertyKeys (const 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/specifying 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 falls back to the Data-layer (implemented by the concrete rule class) if the ID-layer is not sufficient or it is explicitly stated to (only) look at the data layer. 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 identifying (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\>.[relationUID|destinationUID|ruleID|\<data-layer-specific\>]"
Definition at line 74 of file mitkPropertyRelationRuleBase.h.
typedef itk::SmartPointer<const Self> mitk::PropertyRelationRuleBase::ConstPointer |
Definition at line 77 of file mitkPropertyRelationRuleBase.h.
|
protected |
Definition at line 286 of file mitkPropertyRelationRuleBase.h.
using mitk::PropertyRelationRuleBase::InstanceIDType = std::string |
Definition at line 100 of file mitkPropertyRelationRuleBase.h.
|
protected |
Definition at line 270 of file mitkPropertyRelationRuleBase.h.
Definition at line 77 of file mitkPropertyRelationRuleBase.h.
Definition at line 82 of file mitkPropertyRelationRuleBase.h.
using mitk::PropertyRelationRuleBase::RelationUIDVectorType = std::vector<RelationUIDType> |
Definition at line 83 of file mitkPropertyRelationRuleBase.h.
using mitk::PropertyRelationRuleBase::RelationVectorType = std::vector<RelationType> |
Definition at line 95 of file mitkPropertyRelationRuleBase.h.
using mitk::PropertyRelationRuleBase::RuleIDType = std::string |
Definition at line 81 of file mitkPropertyRelationRuleBase.h.
Definition at line 77 of file mitkPropertyRelationRuleBase.h.
typedef itk::Object mitk::PropertyRelationRuleBase::Superclass |
Definition at line 77 of file mitkPropertyRelationRuleBase.h.
|
strong |
Enum class for different types of relations.
Enumerator | |
---|---|
None | Two IPropertyOwner have no relation under the rule. |
Data | Two IPropertyOwner have a relation, but it is "only" deduced from the Data-layer (so a bit "weaker" as ID). Reasons for the missing ID connection could be that Destintination has not IIdentifiable implemented. |
ID | Two IPropertyOwner have a relation and are explicitly connected via the ID of IIdentifiable of the Destination. |
Complete | Two IPropertyOwner have a relation and are fully explicitly connected (via data layer and ID layer). |
Definition at line 86 of file mitkPropertyRelationRuleBase.h.
|
protecteddefault |
|
overrideprotecteddefault |
|
protected |
Helper method that tries to cast the provider to the Identifiable interface.
Pointer mitk::PropertyRelationRuleBase::Clone | ( | ) | const |
|
protected |
Explicitly connects the passed instances. Afterwards they have a relation of Data (if data layer is supported), ID (if a destination implements IIdentifiable) or Complete (if Data and ID could be connected). If the passed instance are already connected the old connection will be overwritten (and raised to the highest possible connection level).
|
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.
source | |
destination | |
instanceID | is the ID for the relation instance that should be connected. Existence of the relation instance is ensured. |
Implemented in mitk::SourceImageRelationRule, and mitk::GenericIDRelationRule.
void mitk::PropertyRelationRuleBase::Disconnect | ( | IPropertyOwner * | source, |
const IPropertyProvider * | destination, | ||
RelationType | layer = RelationType::Complete |
||
) | const |
Disconnect the passed instances by modifying source. One can specify which layer should be disconnected via the argument "layer". Default is the complete disconnection. All RII-properties or properties that define the connection on the data layer in the source for the passed destination will be removed.
source | |
destination | |
layer | Defines the way of disconnection. Data: Only the remove the connection on the data layer. ID: Only remove the connection on the ID layer. Complete: Remove the connection on all layers. If a connection does not exist on a selected layer, it is silently ignored. |
void mitk::PropertyRelationRuleBase::Disconnect | ( | IPropertyOwner * | source, |
RelationUIDType | relationUID, | ||
RelationType | layer = RelationType::Complete |
||
) | const |
Disconnect the source from the passed relationUID (useful for "zombie relations"). One can specify which layer should be disconnected via the argument "layer". Default is the complete disconnection. All RII-properties or properties that define the connection on the data layer in the source for the passed destination will be removed. If the relationUID is not part of the source. Nothing will be changed.
source | |
relationUID | |
layer | Defines the way of disconnection. Data: Only the remove the connection on the data layer. ID: Only remove the connection on the ID layer. Complete: Remove the connection on all layers. If a connection does not exist on a selected layer, it is silently ignored. |
|
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, mitk::GenericIDRelationRule, and mitk::ModelFitResultRelationRule.
|
inlinevirtual |
Reimplemented in mitk::SourceImageRelationRule, and mitk::GenericIDRelationRule.
Definition at line 77 of file mitkPropertyRelationRuleBase.h.
|
virtual |
Reimplemented in mitk::SourceImageRelationRule, and mitk::GenericIDRelationRule.
NodePredicateBase::ConstPointer mitk::PropertyRelationRuleBase::GetConnectedSourcesDetector | ( | ) | const |
Predicate that can be used to find nodes that are Sources of that rule and connected. Thus all nodes where IsSource() returns true.
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.
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. |
relationUID |
|
pure virtual |
Returns a human readable string that can be used to describe the role of a destination in context of the rule instance.
Implemented in mitk::SourceImageRelationRule, and mitk::GenericIDRelationRule.
NodePredicateBase::ConstPointer mitk::PropertyRelationRuleBase::GetDestinationsDetector | ( | const IPropertyProvider * | source, |
RelationType | exclusiveRelation = RelationType::None |
||
) | 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. |
exclusiveRelation | Defines if only special types of relations should detected. None: All relations (default); Data: must be a data relation (so Data or Complete); ID: must be an ID relation (so ID or Complete); Complete: only complete relations. |
|
protected |
Helper function that retrieves the destination UID of a relation instance of a passed source. If the relation has no destination UID, an empty string will be returned.
|
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.
RelationUIDVectorType mitk::PropertyRelationRuleBase::GetExistingRelations | ( | const IPropertyProvider * | source, |
RelationType | layer = RelationType::None |
||
) | const |
Returns a vector of relation UIDs for all relations of this rule instance that are defined for the passed source.
source | |
layer | Defines the layer the relations must be reflected. None: does not matter which one, as long as at least one is present. Data: Only data layer exclusive connections, ID: Only ID layer exclusive connections. Complete: Only relations that are connected on both layers. |
|
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.
|
staticprotected |
Helper function that deduces the instance ID out of a property name. If it cannot be deduced an MITK exception is thrown.
|
protected |
Helper function that deduces the relation instance ID given the relation UID. If it cannot be deduced an NoPropertyRelationException is thrown.
|
staticprotected |
helper method that serves as a workaround until T24729 is done. Please remove if T24728 is done then could directly use owner->GetPropertyKeys() again.
std::vector<PropertyKeyPath> mitk::PropertyRelationRuleBase::GetRelationPropertyPaths | ( | const IPropertyProvider * | source, |
RelationUIDType | relationUID, | ||
RelationType | layer = RelationType::Data |
||
) | const |
Returns the list of PropertyKeyPaths of all properties that are relevant for a given relation.
source | Pointer to the Source instance that contains the potential properties. |
relationUID | UID of the relation that is relevant for the requested properties. |
layer | Indicates which layer is requested. ID: returns all RII properties that belong to the relation. Data: returns all properties that are relevant/belong to the data layer of the relation. Complete: returns all properties (ID+Data) |
RelationVectorType mitk::PropertyRelationRuleBase::GetRelationTypes | ( | const IPropertyProvider * | source, |
const IPropertyProvider * | destination | ||
) | const |
Returns all relation types of the passed IPropertyOwner instances.
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 relation, no ID can be deduced and an exception will be thrown. If more than one relation is found, also an exception will be thrown. Thus only use this convenience method, if you are sure that one(!) relation UID can exist.
|
protected |
Helper function that deduces the relation UID of the given relation instance. If it cannot be deduced an NoPropertyRelationException is thrown.
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.
|
protectedpure virtual |
Returns the RelationUIDs of all relations that are defined by the data layer of source for this rule instance and, if defined, destination. If the passed source (and destination) instance has no relation on the data layer, an empty vector will be returned.
source | |
destination | Destination the find relations should point to. If destination is NULL any relation on the data layer for this rule and source are wanted. |
instances_IDLayer | List of relation instances that are already defined by the ID layer. The implementation of this function should only cover relations that are not already resembled in the passed relarions_IDLayer. |
Implemented in mitk::SourceImageRelationRule, mitk::GenericIDRelationRule, and mitk::ModelFitResultRelationRule.
|
static |
Returns the property key path for RII DestinationUID properties.
instanceID | If not empty, the PropertyKeyPath is only for a specific instance. If empty, it is wildcarded and will match RII DestinationUIDs property of any instance. |
|
static |
Returns the property key path for a RII property.
propName | If not empty a PropertyPath element will added (with the passed value) after the <InstanceID> element. |
instanceID | If not empty, the PropertyKeyPath is only for a specific instance. If empty, it is wildcarded and will match RIIs property of any instance. |
|
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 be added (with the passed value) after the <InstanceID> element. |
instanceID | If not empty only for the reg ex will only valid for the passed instanceID. Otherwise for all. |
|
static |
Returns the property key path for RII RelationUID properties.
instanceID | If not empty, the PropertyKeyPath is only for a specific instance. If empty, it is wildcarded and will match RII RelationUIDs property of any instance. |
|
static |
Returns the property key path for RII RuleID properties.
instanceID | If not empty, the PropertyKeyPath is only for a specific instance. If empty, it is wildcarded and will match RII RuleIDs property of any instance. |
|
static |
Returns the generic root path for relation rules ("MITK.Relations").
|
pure virtual |
Returns an ID string that identifies the rule class.
Implemented in mitk::SourceImageRelationRule, and mitk::GenericIDRelationRule.
|
protected |
Helper function that retrieves the rule ID of a relation instance of a passed source.
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.
|
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.
NodePredicateBase::ConstPointer mitk::PropertyRelationRuleBase::GetSourcesDetector | ( | const IPropertyProvider * | destination, |
RelationType | exclusiveRelation = RelationType::None |
||
) | 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. |
exclusiveRelation | Defines if only special types of relations should detected. None: All relations (default); Data: must be a data relation (so Data or Complete); ID: must be an ID relation (so ID or Complete); Complete: only complete relations. |
|
inlinestatic |
Definition at line 77 of file mitkPropertyRelationRuleBase.h.
bool mitk::PropertyRelationRuleBase::HasRelation | ( | const IPropertyProvider * | source, |
const IPropertyProvider * | destination, | ||
RelationType | requiredRelation = RelationType::None |
||
) | const |
Indicates if passed IPropertyOwner instances have a relation of a certain type.
source | |
destination | |
requiredRelation | Defines the type of relation that should be present. None: does not matter which one, as long as at least one is present. Data: Only data layer exclusive connections, ID: Only ID layer exclusive connections. Complete: Only relations that are connected on both layers. |
|
overrideprotected |
|
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.
|
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, and mitk::ModelFitResultRelationRule.
bool mitk::PropertyRelationRuleBase::IsSource | ( | const IPropertyProvider * | owner | ) | const |
Returns true if the passed owner is a Source of a relation defined by the rule.
|
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).
|
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.
mitk::PropertyRelationRuleBase::itkCreateAnotherMacro | ( | Self | ) |
|
staticprotected |