aboutsummaryrefslogtreecommitdiff
path: root/Src/Wasabi/api/config/items/attrfloat.h
blob: 056f0c466e1d78fe97808b2991e0aad5a75d8c11 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#ifndef _ATTRFLOAT_H
#define _ATTRFLOAT_H

#include "attribute.h"

// actually it's a double :)

class _float : public Attribute {
public:
  /**
    Optionally set the name and default value of 
    your configuration attribute during construction.
    
    @param name Name of the configuration attribute.
    @param default_val Default value.
  */
  _float(const wchar_t *name=NULL, double default_val=0.f) : Attribute(name) {
    setValueAsDouble(default_val, true);
  }
  
  /**
    Get the attribute type. This will return 
    a constant representing the attribute type.
    
    These constants can be: BOOL, FLOAT, STRING and INT.
    
    @see AttributeType
    @ret The attribute type.
  */
  virtual int getAttributeType() { return AttributeType::FLOAT; }
  
  /**
    Get the configuration group to be used to represent
    this attribute in the registry.
    
    @ret Config group to be used.
  */
  virtual const wchar_t *getConfigGroup() { return L"studio.configgroup.float"; }

  // convenience operators
  /**
    Get the value of the attribute.
  */
  operator double() { return getValueAsDouble(); }
  
  /**
    Set the value of the attribute.
  */
  double operator =(double newval) { return setValueAsDouble(newval) ? newval : getValueAsDouble(); }
};

#endif