Motiviations:
- By defining an abstract interfact, we can start to avoid distinct code for Nodes and BaseData, when its just about properties. In addition makes further refactoring in context of nodes easier.
- using this interface helps to introduce a more controlled/const usage of properties.
Proposed interface:
lang=cpp
class IPropertyOwner
{
public:
using ContextIDType = std::string;
using PropertyNamesType = std::vector<std::string>;
/** Gets a property by passed key.
@param contextID Can be used to specify a context. If nothing is set the default context is used. If a context is set, the property will be searched in this context.
@param defaultFallBack If set to true, the default context will always be checked if nothing was found in the specified context.
@return Returns empty pointer if no property was found for the key. Otherwise it returns the found property pointer.
@remark If you want to modify the property you have to clone it and set the modified clone.
*/
mitk::BaseProperty::ConstPointer GetProperty(const std::string& propertyKey, const ContextIDType& contextID = "", bool defaultFallBack = true) const = 0;
/** Sets a property by passed key and for the specified context.
@param contextID Can be used to specify a context. If nothing is set the default context is used. If a context is set, the property will be searched in this context.
@param defaultFallBack If set to true, the default context will always be checked if nothing was found in the specified context.
*/
void SetProperty(const std::string& propertyKey, BaseProperty* property, const ContextIDType& contextID = "", bool defaultFallBack = true) = 0;
/** Returns a list of all known properties in the specified context.
@param contextID Can be used to specify a context. If nothing is set the default context is used.
@param defaultFallBack If set to true, the result will be the merged (unified) names list of the default and the specified context.
*/
PropertyNamesType GetPropertyNames(const ContextIDType& contextID = "", bool defaultFallBack = false);
}
Should we also add direct Iterator support for the interface? Like BeginProperty() EndProperty()?