bug fix: Unix compilation problems

git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@318 7ec92016-0320-0410-acc4-a06ded1c099a
This commit is contained in:
syntheticpp 2005-10-24 12:13:07 +00:00
parent f682afc33b
commit 7d66b82b9a
4 changed files with 45 additions and 45 deletions

View file

@ -21,7 +21,7 @@
#include <iostream>
#include "loki/Singleton.h"
#include "loki/TypeList.h"
#include "loki/Typelist.h"
namespace Loki

View file

@ -12,14 +12,14 @@
// singletons and globally and locally defined dynamically allocated
// objects.
//
// The program defines three classes: Example, Keyboard and Log.
// The program defines three classes: Example, Keyboard and LogClass.
//
// The purpose of the Example class is to send a message to cout
// when an Example object is being destroyed.
//
// The Keyboard class is a singleton.
//
// The Log class is also a singleton.
// The LogClass class is also a singleton.
//
// The pGlobal object is deleted using an adapter functor to
// customize Example's destruction (see destGlobal()).
@ -41,7 +41,7 @@
// 1) The global object
// 2) The local object
// 3) The Keyboard singleton
// 4) The Log singleton
// 4) The LogClass singleton
//
// Examples:
// longevity 1 2 3 4
@ -104,23 +104,23 @@ inline unsigned int GetLongevity(Keyboard *)
typedef SingletonHolder<Keyboard, CreateUsingNew, SingletonWithLongevity> keyboard;
// A singleton Log object derived from the Example class.
// A singleton LogClass object derived from the Example class.
// Its longevity is set by the user on the command line.
//
class Log : public Example
class LogClass : public Example
{
public:
Log() : Example("Destroying Log")
LogClass() : Example("Destroying LogClass")
{ }
}
;
inline unsigned int GetLongevity(Log *)
inline unsigned int GetLongevity(LogClass *)
{
return logPriority;
}
typedef SingletonHolder<Log, CreateUsingNew, SingletonWithLongevity> log;
typedef SingletonHolder<LogClass, CreateUsingNew, SingletonWithLongevity> LogBook;
// Instantiate a global Example object. It's not a singleton
@ -146,7 +146,7 @@ void help(const char *s)
cout << " par1: global object\n";
cout << " par2: local object\n";
cout << " par3: keyboard singleton\n";
cout << " par4: log singleton\n";
cout << " par4: LogBook singleton\n";
cout << "Example: " << s << " 1 2 3 4" << endl;
}
@ -179,7 +179,7 @@ int main(int argc, char *argv[])
pLocal->echo("pLocal created after main() started.");
// Instantiate both singletons by calling them...
log::Instance().echo("Log singleton instantiated");
LogBook::Instance().echo("LogClass singleton instantiated");
keyboard::Instance().echo("Keyboard singleton instantiated");
return 0;

View file

@ -12,14 +12,14 @@
//
// Expected output:
//
// Log::Log()
// Log singleton instantiated
// Going to manually delete log.
// Log::~Log()
// Log::Log()
// Log reinstantiated.
// LogClass::LogClass()
// LogClass singleton instantiated
// Going to manually delete LogBook.
// LogClass::~LogClass()
// LogClass::LogClass()
// LogClass reinstantiated.
// Going to terminate program now.
// Log::~Log()
// LogClass::~LogClass()
//
#include <iostream>
@ -28,19 +28,19 @@
using namespace std; // okay for small programs
using namespace Loki; // okay for small programs
// A singleton Log object derived from the Example class.
// A singleton LogClass object derived from the Example class.
// Its longevity is set by the user on the command line.
//
class Log
class LogClass
{
public:
Log()
LogClass()
{
print("Log::Log()");
print("LogClass::LogClass()");
};
~Log()
~LogClass()
{
print("Log::~Log()");
print("LogClass::~LogClass()");
}
void print(const char *s)
{
@ -48,7 +48,7 @@ public:
}
};
typedef SingletonHolder<Log, CreateUsingNew, DeletableSingleton> log;
typedef SingletonHolder<LogClass, CreateUsingNew, DeletableSingleton> LogBook;
class Example
{
@ -63,13 +63,13 @@ public:
int main(int argc, char *argv[])
{
// Instantiate both singletons by calling them...
log::Instance().print("Log singleton instantiated");
log::Instance().print("Going to manually delete log.");
LogBook::Instance().print("LogClass singleton instantiated");
LogBook::Instance().print("Going to manually delete LogBook.");
DeletableSingleton<Log>::GracefulDelete();
DeletableSingleton<LogClass>::GracefulDelete();
log::Instance().print("Log reinstantiated.");
log::Instance().print("Going to terminate program now.");
LogBook::Instance().print("LogClass reinstantiated.");
LogBook::Instance().print("Going to terminate program now.");
#if defined(__BORLANDC__) || defined(__GNUC__) || defined(_MSC_VER)
system("pause"); // Stop console window from closing if run from IDE.

View file

@ -8,19 +8,19 @@
// for any purpose. It is provided "as is" without express or implied warranty.
////////////////////////////////////////////////////////////////////////////////
// A singleton Log object that resurrects itself after
// A singleton LogClass object that resurrects itself after
// it has been automatically destroyed during program
// termination. When a dead-reference to the Log
// termination. When a dead-reference to the LogClass
// singleton is detected, it is resurrected automatically.
//
// Expected output:
// Example c'tor
// Log c'tor
// Log now instantiated.
// Log d'tor
// LogClass c'tor
// LogClass now instantiated.
// LogClass d'tor
// Example d'tor starting
// Log c'tor
// Log: inside Example d'tor
// LogClass c'tor
// LogClass: inside Example d'tor
// Example d'tor finished
//
// The last line of the output only appears when this
@ -34,16 +34,16 @@
using namespace std; // okay for small programs
using namespace Loki; // okay for small programs
class Log
class LogClass
{
public:
Log()
LogClass()
{
echo("Log c'tor");
echo("LogClass c'tor");
}
~Log()
~LogClass()
{
echo("Log d'tor");
echo("LogClass d'tor");
}
void echo(const char *s)
{
@ -51,7 +51,7 @@ public:
}
};
typedef SingletonHolder<Log, CreateUsingNew, PhoenixSingleton> log;
typedef SingletonHolder<LogClass, CreateUsingNew, PhoenixSingleton> LogBook;
// A generic example class that stores and echoes a const char.
@ -66,7 +66,7 @@ public:
~Example()
{
echo("Example d'tor starting");
log::Instance().echo("Log: inside Example d'tor");
LogBook::Instance().echo("LogClass: inside Example d'tor");
echo("Example d'tor finished");
}
void echo(const char *s)
@ -80,7 +80,7 @@ int main(int argc, char* argv[])
{
Example *example = new Example();
SetLongevity<Example, void (*)(Example*)>(example, 1, &Loki::Private::Deleter<Example>::Delete);
log::Instance().echo("Log now instantiated.");
LogBook::Instance().echo("LogClass now instantiated.");
#if defined(__BORLANDC__) || defined(__GNUC__) || defined(_MSC_VER)
system("pause"); // Stop console window from closing if run from IDE.