1
0

attrfloat.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #ifndef _ATTRFLOAT_H
  2. #define _ATTRFLOAT_H
  3. #include "attribute.h"
  4. // actually it's a double :)
  5. class _float : public Attribute {
  6. public:
  7. /**
  8. Optionally set the name and default value of
  9. your configuration attribute during construction.
  10. @param name Name of the configuration attribute.
  11. @param default_val Default value.
  12. */
  13. _float(const wchar_t *name=NULL, double default_val=0.f) : Attribute(name) {
  14. setValueAsDouble(default_val, true);
  15. }
  16. /**
  17. Get the attribute type. This will return
  18. a constant representing the attribute type.
  19. These constants can be: BOOL, FLOAT, STRING and INT.
  20. @see AttributeType
  21. @ret The attribute type.
  22. */
  23. virtual int getAttributeType() { return AttributeType::FLOAT; }
  24. /**
  25. Get the configuration group to be used to represent
  26. this attribute in the registry.
  27. @ret Config group to be used.
  28. */
  29. virtual const wchar_t *getConfigGroup() { return L"studio.configgroup.float"; }
  30. // convenience operators
  31. /**
  32. Get the value of the attribute.
  33. */
  34. operator double() { return getValueAsDouble(); }
  35. /**
  36. Set the value of the attribute.
  37. */
  38. double operator =(double newval) { return setValueAsDouble(newval) ? newval : getValueAsDouble(); }
  39. };
  40. #endif