#pragma once
#include "ExceptionCode.h"
#include "SVGPropertyTearOff.h"
namespace WebCore {
class SVGNumber : public SVGPropertyTearOff<float> {
public:
static Ref<SVGNumber> create(SVGAnimatedProperty& animatedProperty, SVGPropertyRole role, float& value)
{
return adoptRef(*new SVGNumber(animatedProperty, role, value));
}
static Ref<SVGNumber> create(const float& initialValue = { })
{
return adoptRef(*new SVGNumber(initialValue));
}
static Ref<SVGNumber> create(const float* initialValue)
{
return adoptRef(*new SVGNumber(initialValue));
}
template<typename T> static ExceptionOr<Ref<SVGNumber>> create(ExceptionOr<T>&& initialValue)
{
if (initialValue.hasException())
return initialValue.releaseException();
return create(initialValue.releaseReturnValue());
}
float valueForBindings()
{
return propertyReference();
}
ExceptionOr<void> setValueForBindings(float value)
{
if (isReadOnly())
return Exception { NO_MODIFICATION_ALLOWED_ERR };
propertyReference() = value;
commitChange();
return { };
}
private:
SVGNumber(SVGAnimatedProperty& animatedProperty, SVGPropertyRole role, float& value)
: SVGPropertyTearOff<float>(&animatedProperty, role, value)
{
}
explicit SVGNumber(const float& initialValue)
: SVGPropertyTearOff<float>(initialValue)
{
}
explicit SVGNumber(const float* initialValue)
: SVGPropertyTearOff<float>(initialValue)
{
}
};
}