Page MenuHomePhabricator

PropertyRuleClass for "simple" ID relations
Closed, ResolvedPublic


Base class for PropertyRelationRules.
Other informations are directly encoded in the documentation of the draft proposal.
The new class is basically just used to define ruleID and display name. The rest is already handled by the base class :).

Proposal for the interface draft:

class GenericIDReleationRule : public PropertyRelationRuleBase
  mitkClassMacroItkParent(GenericIDReleationRule, PropertyRelationRuleBase);
  using RuleIDType = std::string;
  using RelationIDType = IIdentifiable::UIDType;
  using RelationIDVectorType = std::vector<RelationIDType>;
    /** Returns an ID string that identifies the rule class. */
  virtual RuleIDType GetRuleID() const;
  /** Returns a humanreadable string that can be used to described the rule. Must not be unique.*/
  virtual std::string GetDisplayName() const;  

  GenericIDReleationRule(RuleIDType ruleID, const std::string& displayName = "");
  /** Is called by HasRelation() if no relation is evident in the ID-layer.
   Implement this method to deduce if the passed instances have a relation of type
   None, Implicit_Data or Connected_Data.
   @pre source must be a pointer to a valid IPropertyOwner instance.
   @pre destination must be a pointer to a valid IPropertyOwner instance.
  virtual RelationType HasRelation_datalayer(const IPropertyOwner *source, const IPropertyOwner *destination) const;

  /** Is called by GetRelationID() if 1) the relation ID cannot be deduced on the ID-layer
   and 2) there are relationID-properties that indicated at least a connected relation.
   Implement this method to check which existing relations as Connected_Data exists between
   both passed instances. If the passed instances have no
   explicit relation (so of type Connected_Data) no ID can be deduced an exception
   will be thrown.
   @pre source must be a pointer to a valid IPropertyOwner instance.
   @pre destination must be a pointer to a valid IPropertyOwner instance.
   @pre Source and destination have a relation of type Connected_Data or Connected_ID*/
  virtual RelationIDType GetRelationID_datalayer(const IPropertyOwner *source, const IPropertyOwner *destination) const;
  /**Is called by Connect() to ensure that source has correctly set properties to resample
   the relation. This means that the method should set the properties that describe and encode the relation (relation-properties),
   as well as the relationID-properties that are needed to identify which properties are relation-properties of this relations.
   If the passed instance are already connected the old connection will be overwritten (and raised to the highest possible connection level)
   Connect() will ensure that source and destination are valid pointers.
   @param relationID is the ID for the relation that should be connected. It is queried by Connect() via GetRelationID() or created if needed.
   @pre source must be a valid instance.
   @pre destination must be a valid instance.*/
  virtual void Connect_datalayer(IPropertyOwner *source, const IPropertyOwner *destination, RelationIDType relationID) const;

  /**This method is called by Disconnect() to remove all properties of the relation from the source.
   @remark All relationID-properties of this relation will removed by Disconnect() after this method call.
   If the relationID is not part of the source. Nothing will be changed. Disconnect() ensures that source is a valid pointer if called.
   @pre source must be a valid instance.*/
  virtual void Disconnect_datalayer(IPropertyOwner *source, RelationIDType relationID) const;

Remarks to implementation details:
All protected data layer methods can just be empty stubs because the rule has no data layer and just works on IDs.