Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitkPropertyRelationRuleBase.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 mitkPropertyRelationRuleBase_h
14 #define mitkPropertyRelationRuleBase_h
15 
16 #include <mitkIPropertyOwner.h>
17 #include <mitkIdentifiable.h>
18 
19 #include <mitkException.h>
20 #include <mitkNodePredicateBase.h>
21 #include <mitkPropertyKeyPath.h>
22 
23 #include <MitkCoreExports.h>
24 
25 #include <string>
26 
27 namespace mitk
28 {
63  class MITKCORE_EXPORT PropertyRelationRuleBase : public itk::Object
64  {
65  public:
67  itkCloneMacro(Self);
69 
70  using RuleIDType = std::string;
72  using RelationUIDVectorType = std::vector<RelationUIDType>;
73 
75  enum class RelationType
76  {
77  None = 0,
78  Data = 1,
81  ID = 2,
82  Complete = 3
83  };
84  using RelationVectorType = std::vector<RelationType>;
85 
88 
89  using InstanceIDType = std::string;
94  static PropertyKeyPath GetRIIPropertyKeyPath(const std::string propName, const InstanceIDType& instanceID);
107 
111  virtual RuleIDType GetRuleID() const = 0;
112 
114  virtual std::string GetDisplayName() const = 0;
115 
118  virtual std::string GetSourceRoleName() const = 0;
121  virtual std::string GetDestinationRoleName() const = 0;
122 
125  virtual bool IsAbstract() const;
126 
130  virtual bool IsSourceCandidate(const IPropertyProvider *owner) const;
131 
135  virtual bool IsDestinationCandidate(const IPropertyProvider *owner) const;
136 
139  bool IsSource(const IPropertyProvider *owner) const;
140 
148  RelationVectorType GetRelationTypes(const IPropertyProvider* source, const IPropertyProvider* destination) const;
149 
161  bool HasRelation(const IPropertyProvider *source, const IPropertyProvider *destination, RelationType requiredRelation = RelationType::None) const;
162 
169  RelationUIDVectorType GetExistingRelations(const IPropertyProvider *source, RelationType layer = RelationType::None) const;
170 
177 
187  RelationUIDType GetRelationUID(const IPropertyProvider *source, const IPropertyProvider *destination) const;
188 
191  NodePredicateBase::ConstPointer GetSourceCandidateIndicator() const;
194  NodePredicateBase::ConstPointer GetDestinationCandidateIndicator() const;
197  NodePredicateBase::ConstPointer GetConnectedSourcesDetector() const;
203  NodePredicateBase::ConstPointer GetSourcesDetector(
204  const IPropertyProvider *destination, RelationType exclusiveRelation = RelationType::None) const;
210  NodePredicateBase::ConstPointer GetDestinationsDetector(
211  const IPropertyProvider *source, RelationType exclusiveRelation = RelationType::None) const;
218  NodePredicateBase::ConstPointer GetDestinationDetector(const IPropertyProvider *source,
219  RelationUIDType relationUID) const;
220 
231  void Disconnect(IPropertyOwner *source, const IPropertyProvider *destination, RelationType layer = RelationType::Complete) const;
243  void Disconnect(IPropertyOwner *source, RelationUIDType relationUID, RelationType layer = RelationType::Complete) const;
244 
260  std::vector<PropertyKeyPath> GetRelationPropertyPaths(const IPropertyProvider* source,
261  RelationUIDType relationUID, RelationType layer = RelationType::Data) const;
262 
263  protected:
266  ~PropertyRelationRuleBase() override = default;
267 
268  using InstanceIDVectorType = std::vector<InstanceIDType>;
270 
282  const IPropertyProvider *destination) const;
283 
284  using DataRelationUIDVectorType = std::vector< std::pair<RelationUIDType, RuleIDType> >;
302  const IPropertyProvider * destination, const InstanceIDVectorType& instances_IDLayer) const = 0;
303 
310  const RelationUIDType &relationUID) const;
311 
321  RelationUIDType Connect(IPropertyOwner *source, const IPropertyProvider *destination) const;
322 
334  virtual void Connect_datalayer(IPropertyOwner *source,
335  const IPropertyProvider *destination,
336  const InstanceIDType &instanceID) const = 0;
337 
344  virtual void Disconnect_datalayer(IPropertyOwner *source, const RelationUIDType & relationUID) const = 0;
345 
349  virtual bool IsSupportedRuleID(const RuleIDType& ruleID) const;
350 
354  std::string GetRIIPropertyRegEx(const std::string propName = "", const InstanceIDType &instanceID = "") const;
355 
358  static InstanceIDType GetInstanceIDByPropertyName(const std::string propName);
359 
364  const InstanceIDType &instanceID) const;
369  const InstanceIDType & instanceID) const;
370 
373  static std::vector<std::string> GetPropertyKeys(const IPropertyProvider *owner);
374 
377 
378  private:
380  static RelationUIDType CreateRelationUID();
381 
387  InstanceIDType CreateNewRelationInstance(IPropertyOwner *source, const RelationUIDType &relationUID) const;
388  };
389 
392  {
393  public:
395  };
396 
397 } // namespace mitk
398 
399 #endif
#define MITKCORE_EXPORT
Base class for all MITK exceptions.
Definition: mitkException.h:53
Interface implemented by classes that provide write/read access to property information.
Interface implemented by classes that provide access to property information.
Base class of identifiable objects.
std::string UIDType
Type alias for unique identifiers.
Class that can be used to specify nested or wild carded property keys. E.g. for the use in context of...
Base class for defining and detecting property-based relations between data objects.
RelationUIDType GetRelationUID(const IPropertyProvider *source, const IPropertyProvider *destination) const
NodePredicateBase::ConstPointer GetDestinationCandidateIndicator() const
virtual void Disconnect_datalayer(IPropertyOwner *source, const RelationUIDType &relationUID) const =0
bool IsSource(const IPropertyProvider *owner) const
std::vector< RelationType > RelationVectorType
RuleIDType GetRuleIDByInstanceID(const IPropertyProvider *source, const InstanceIDType &instanceID) const
static PropertyKeyPath GetRIIPropertyKeyPath(const std::string propName, const InstanceIDType &instanceID)
std::string GetRIIPropertyRegEx(const std::string propName="", const InstanceIDType &instanceID="") const
std::vector< RelationUIDType > RelationUIDVectorType
virtual std::string GetSourceRoleName() const =0
std::vector< std::pair< RelationUIDType, RuleIDType > > DataRelationUIDVectorType
std::string GetDestinationUIDByInstanceID(const IPropertyProvider *source, const InstanceIDType &instanceID) const
NodePredicateBase::ConstPointer GetConnectedSourcesDetector() const
static PropertyKeyPath GetRootKeyPath()
bool HasRelation(const IPropertyProvider *source, const IPropertyProvider *destination, RelationType requiredRelation=RelationType::None) const
RelationUIDType Connect(IPropertyOwner *source, const IPropertyProvider *destination) const
std::vector< PropertyKeyPath > GetRelationPropertyPaths(const IPropertyProvider *source, RelationUIDType relationUID, RelationType layer=RelationType::Data) const
Get all property key paths relevant for a given relation.
RelationUIDVectorType GetExistingRelations(const IPropertyProvider *source, RelationType layer=RelationType::None) const
const Identifiable * CastProviderAsIdentifiable(const mitk::IPropertyProvider *provider) const
PropertyRelationRuleBase(const PropertyRelationRuleBase &)
static PropertyKeyPath GetRIIRuleIDPropertyKeyPath(const InstanceIDType &instanceID="")
NodePredicateBase::ConstPointer GetDestinationDetector(const IPropertyProvider *source, RelationUIDType relationUID) const
mitkClassMacroItkParent(PropertyRelationRuleBase, itk::Object)
virtual RuleIDType GetRuleID() const =0
std::vector< InstanceIDType > InstanceIDVectorType
virtual std::string GetDisplayName() const =0
NodePredicateBase::ConstPointer GetSourcesDetector(const IPropertyProvider *destination, RelationType exclusiveRelation=RelationType::None) const
static InstanceIDType GetInstanceIDByPropertyName(const std::string propName)
static PropertyKeyPath GetRIIRelationUIDPropertyKeyPath(const InstanceIDType &instanceID="")
void Disconnect(IPropertyOwner *source, RelationUIDType relationUID, RelationType layer=RelationType::Complete) const
virtual bool IsSourceCandidate(const IPropertyProvider *owner) const
RelationUIDType GetRelationUIDByInstanceID(const IPropertyProvider *source, const InstanceIDType &instanceID) const
InstanceIDVectorType GetInstanceID_IDLayer(const IPropertyProvider *source, const IPropertyProvider *destination) const
InstanceIDType GetInstanceIDByRelationUID(const IPropertyProvider *source, const RelationUIDType &relationUID) const
NodePredicateBase::ConstPointer GetDestinationsDetector(const IPropertyProvider *source, RelationType exclusiveRelation=RelationType::None) const
RelationUIDVectorType GetRelationUIDs(const IPropertyProvider *source, const IPropertyProvider *destination) const
virtual bool IsDestinationCandidate(const IPropertyProvider *owner) const
virtual void Connect_datalayer(IPropertyOwner *source, const IPropertyProvider *destination, const InstanceIDType &instanceID) const =0
static std::vector< std::string > GetPropertyKeys(const IPropertyProvider *owner)
~PropertyRelationRuleBase() override=default
virtual bool IsSupportedRuleID(const RuleIDType &ruleID) const
RelationVectorType GetRelationTypes(const IPropertyProvider *source, const IPropertyProvider *destination) const
static InstanceIDType NULL_INSTANCE_ID()
virtual bool IsAbstract() const
NodePredicateBase::ConstPointer GetSourceCandidateIndicator() const
void Disconnect(IPropertyOwner *source, const IPropertyProvider *destination, RelationType layer=RelationType::Complete) const
virtual std::string GetDestinationRoleName() const =0
virtual DataRelationUIDVectorType GetRelationUIDs_DataLayer(const IPropertyProvider *source, const IPropertyProvider *destination, const InstanceIDVectorType &instances_IDLayer) const =0
static PropertyKeyPath GetRIIDestinationUIDPropertyKeyPath(const InstanceIDType &instanceID="")
@ None
No anti-aliasing.
#define mitkExceptionClassMacro(ClassName, SuperClassName)
Convenience macro for defining MITK exception subclasses.
Find image slices visible on a given plane.
@ Data
Only properties from the BaseData's property list.