Page MenuHomePhabricator | MITK

Introduce IPropertyRelations
Closed, ResolvedPublic

Description

This service interface allows to register manage rules that define releations based on properties (and ther values).

Draft for the interface:

class MITKCORE_EXPORT IPropertyRelations
{
public:
  virtual ~IPropertyRelations();

  using RuleResultType = std::list<PropertyRelationRuleBase::ConstPointer>;
  using RuleIDType = PropertyRelationRuleBase::RuleIDType;
  
  /** \brief Add rule for a specific relation.
    * If there is already a property rule instance  it won't be added.
    * Rule instances are regarded equal, if the rule ID is equal.
    * You may enforce to overwrite the old equal rule
    * by the overwrite parameter.
    *
    * \param[in] rule Relation rule of the property.
    * \param[in] overwrite Overwrite already existing relation rule.
    * \return True if relation rule was added successfully.
    */
  virtual bool AddRule(const PropertyRelationRuleBase *rule, bool overwrite = false) = 0;

  /** \brief Get all relation rules where the passed source is realy a source of. (PropertyRelationRuleBase::IsSource() would return true)
    * \param[in] source Pointer to the instance that should be checked as source for the searched rules.
    * \return Property relation rules or empty list if no relation rules are available.
    */
  virtual RuleResultType GetRuleForSource(const IPropertyOwner* source) const = 0;

  /** \brief Get all relation rules that would accept the passed IPropertOwner as source.
    * \param[in] sourceCandidate Pointer to the instance that should be checked to be a suitable source.
    * \return Property relation rules or empty list if no relation rules are available.
    */
  virtual RuleResultType GetRuleForSourceCandidate(const IPropertyOwner* sourceCandidate) const = 0;

  /** \brief Get all relation rules that would accept the passed IPropertOwner as destination.
    * \param[in] destCandidate Pointer to the instance that should be checked to be a suitable destination.
    * \return Property relation rules or empty list if no relation rules are available.
    */
  virtual RuleResultType GetRulesForDestinationCandidate(const IPropertyOwner* destCandidate) const = 0;

  /** \brief Get the relation rule that has the specfied ruleID.
  *
  * \return Property relation rule or null pointer, if no relation rule is available.
  */
  virtual PropertyRelationRuleBase::ConstPointer GetRule(const RuleIDType &ruleID) const = 0;

  /** \brief Check if a passed instance has defined relation covered by the registered rules.
    *
    * \param[in] source Pointer to the instance that should be checked as source for the searched rules.
    * \return True if the property has relations of registered rules, false otherwise.
    */
  virtual bool HasRuleForSource(const IPropertyOwner* source) const = 0;

  /** \brief Remove all relation rule.
    */
  virtual void RemoveAllRules() = 0;

  /** \brief Remove relation rule instance with the passed ID. If rule does not exist nothing happens.
    */
  virtual void RemoveRule(const RuleIDType &ruleID) = 0;

};

Event Timeline

floca created this task.Nov 17 2017, 1:47 PM
floca updated the task description. (Show Details)Nov 22 2017, 5:04 PM
kislinsk removed kislinsk as the assignee of this task.Dec 17 2017, 8:59 PM
kislinsk added a subscriber: kislinsk.
floca closed this task as Resolved.Feb 2 2018, 5:10 PM
floca claimed this task.