diff --git a/test/DeletableSingleton/Makefile b/test/DeletableSingleton/Makefile new file mode 100755 index 0000000..30614f2 --- /dev/null +++ b/test/DeletableSingleton/Makefile @@ -0,0 +1,10 @@ +BIN = DeletableSingleton +CXXFLAGS = -Wall -Wold-style-cast -Wundef -Wsign-compare -Wconversion -Wpointer-arith -pedantic -O2 +CPPFLAGS = -I../../include -DNDEBUG +LDFLAGS = -L../../lib +LDLIBS = -lloki + +.PHONY: build clean +build: $(BIN) +clean: + rm -f $(BIN) $(BIN).exe $(BIN).o diff --git a/test/DeletableSingleton/make.msvc.bat b/test/DeletableSingleton/make.msvc.bat new file mode 100755 index 0000000..df77139 --- /dev/null +++ b/test/DeletableSingleton/make.msvc.bat @@ -0,0 +1,10 @@ + +:: DeletableSingleton.cpp + +cl -c -Zm200 -O2 -DNDEBUG -MT -EHsc -GR -W0 -wd4710 -I"." -I"..\..\include" DeletableSingleton.cpp + +link /NOLOGO /SUBSYSTEM:CONSOLE /incremental:no /OUT:"DeletableSingleton-msvc.exe" ..\..\lib\loki.lib DeletableSingleton.obj + + +del *.obj + diff --git a/test/Makefile b/test/Makefile index 2f2b624..4ae577b 100755 --- a/test/Makefile +++ b/test/Makefile @@ -1,4 +1,4 @@ -SUBTARGETS = Factory Longevity OrderedStatic Pimpl RegressionTest \ +SUBTARGETS = DeletableSingleton Factory Longevity OrderedStatic Pimpl RegressionTest \ SafeFormat ScopeGuard Singleton SmallObj Visitor flex_string SUBTARGETS_CLEAN = $(foreach SUBTARGET,$(SUBTARGETS),$(SUBTARGET)-clean) diff --git a/test/Singleton/DeletableSingleton.cpp b/test/Singleton/DeletableSingleton.cpp deleted file mode 100755 index 5918aa6..0000000 --- a/test/Singleton/DeletableSingleton.cpp +++ /dev/null @@ -1,80 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// The Loki Library -// Copyright (c) 2005 by Curtis Krauskopf -// Copyright (c) 2005 by Peter Kuemmel -// -// Code covered by the MIT License -// The authors make no representations about the suitability of this software -// for any purpose. It is provided "as is" without express or implied warranty. -//////////////////////////////////////////////////////////////////////////////// - -// Show an example of a Loki policy that uses DeletableSingleton. -// -// Expected output: -// -// LogClass::LogClass() -// LogClass singleton instantiated -// Going to manually delete LogBook. -// LogClass::~LogClass() -// LogClass::LogClass() -// LogClass reinstantiated. -// Going to terminate program now. -// LogClass::~LogClass() -// - -#include -#include // for Loki::SingletonHolder - -using namespace std; // okay for small programs -using namespace Loki; // okay for small programs - -// A singleton LogClass object derived from the Example class. -// Its longevity is set by the user on the command line. -// -class LogClass -{ -public: - LogClass() - { - print("LogClass::LogClass()"); - }; - ~LogClass() - { - print("LogClass::~LogClass()"); - } - void print(const char *s) - { - cout << s << endl; - } -}; - -typedef SingletonHolder LogBook; - -class Example -{ -public: - void method() - { - cout << "test\n"; - } -}; - - -int main(int argc, char *argv[]) -{ - // Instantiate both singletons by calling them... - LogBook::Instance().print("LogClass singleton instantiated"); - LogBook::Instance().print("Going to manually delete LogBook."); - - DeletableSingleton::GracefulDelete(); - - LogBook::Instance().print("LogClass reinstantiated."); - LogBook::Instance().print("Going to terminate program now."); - -#if defined(__BORLANDC__) || defined(_MSC_VER) - system("PAUSE"); -#endif - - return 0; -} - diff --git a/test/Singleton/Makefile b/test/Singleton/Makefile index e294646..08d101e 100644 --- a/test/Singleton/Makefile +++ b/test/Singleton/Makefile @@ -1,4 +1,3 @@ -BIN1 = DeletableSingleton BIN2 = Dependencies BIN3 = Phoenix CXXFLAGS = -Wall -Wold-style-cast -Wundef -Wsign-compare -Wconversion -Wpointer-arith -pedantic -O2 @@ -7,6 +6,6 @@ LDFLAGS = -L../../lib LDLIBS = -lloki .PHONY: build clean -build: $(BIN1) $(BIN2) $(BIN3) +build: $(BIN2) $(BIN3) clean: - rm -f $(BIN1) $(BIN2) $(BIN3) $(BIN1).exe $(BIN1).o $(BIN2).exe $(BIN2).o $(BIN3).exe $(BIN3).o + rm -f $(BIN2) $(BIN3) $(BIN2).exe $(BIN2).o $(BIN3).exe $(BIN3).o diff --git a/test/Singleton/make.msvc.bat b/test/Singleton/make.msvc.bat index 046a8ae..522e71b 100755 --- a/test/Singleton/make.msvc.bat +++ b/test/Singleton/make.msvc.bat @@ -1,13 +1,4 @@ -:: DeletableSingleton.cpp - -cl -c -Zm200 -O2 -DNDEBUG -MT -EHsc -GR -W0 -wd4710 -I"." -I"..\..\include" DeletableSingleton.cpp - -link /NOLOGO /SUBSYSTEM:CONSOLE /incremental:no /OUT:"DeletableSingleton-msvc.exe" ..\..\lib\loki.lib DeletableSingleton.obj - - - - :: Phoenix.cpp cl -c -Zm200 -O2 -DNDEBUG -MT -EHsc -GR -W0 -wd4710 -I"." -I"..\..\include" Phoenix.cpp diff --git a/test/make.msvc.bat b/test/make.msvc.bat index 50bb1c7..05fef0d 100755 --- a/test/make.msvc.bat +++ b/test/make.msvc.bat @@ -1,4 +1,8 @@ +cd DeletableSingleton +call make.msvc.bat +cd .. + cd Factory call make.msvc.bat cd ..