Last active
June 13, 2019 11:44
-
-
Save qrealka/9ffbe8ec4d047f4f4ee3ae6b72c1df3b to your computer and use it in GitHub Desktop.
Badge pattern
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
template<typename T> | |
class Badge { | |
friend T; | |
Badge() {} | |
}; | |
class Device; | |
class VFS { | |
public: | |
static VFS& the() { static VFS instance; return instance; } | |
void register_device(Device&, Badge<Device>) {} | |
void unregister_device(Device&, Badge<Device>){} | |
}; | |
class Device { | |
public: | |
Device() | |
{ | |
VFS::the().register_device(*this, {}); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment