Medical Imaging Interaction Toolkit  2024.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 {
74  class MITKCORE_EXPORT PropertyRelationRuleBase : public itk::Object
75  {
76  public:
78  itkCloneMacro(Self);
79  itkCreateAnotherMacro(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 
98  static PropertyKeyPath GetRootKeyPath();
99 
100  using InstanceIDType = std::string;
105  static PropertyKeyPath GetRIIPropertyKeyPath(const std::string propName, const InstanceIDType& instanceID);
109  static PropertyKeyPath GetRIIRelationUIDPropertyKeyPath(const InstanceIDType& instanceID = "");
113  static PropertyKeyPath GetRIIRuleIDPropertyKeyPath(const InstanceIDType& instanceID = "");
117  static PropertyKeyPath GetRIIDestinationUIDPropertyKeyPath(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 
187  RelationUIDVectorType GetRelationUIDs(const IPropertyProvider *source, const IPropertyProvider *destination) const;
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:
267  PropertyRelationRuleBase() = default;
268  ~PropertyRelationRuleBase() override = default;
269 
270  using InstanceIDVectorType = std::vector<InstanceIDType>;
271  static InstanceIDType NULL_INSTANCE_ID();
272 
283  InstanceIDVectorType GetInstanceID_IDLayer(const IPropertyProvider *source,
284  const IPropertyProvider *destination) const;
285 
286  using DataRelationUIDVectorType = std::vector< std::pair<RelationUIDType, RuleIDType> >;
303  virtual DataRelationUIDVectorType GetRelationUIDs_DataLayer(const IPropertyProvider * source,
304  const IPropertyProvider * destination, const InstanceIDVectorType& instances_IDLayer) const = 0;
305 
308  RelationUIDType GetRelationUIDByInstanceID(const IPropertyProvider *source, const InstanceIDType &instanceID) const;
311  InstanceIDType GetInstanceIDByRelationUID(const IPropertyProvider *source,
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 
365  RuleIDType GetRuleIDByInstanceID(const IPropertyProvider *source,
366  const InstanceIDType &instanceID) const;
370  std::string GetDestinationUIDByInstanceID(const IPropertyProvider * source,
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 
380  const Identifiable* CastProviderAsIdentifiable(const mitk::IPropertyProvider* provider) const;
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
mitkException.h
mitk::Exception
An object of this class represents an exception of MITK. Please don't instantiate exceptions manually...
Definition: mitkException.h:45
mitk::PropertyRelationRuleBase::DataRelationUIDVectorType
std::vector< std::pair< RelationUIDType, RuleIDType > > DataRelationUIDVectorType
Definition: mitkPropertyRelationRuleBase.h:286
mitkIdentifiable.h
mitk::PropertyRelationRuleBase::RuleIDType
std::string RuleIDType
Definition: mitkPropertyRelationRuleBase.h:81
mitk::PropertyRelationRuleBase
Definition: mitkPropertyRelationRuleBase.h:74
mitk::Identifiable::UIDType
std::string UIDType
Definition: mitkIdentifiable.h:48
itk::SmartPointer< const Self >
mitkNodePredicateBase.h
mitk::PropertyKeyPath
Class that can be used to specify nested or wild carded property keys. E.g. for the use in context of...
Definition: mitkPropertyKeyPath.h:51
mitkClassMacroItkParent
#define mitkClassMacroItkParent(className, SuperClassName)
Definition: mitkCommon.h:45
mitk::PropertyRelationRuleBase::InstanceIDType
std::string InstanceIDType
Definition: mitkPropertyRelationRuleBase.h:100
mitk
Find image slices visible on a given plane.
Definition: RenderingTests.dox:1
mitk::PropertyRelationRuleBase::InstanceIDVectorType
std::vector< InstanceIDType > InstanceIDVectorType
Definition: mitkPropertyRelationRuleBase.h:270
mitk::AntiAliasing::None
@ None
mitkPropertyKeyPath.h
mitk::PropertyRelationRuleBase::RelationUIDType
Identifiable::UIDType RelationUIDType
Definition: mitkPropertyRelationRuleBase.h:82
mitkIPropertyOwner.h
mitk::PropertyRelationRuleBase::RelationVectorType
std::vector< RelationType > RelationVectorType
Definition: mitkPropertyRelationRuleBase.h:95
MitkCoreExports.h
mitk::NoPropertyRelationException
Definition: mitkPropertyRelationRuleBase.h:395
mitk::PropertyRelationRuleBase::RelationType
RelationType
Definition: mitkPropertyRelationRuleBase.h:86
mitk::PropertyRelationRuleBase::RelationUIDVectorType
std::vector< RelationUIDType > RelationUIDVectorType
Definition: mitkPropertyRelationRuleBase.h:83
mitk::Identifiable
Base class of identifiable objects.
Definition: mitkIdentifiable.h:45
mitkExceptionClassMacro
#define mitkExceptionClassMacro(ClassName, SuperClassName)
Definition: mitkExceptionMacro.h:62
mitk::IPropertyProvider
Definition: mitkIPropertyProvider.h:24
mitk::IPropertyOwner
Definition: mitkIPropertyOwner.h:22
MITKCORE_EXPORT
#define MITKCORE_EXPORT
Definition: MitkCoreExports.h:15