lgrosz / ClimbLib

https://lgrosz.github.io/ClimbLib/
GNU Lesser General Public License v3.0
0 stars 0 forks source link

Private-implementation pattern for grades #42

Closed lgrosz closed 2 months ago

lgrosz commented 2 months ago

Currently, the private implementation pattern for grades functions well. However.. if I were to say introduce "VB" as a hueco-grade.. I'm not sure what I'd do. It isn't common for VBs to have + or - associated with them, so I'd need to introduce another modifier GRADE_HUECO_MODIFIER_NONE.. Then the GradeHueco_value method wouldn't have a well-defined return.. unless it were to become something like...

typedef enum {
  GradeHuecoType_BASIC,
  GradeHuecoType_NUMERIC
} GradeHuecoType;

struct {
    GradeHuecoType type;
    union {
      unsigned int value;
    } data;
};

at which point I feel like I should just change and expose a new definition for GradeHueco...

typedef enum {
  GradeHuecoType_BASIC,
  GradeHuecoType_NUMERIC
} GradeHuecoType;

typedef enum {
  GradeHuecoModifier_MINUS,
  GradeHuecoModifier_NONE,
  GradeHuecoModifier_PLIUS,
} GradeHuecoModifier;

struct {
    GradeHuecoType type;
    union {
      struct {
        unsigned int value;
        GradeHuecoModifier modifier;
      } numeric;
    } data;
};