Medical Imaging Interaction Toolkit  2018.4.99-389bf124
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 {
73  class MITKCORE_EXPORT PropertyRelationRuleBase : public itk::Object
74  {
75  public:
77  itkCloneMacro(Self);
78  itkCreateAnotherMacro(Self);
79 
80  using RuleIDType = std::string;
82  using RelationUIDVectorType = std::vector<RelationUIDType>;
83 
85  enum class RelationType
86  {
87  None = 0,
88  Implicit_Data = 1,
90  Connected_Data = 2,
93  Connected_ID = 4
94  };
95 
97  static PropertyKeyPath GetRootKeyPath();
98 
102  virtual RuleIDType GetRuleID() const = 0;
103 
105  virtual std::string GetDisplayName() const = 0;
106 
109  virtual std::string GetSourceRoleName() const = 0;
112  virtual std::string GetDestinationRoleName() const = 0;
113 
116  virtual bool IsAbstract() const;
117 
121  virtual bool IsSourceCandidate(const IPropertyProvider *owner) const;
122 
126  virtual bool IsDestinationCandidate(const IPropertyProvider *owner) const;
127 
131  bool IsSource(const IPropertyProvider *owner) const;
132 
137  RelationType HasRelation(const IPropertyProvider *source, const IPropertyProvider *destination) const;
138 
143  RelationUIDVectorType GetExistingRelations(const IPropertyProvider *source) const;
144 
152  RelationUIDVectorType GetRelationUIDs(const IPropertyProvider *source, const IPropertyProvider *destination) const;
153 
164  RelationUIDType GetRelationUID(const IPropertyProvider *source, const IPropertyProvider *destination) const;
165 
168  NodePredicateBase::ConstPointer GetSourceCandidateIndicator() const;
171  NodePredicateBase::ConstPointer GetDestinationCandidateIndicator() const;
174  NodePredicateBase::ConstPointer GetConnectedSourcesDetector() const;
179  NodePredicateBase::ConstPointer GetSourcesDetector(
180  const IPropertyProvider *destination, RelationType minimalRelation = RelationType::Implicit_Data) const;
185  NodePredicateBase::ConstPointer GetDestinationsDetector(
186  const IPropertyProvider *source, RelationType minimalRelation = RelationType::Implicit_Data) const;
193  NodePredicateBase::ConstPointer GetDestinationDetector(const IPropertyProvider *source,
194  RelationUIDType relationUID) const;
195 
200  void Disconnect(IPropertyOwner *source, const IPropertyProvider *destination) const;
205  void Disconnect(IPropertyOwner *source, RelationUIDType relationUID) const;
206 
207  protected:
208  PropertyRelationRuleBase() = default;
209  ~PropertyRelationRuleBase() override = default;
210 
211  using InstanceIDType = std::string;
212  using InstanceIDVectorType = std::vector<InstanceIDType>;
213  static InstanceIDType NULL_INSTANCE_ID();
214 
225  InstanceIDVectorType GetInstanceID_IDLayer(const IPropertyProvider *source,
226  const IPropertyProvider *destination) const;
227 
239  virtual InstanceIDVectorType GetInstanceID_datalayer(const IPropertyProvider *source,
240  const IPropertyProvider *destination) const = 0;
241 
249  virtual bool HasImplicitDataRelation(const IPropertyProvider *source,
250  const IPropertyProvider *destination) const = 0;
251 
254  RelationUIDType GetRelationUIDByInstanceID(const IPropertyProvider *source, const InstanceIDType &instanceID) const;
257  InstanceIDType GetInstanceIDByRelationUID(const IPropertyProvider *source,
258  const RelationUIDType &relationUID) const;
259 
269  RelationUIDType Connect(IPropertyOwner *source, const IPropertyProvider *destination) const;
270 
280  virtual void Connect_datalayer(IPropertyOwner *source,
281  const IPropertyProvider *destination,
282  const InstanceIDType &instanceID) const = 0;
283 
290  virtual void Disconnect_datalayer(IPropertyOwner *source, const InstanceIDType &instanceID) const = 0;
291 
295  virtual bool IsSupportedRuleID(const RuleIDType& ruleID) const;
296 
300  std::string GetRIIPropertyRegEx(const std::string propName = "", const InstanceIDType &instanceID = "") const;
301 
304  static InstanceIDType GetInstanceIDByPropertyName(const std::string propName);
305 
309  RuleIDType GetRuleIDByInstanceID(const IPropertyProvider *source,
310  const InstanceIDType &instanceID) const;
311 
312  itk::LightObject::Pointer InternalClone() const override;
313 
314  static std::vector<std::string> GetPropertyKeys(const mitk::IPropertyProvider *owner);
315 
316  private:
318  static RelationUIDType CreateRelationUID();
319 
325  InstanceIDType CreateNewRelationInstance(IPropertyOwner *source, const RelationUIDType &relationUID) const;
326  };
327 
330  {
331  public:
333  };
334 
335 } // namespace mitk
336 
337 #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:49
#define mitkExceptionClassMacro(ClassName, SuperClassName)
std::vector< RelationUIDType > RelationUIDVectorType
std::vector< InstanceIDType > InstanceIDVectorType
Class that can be used to specify nested or wild carded property keys. E.g. for the use in context of...