Commit 28affae1 authored by Paul Asmuth's avatar Paul Asmuth
Browse files

template hackery

parent 0b63fc32
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ protected:
template <typename X, typename Y>
class Series2D : public Series {
public:
  Series2D() : Series2D("unnamed") {}
  Series2D(const std::string& name) : Series(name) {}

  void addDatum(X x, Y y) {
@@ -54,6 +55,7 @@ protected:
template <typename X, typename Y, typename Z>
class Series3D : public Series {
public:
  Series3D() : Series3D("unnamed") {}
  Series3D(const std::string& name) : Series(name) {}

  void addDatum(X x, Y y, Z z) {
+5 −0
Original line number Diff line number Diff line
@@ -6,12 +6,17 @@
 */
#include "drawstatement.h"
#include "../ui/canvas.h"
#include "../ui/barchart.h"

namespace fnordmetric {
namespace query {

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

}
+7 −0
Original line number Diff line number Diff line
@@ -57,6 +57,13 @@ public:

  void execute(ui::Canvas* canvas);

  template <typename T>
  void executeDrawable(T* drawable) {
    for (const auto& series_stmt : series_stmts_) {
      series_stmt->executeDrawable(drawable);
    }
  }

protected:
  std::vector<SeriesStatement*> series_stmts_;
  //std::vector<AxisStatement*> axis_stmts_;
+5 −0
Original line number Diff line number Diff line
@@ -85,6 +85,11 @@ ResultList* Query::getResultList(size_t index) const {
  return results_[index].get();
}

ui::Canvas* Query::getChart(size_t index) const {
  assert(index < charts_.size()); // FIXPAUL
  return charts_[index].get();
}

/*
bool Query::execute(ChartRenderTarget* target) {
  Drawable* drawable = nullptr;
+3 −1
Original line number Diff line number Diff line
@@ -858,7 +858,7 @@ public:
        ""
        "  CREATE SERIES WITH"
        "    SELECT"
        "      one, two"
        "      one AS x, two AS y"
        "    FROM"
        "      testtable;",
 /*       ""
@@ -876,6 +876,8 @@ public:
        &repo);

    query.execute();
    auto chart = query.getChart(0);
    chart->renderSVG();
  }

};
Loading