Created
August 8, 2019 06:44
-
-
Save foodtooth/d7dc5b48dce5647719d9bd4cbcc2ec40 to your computer and use it in GitHub Desktop.
Singleton example, and Interface basic concept
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
#ifndef RESPONSE_MANAGER_H | |
#define RESPONSE_MANAGER_H | |
#include <unordered_map> | |
#include <string> | |
#include <memory> | |
class ResponseInterface { | |
public: | |
ResponseInterface(const ResponseInterface&) = default; | |
ResponseInterface(ResponseInterface&&) = default; | |
ResponseInterface& operator=(const ResponseInterface&) = default; | |
ResponseInterface& operator=(ResponseInterface&&) = default; | |
ResponseInterface() = default; | |
virtual ~ResponseInterface() = default; | |
}; | |
template <typename MRes> | |
class ResponseManager final { | |
public: | |
ResponseManager(const ResponseManager&) = delete; | |
ResponseManager(ResponseManager&&) = delete; | |
ResponseManager& operator=(const ResponseManager&) = delete; | |
ResponseManager& operator=(ResponseManager&&) = delete; | |
static ResponseManager& GetInstance() { | |
static ResponseManager instance; | |
return instance; | |
} | |
private: | |
ResponseManager() = default; | |
~ResponseManager() = default; | |
std::unordered_map<std::string, std::unique_ptr<ResponseInterface>> responses_map_; | |
}; | |
#endif // RESPONSE_MANAGER_H |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment