Last active
August 29, 2015 14:14
-
-
Save Fraser999/896b72b77ba8289c4dc2 to your computer and use it in GitHub Desktop.
New Routing
This file contains 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
#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