Created
August 21, 2017 15:07
-
-
Save njlr/69482390798dee5b700e18e526f926dc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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