Medical Imaging Interaction Toolkit  2021.02.99-e55a5d2f
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> GetReleationPropertyPaths(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
#define MITKCORE_EXPORT
DataCollection - Class to facilitate loading/accessing structured data.
An object of this class represents an exception of MITK. Please don&#39;t instantiate exceptions manually...
Definition: mitkException.h:45
#define mitkClassMacroItkParent(className, SuperClassName)
Definition: mitkCommon.h:45
#define mitkExceptionClassMacro(ClassName, SuperClassName)
std::vector< RelationUIDType > RelationUIDVectorType
std::vector< std::pair< RelationUIDType, RuleIDType > > DataRelationUIDVectorType
std::vector< InstanceIDType > InstanceIDVectorType
std::vector< RelationType > RelationVectorType
Class that can be used to specify nested or wild carded property keys. E.g. for the use in context of...
Base class of identifiable objects.