Skip to content

Instantly share code, notes, and snippets.

@njlr
Created August 21, 2017 15:07
Show Gist options
  • Save njlr/69482390798dee5b700e18e526f926dc to your computer and use it in GitHub Desktop.
Save njlr/69482390798dee5b700e18e526f926dc to your computer and use it in GitHub Desktop.
struct Renderable {
 virtual Image render(unsigned const width) const = 0;
  virtual ~Renderable() {}
};
template<class T>
struct Model : Renderable {
  T data;
  Model(T const& data)
  : data{ data }
  {}
  virutal ComponentModel() {}
};
struct Component : Renderable {
  template<class T>
  Component(T data) 
  : pimpl{make_shared<Model<T>>(data)}
  {}
 
  virtual Image render(unsigned const width) const {
  return pimpl->render(width);
  }
 
 shared_ptr<Renderable> pimpl; 
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment