Commit b01cf81a authored by Paul Asmuth's avatar Paul Asmuth
Browse files

hackety hack

parent 28affae1
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -12,10 +12,9 @@ namespace fnordmetric {
namespace query {

void DrawStatement::execute(ui::Canvas* canvas) {
  printf("execute!");
  switch (type_) {
    case T_BAR_CHART:
      return executeDrawable(new ui::BarChart(canvas));
      return executeDrawable(canvas->addChart<ui::BarChart>());
  }
}

+1 −0
Original line number Diff line number Diff line
@@ -60,6 +60,7 @@ public:
  template <typename T>
  void executeDrawable(T* drawable) {
    for (const auto& series_stmt : series_stmts_) {
  printf("execute!");
      series_stmt->executeDrawable(drawable);
    }
  }
+25 −8
Original line number Diff line number Diff line
@@ -74,10 +74,16 @@ public:
            case SValue::T_FLOAT:
            case SValue::T_INTEGER:
            case SValue::T_BOOL:
              return executeSeries<T, Series2D<double, double>>(drawable);
              return executeSeries<T, double, double>(
                  drawable,
                  x_ind,
                  y_ind);

            case SValue::T_STRING:
              return executeSeries<T, Series2D<double, std::string>>(drawable);
              return executeSeries<T, double, std::string>(
                  drawable,
                  x_ind,
                  y_ind);

            case SValue::T_UNDEFINED:
              break;
@@ -88,11 +94,16 @@ public:
            case SValue::T_FLOAT:
            case SValue::T_INTEGER:
            case SValue::T_BOOL:
              return executeSeries<T, Series2D<std::string, double>>(drawable);
              return executeSeries<T, std::string, double>(
                  drawable,
                  x_ind,
                  y_ind);

            case SValue::T_STRING:
              return executeSeries<T, Series2D<std::string, std::string>>(
                  drawable);
              return executeSeries<T, std::string, std::string>(
                  drawable,
                  x_ind,
                  y_ind);

            case SValue::T_UNDEFINED:
              break;
@@ -108,9 +119,15 @@ public:
    }
  }

  template <typename T, typename S>
  void executeSeries(T* drawable) {
    auto series = new S();
  template <typename T, typename D1, typename D2>
  void executeSeries(T* drawable, int x_ind, int y_ind) {
    auto series = new Series2D<D1, D2>();
    for (const auto& row : rows_) {
      series->addDatum(
          row[x_ind].getValue<D1>(),
          row[x_ind].getValue<D2>());
    }

    drawable->addSeries(series);
  }

+8 −0
Original line number Diff line number Diff line
@@ -229,5 +229,13 @@ SValue* SValue::fromToken(const Token* token) {
  }
}

template<> double SValue::getValue<double>() const {
  return 3;
}

template<> std::string SValue::getValue<std::string>() const {
  return "fnord";
}

}
}
+1 −0
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ public:

  static std::string makeUniqueKey(SValue* arr, size_t len);

  template <typename T> T getValue() const;
  kSValueType getType() const;
  int64_t getInteger() const;
  double getFloat() const;
Loading