Commit 9178ec79 authored by Paul Asmuth's avatar Paul Asmuth
Browse files

rename Element interface to ElementConfig

parent 268fb35c
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -21,10 +21,10 @@ struct Context {
};

template <typename T>
Status stack_head(Context* ctx, T** head);
Status stack_head_config(Context* ctx, T** head);

template <typename T>
Status stack_head(const Context& ctx, T const** head);
Status stack_head_config(const Context& ctx, T const** head);

} // namespace signaltk

+4 −4
Original line number Diff line number Diff line
@@ -12,22 +12,22 @@
namespace signaltk {

template <typename T>
Status stack_head(Context* ctx, T** head) {
Status stack_head_config(Context* ctx, T** head) {
  if (ctx->elements.empty()) {
    return Status::ERROR_INVALID_ELEM;
  }

  *head = static_cast<T*>(ctx->elements.top().get());
  *head = static_cast<T*>(ctx->elements.top().config.get());
  return OK;
}

template <typename T>
Status stack_head(const Context& ctx, T const** head) {
Status stack_head_config(const Context& ctx, T const** head) {
  if (ctx.elements.empty()) {
    return Status::ERROR_INVALID_ELEM;
  }

  *head = static_cast<const T*>(ctx.elements.top().get());
  *head = static_cast<const T*>(ctx.elements.top().config.get());
  return OK;
}

+5 −5
Original line number Diff line number Diff line
@@ -12,13 +12,13 @@

namespace signaltk {

struct Element {

  virtual ~Element() = default;

struct ElementConfig {
  virtual ~ElementConfig() = default;
};

using ElementRef = std::unique_ptr<Element>;
struct ElementRef {
  std::unique_ptr<ElementConfig> config;
};

} // namespace signaltk
+5 −5
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@ AxisDefinition::AxisDefinition() :

Status plot_axis_add(Context* ctx, AxisPosition pos) {
  PlotConfig* elem;
  if (auto rc = stack_head(ctx, &elem); rc) {
  if (auto rc = stack_head_config(ctx, &elem); rc) {
    return rc;
  }

@@ -52,7 +52,7 @@ Status plot_axis_add(Context* ctx, AxisPosition pos) {

Status plot_axis_addtick(Context* ctx, float offset) {
  PlotConfig* elem;
  if (auto rc = stack_head(ctx, &elem); rc) {
  if (auto rc = stack_head_config(ctx, &elem); rc) {
    return rc;
  }

@@ -63,7 +63,7 @@ Status plot_axis_addtick(Context* ctx, float offset) {

Status plot_axis_addlabel(Context* ctx, float offset, const char* label) {
  PlotConfig* elem;
  if (auto rc = stack_head(ctx, &elem); rc) {
  if (auto rc = stack_head_config(ctx, &elem); rc) {
    return rc;
  }

@@ -183,8 +183,8 @@ Status plot_render_axis_horizontal(
}

Status plot_render_axis(Context* ctx, int i) {
  PlotConfig* elem;
  if (auto rc = stack_head(ctx, &elem); rc) {
  const PlotConfig* elem;
  if (auto rc = stack_head_config(*ctx, &elem); rc) {
    return rc;
  }

+1 −1
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@

namespace signaltk {

struct PlotConfig : public Element {
struct PlotConfig : public ElementConfig {
  static constexpr const char* ID = "plot";

  PlotDomain x_domain;
Loading