SVGAnimatedEnumerationPropertyTearOff.h [plain text]
#ifndef SVGAnimatedEnumerationPropertyTearOff_h
#define SVGAnimatedEnumerationPropertyTearOff_h
#if ENABLE(SVG)
#include "SVGAnimatedStaticPropertyTearOff.h"
#include "SVGException.h"
#include "SVGPropertyTraits.h"
namespace WebCore {
template<typename EnumType>
class SVGAnimatedEnumerationPropertyTearOff : public SVGAnimatedStaticPropertyTearOff<unsigned> {
public:
virtual void setBaseVal(const unsigned& property, ExceptionCode& ec)
{
if (!property || property > SVGPropertyTraits<EnumType>::highestEnumValue()) {
ec = SVGException::SVG_INVALID_VALUE_ERR;
return;
}
SVGAnimatedStaticPropertyTearOff<unsigned>::setBaseVal(property, ec);
}
static PassRefPtr<SVGAnimatedEnumerationPropertyTearOff<EnumType> > create(SVGElement* contextElement, const QualifiedName& attributeName, AnimatedPropertyType animatedPropertyType, EnumType& property)
{
ASSERT(contextElement);
return adoptRef(new SVGAnimatedEnumerationPropertyTearOff<EnumType>(contextElement, attributeName, animatedPropertyType, reinterpret_cast<unsigned&>(property)));
}
EnumType& currentAnimatedValue()
{
unsigned& animatedValue = SVGAnimatedStaticPropertyTearOff<unsigned>::currentAnimatedValue();
ASSERT(animatedValue <= SVGPropertyTraits<EnumType>::highestEnumValue());
return reinterpret_cast<EnumType&>(animatedValue);
}
private:
SVGAnimatedEnumerationPropertyTearOff(SVGElement* contextElement, const QualifiedName& attributeName, AnimatedPropertyType animatedPropertyType, unsigned& property)
: SVGAnimatedStaticPropertyTearOff<unsigned>(contextElement, attributeName, animatedPropertyType, property)
{
}
};
}
#endif // ENABLE(SVG)
#endif // SVGAnimatedEnumerationPropertyTearOff_h