Medical Imaging Interaction Toolkit  2025.12.02
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 {
74  class MITKCORE_EXPORT PropertyRelationRuleBase : public itk::Object
75  {
76  public:
78  itkCloneMacro(Self);
80 
81  using RuleIDType = std::string;
83  using RelationUIDVectorType = std::vector<RelationUIDType>;
84 
86  enum class RelationType
87  {
88  None = 0,
89  Data = 1,
92  ID = 2,
93  Complete = 3
94  };
95  using RelationVectorType = std::vector<RelationType>;
96 
99 
100  using InstanceIDType = std::string;
105  static PropertyKeyPath GetRIIPropertyKeyPath(const std::string propName, const InstanceIDType& instanceID);
118 
122  virtual RuleIDType GetRuleID() const = 0;
123 
125  virtual std::string GetDisplayName() const = 0;
126 
129  virtual std::string GetSourceRoleName() const = 0;
132  virtual std::string GetDestinationRoleName() const = 0;
133 
136  virtual bool IsAbstract() const;
137 
141  virtual bool IsSourceCandidate(const IPropertyProvider *owner) const;
142 
146  virtual bool IsDestinationCandidate(const IPropertyProvider *owner) const;
147 
150  bool IsSource(const IPropertyProvider *owner) const;
151 
159  RelationVectorType GetRelationTypes(const IPropertyProvider* source, const IPropertyProvider* destination) const;
160 
172  bool HasRelation(const IPropertyProvider *source, const IPropertyProvider *destination, RelationType requiredRelation = RelationType::None) const;
173 
180  RelationUIDVectorType GetExistingRelations(const IPropertyProvider *source, RelationType layer = RelationType::None) const;
181 
188 
198  RelationUIDType GetRelationUID(const IPropertyProvider *source, const IPropertyProvider *destination) const;
199 
202  NodePredicateBase::ConstPointer GetSourceCandidateIndicator() const;
205  NodePredicateBase::ConstPointer GetDestinationCandidateIndicator() const;
208  NodePredicateBase::ConstPointer GetConnectedSourcesDetector() const;
214  NodePredicateBase::ConstPointer GetSourcesDetector(
215  const IPropertyProvider *destination, RelationType exclusiveRelation = RelationType::None) const;
221  NodePredicateBase::ConstPointer GetDestinationsDetector(
222  const IPropertyProvider *source, RelationType exclusiveRelation = RelationType::None) const;
229  NodePredicateBase::ConstPointer GetDestinationDetector(const IPropertyProvider *source,
230  RelationUIDType relationUID) const;
231 
242  void Disconnect(IPropertyOwner *source, const IPropertyProvider *destination, RelationType layer = RelationType::Complete) const;
254  void Disconnect(IPropertyOwner *source, RelationUIDType relationUID, RelationType layer = RelationType::Complete) const;
255 
263  std::vector<PropertyKeyPath> GetRelationPropertyPaths(const IPropertyProvider* source,
264  RelationUIDType relationUID, RelationType layer = RelationType::Data) const;
265 
266  protected:
268  ~PropertyRelationRuleBase() override = default;
269 
270  using InstanceIDVectorType = std::vector<InstanceIDType>;
272 
284  const IPropertyProvider *destination) const;
285 
286  using DataRelationUIDVectorType = std::vector< std::pair<RelationUIDType, RuleIDType> >;
304  const IPropertyProvider * destination, const InstanceIDVectorType& instances_IDLayer) const = 0;
305 
312  const RelationUIDType &relationUID) const;
313 
323  RelationUIDType Connect(IPropertyOwner *source, const IPropertyProvider *destination) const;
324 
336  virtual void Connect_datalayer(IPropertyOwner *source,
337  const IPropertyProvider *destination,
338  const InstanceIDType &instanceID) const = 0;
339 
346  virtual void Disconnect_datalayer(IPropertyOwner *source, const RelationUIDType & relationUID) const = 0;
347 
351  virtual bool IsSupportedRuleID(const RuleIDType& ruleID) const;
352 
356  std::string GetRIIPropertyRegEx(const std::string propName = "", const InstanceIDType &instanceID = "") const;
357 
360  static InstanceIDType GetInstanceIDByPropertyName(const std::string propName);
361 
366  const InstanceIDType &instanceID) const;
371  const InstanceIDType & instanceID) const;
372 
373  itk::LightObject::Pointer InternalClone() const override;
374 
377  static std::vector<std::string> GetPropertyKeys(const IPropertyProvider *owner);
378 
381 
382  private:
384  static RelationUIDType CreateRelationUID();
385 
391  InstanceIDType CreateNewRelationInstance(IPropertyOwner *source, const RelationUIDType &relationUID) const;
392  };
393 
396  {
397  public:
399  };
400 
401 } // namespace mitk
402 
403 #endif
#define MITKCORE_EXPORT
An object of this class represents an exception of MITK. Please don't instantiate exceptions manually...
Definition: mitkException.h:46
Base class of identifiable objects.
Class that can be used to specify nested or wild carded property keys. E.g. for the use in context of...
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
RelationUIDVectorType GetExistingRelations(const IPropertyProvider *source, RelationType layer=RelationType::None) const
const Identifiable * CastProviderAsIdentifiable(const mitk::IPropertyProvider *provider) const
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)
itk::LightObject::Pointer InternalClone() const override
~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="")
#define mitkExceptionClassMacro(ClassName, SuperClassName)
Find image slices visible on a given plane.