move DeletableSingleton to its own folder
git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@547 7ec92016-0320-0410-acc4-a06ded1c099a
This commit is contained in:
parent
b9ac41218c
commit
5a8e9c06f4
7 changed files with 27 additions and 93 deletions
10
test/DeletableSingleton/Makefile
Executable file
10
test/DeletableSingleton/Makefile
Executable file
|
@ -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
|
10
test/DeletableSingleton/make.msvc.bat
Executable file
10
test/DeletableSingleton/make.msvc.bat
Executable file
|
@ -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
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
SUBTARGETS = Factory Longevity OrderedStatic Pimpl RegressionTest \
|
SUBTARGETS = DeletableSingleton Factory Longevity OrderedStatic Pimpl RegressionTest \
|
||||||
SafeFormat ScopeGuard Singleton SmallObj Visitor flex_string
|
SafeFormat ScopeGuard Singleton SmallObj Visitor flex_string
|
||||||
SUBTARGETS_CLEAN = $(foreach SUBTARGET,$(SUBTARGETS),$(SUBTARGET)-clean)
|
SUBTARGETS_CLEAN = $(foreach SUBTARGET,$(SUBTARGETS),$(SUBTARGET)-clean)
|
||||||
|
|
||||||
|
|
|
@ -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 <iostream>
|
|
||||||
#include <loki/Singleton.h> // 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<LogClass, CreateUsingNew, DeletableSingleton> 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<LogClass>::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;
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
BIN1 = DeletableSingleton
|
|
||||||
BIN2 = Dependencies
|
BIN2 = Dependencies
|
||||||
BIN3 = Phoenix
|
BIN3 = Phoenix
|
||||||
CXXFLAGS = -Wall -Wold-style-cast -Wundef -Wsign-compare -Wconversion -Wpointer-arith -pedantic -O2
|
CXXFLAGS = -Wall -Wold-style-cast -Wundef -Wsign-compare -Wconversion -Wpointer-arith -pedantic -O2
|
||||||
|
@ -7,6 +6,6 @@ LDFLAGS = -L../../lib
|
||||||
LDLIBS = -lloki
|
LDLIBS = -lloki
|
||||||
|
|
||||||
.PHONY: build clean
|
.PHONY: build clean
|
||||||
build: $(BIN1) $(BIN2) $(BIN3)
|
build: $(BIN2) $(BIN3)
|
||||||
clean:
|
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
|
||||||
|
|
|
@ -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
|
:: Phoenix.cpp
|
||||||
|
|
||||||
cl -c -Zm200 -O2 -DNDEBUG -MT -EHsc -GR -W0 -wd4710 -I"." -I"..\..\include" Phoenix.cpp
|
cl -c -Zm200 -O2 -DNDEBUG -MT -EHsc -GR -W0 -wd4710 -I"." -I"..\..\include" Phoenix.cpp
|
||||||
|
|
|
@ -1,4 +1,8 @@
|
||||||
|
|
||||||
|
cd DeletableSingleton
|
||||||
|
call make.msvc.bat
|
||||||
|
cd ..
|
||||||
|
|
||||||
cd Factory
|
cd Factory
|
||||||
call make.msvc.bat
|
call make.msvc.bat
|
||||||
cd ..
|
cd ..
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue