Skip to content

Instantly share code, notes, and snippets.

@Fraser999
Last active August 29, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Fraser999/896b72b77ba8289c4dc2 to your computer and use it in GitHub Desktop.
Save Fraser999/896b72b77ba8289c4dc2 to your computer and use it in GitHub Desktop.
New Routing
#include <iostream>
#include <string>
using namespace std;
template <typename Child>
struct Routing
{
Routing() = delete;
explicit Routing(std::string s) : t(s) {}
void Get()
{
static_cast<Child*>(this)->FacadeGet();
}
void Hello() { std::cerr << "Heloo"; }
string t;
};
template <typename Child>
struct MaidMgr
{
void interface()
{
static_cast<Child*>(this)->FacadeGet();
CallHello();
}
void CallHello() {
static_cast<Child*>(this)->Hello();
}
void Get() { std::cerr << "MaidMgr Get\n";
static_cast<Child*>(this)->Hello();
}
};
template <typename Child>
struct DataMgr
{
void interface()
{
static_cast<Child*>(this)->FacadeGet();
CallHello();
}
void CallHello() {
static_cast<Child*>(this)->Hello();
}
};
struct Facade : public MaidMgr<Facade>, public DataMgr<Facade>, public Routing<Facade>
{
Facade() : Routing<Facade>("Whatever") {}
void FacadeGet()
{
cerr << "Derived implementation " << x << "\n";
}
string x = "test";
};
int main()
{
Facade d;
d.template MaidMgr<Facade>::Get();
// Routing<Facade> b{};
// b.interface();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment