![Quality Gate Status](https://camo.githubusercontent.com/c9c548fedec25043629a02e905bd6910189033b4bc27cf6334038eacf90836fd/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d786f727a35375f536572766963654c6f6361746f72266d65747269633d616c6572745f737461747573)
#include "ServiceLocator/ServiceLocator.hpp"
#include <iostream>
class A {
public:
A() {
std::cout << __func__ << std::endl;
}
~A() {
std::cout << __func__ << std::endl;
}
A(const A &other) = delete;
A(A &&other) = delete;
A &operator=(const A &other) = delete;
A &operator=(A &&other) = delete;
};
class B {
public:
B() {
std::cout << __func__ << std::endl;
}
~B() {
std::cout << __func__ << std::endl;
}
B(const B &other) = delete;
B(B &&other) = delete;
B &operator=(const B &other) = delete;
B &operator=(B &&other) = delete;
};
int main() {
ServiceLocator serviceLocator;
serviceLocator.SetInstance<A>();
serviceLocator.SetInstance<B>();
std::cout << serviceLocator.GetInstance<A>() << std::endl;
std::cout << serviceLocator.GetInstance<B>() << std::endl;
std::cout << serviceLocator.GetInstance<A>() << std::endl;
std::cout << serviceLocator.GetInstance<B>() << std::endl;
serviceLocator.Clear();
std::cout << serviceLocator.GetInstance<A>() << std::endl;
std::cout << serviceLocator.GetInstance<B>() << std::endl;
return 0;
}
A
B
00000241A0CA9850
00000241A0CA9550
00000241A0CA9850
00000241A0CA9550
~B
~A
0000000000000000
0000000000000000
git clone https://github.com/microsoft/vcpkg.git ~/vcpkg
~/vcpkg/bootstrap-vcpkg.sh
git clone https://github.com/xorz57/ServiceLocator.git
cd ServiceLocator
cmake -B build -DCMAKE_BUILD_TYPE=Release -S . -DCMAKE_TOOLCHAIN_FILE=~/vcpkg/scripts/buildsystems/vcpkg.cmake
cmake --build build --config Release
ctest --build-config Release
git clone https://github.com/microsoft/vcpkg.git C:/vcpkg
C:/vcpkg/bootstrap-vcpkg.bat
C:/vcpkg/vcpkg.exe integrate install
git clone https://github.com/xorz57/ServiceLocator.git
cd ServiceLocator
cmake -B build -DCMAKE_BUILD_TYPE=Release -S . -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake
cmake --build build --config Release
ctest --build-config Release