Removed 'singleton' and 'singletonManager' classes.

This commit is contained in:
Vincent Richard 2005-03-14 20:35:25 +00:00
parent 825021442c
commit 362fa346f9
16 changed files with 65 additions and 170 deletions

View File

@ -2,6 +2,11 @@
VERSION 0.6.4cvs
================
2005-03-14 Vincent Richard <vincent@vincent-richard.net>
* removed singleton<> and singletonManager classes: useless and quite
confusing in Doxygen-generated documentation.
2005-02-06 Vincent Richard <vincent@vincent-richard.net>
* mailboxList.{cpp|hpp}: dropped protected inheritance which was not

View File

@ -147,7 +147,6 @@ libvmime_sources = [
'utility/md5.cpp', 'utility/md5.hpp',
'utility/path.cpp', 'utility/path.hpp',
'utility/random.cpp', 'utility/random.hpp',
'utility/singleton.cpp', 'utility/singleton.hpp',
'utility/smartPtr.hpp',
'utility/stream.cpp', 'utility/stream.hpp',
'utility/stringProxy.cpp', 'utility/stringProxy.hpp',

View File

@ -54,6 +54,13 @@ encoderFactory::~encoderFactory()
}
encoderFactory* encoderFactory::getInstance()
{
static encoderFactory instance;
return (&instance);
}
encoder* encoderFactory::create(const string& name)
{
return (getEncoderByName(name)->create());

View File

@ -63,6 +63,13 @@ headerFieldFactory::~headerFieldFactory()
}
headerFieldFactory* headerFieldFactory::getInstance()
{
static headerFieldFactory instance;
return (&instance);
}
headerField* headerFieldFactory::create
(const string& name, const string& body)
{

View File

@ -45,6 +45,13 @@ serviceFactory::~serviceFactory()
}
serviceFactory* serviceFactory::getInstance()
{
static serviceFactory instance;
return (&instance);
}
service* serviceFactory::create
(session* sess, const string& protocol, authenticator* auth)
{

View File

@ -24,6 +24,13 @@ namespace vmime
{
options* options::getInstance()
{
static options instance;
return (&instance);
}
options::multipartOptions::multipartOptions()
: m_prologText("This is a multi-part message in MIME format. Your mail reader " \
"does not understand MIME message format."),

View File

@ -42,6 +42,13 @@ parameterFactory::~parameterFactory()
}
parameterFactory* parameterFactory::getInstance()
{
static parameterFactory instance;
return (&instance);
}
parameter* parameterFactory::create
(const string& name, const string& value)
{

View File

@ -42,6 +42,13 @@ textPartFactory::~textPartFactory()
}
textPartFactory* textPartFactory::getInstance()
{
static textPartFactory instance;
return (&instance);
}
textPart* textPartFactory::create(const mediaType& type)
{
NameMap::const_iterator pos = m_nameMap.find(type.generate());

View File

@ -1,53 +0,0 @@
//
// VMime library (http://vmime.sourceforge.net)
// Copyright (C) 2002-2005 Vincent Richard <vincent@vincent-richard.net>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of
// the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
#include "vmime/utility/singleton.hpp"
namespace vmime {
namespace utility {
singletonManager::singletonManager()
{
}
singletonManager::~singletonManager()
{
for (std::list <abstractSingleton*>::iterator it = m_list.begin() ; it != m_list.end() ; ++it)
delete (*it);
}
singletonManager* singletonManager::getInstance()
{
static singletonManager inst;
return (&inst);
}
void singletonManager::manage(abstractSingleton* s)
{
m_list.push_back(s);
}
} // utility
} // vmime

View File

@ -22,7 +22,6 @@
#include "vmime/encoder.hpp"
#include "vmime/utility/singleton.hpp"
#include "vmime/utility/stringUtils.hpp"
@ -33,10 +32,8 @@ namespace vmime
/** A factory to create 'encoder' objects for the specified encoding.
*/
class encoderFactory : public utility::singleton <encoderFactory>
class encoderFactory
{
friend class utility::singleton <encoderFactory>;
private:
encoderFactory();
@ -44,6 +41,8 @@ private:
public:
static encoderFactory* getInstance();
/** Information about a registered encoder. */
class registeredEncoder
{

View File

@ -22,7 +22,6 @@
#include "vmime/headerField.hpp"
#include "vmime/utility/singleton.hpp"
#include "vmime/utility/stringUtils.hpp"
@ -30,10 +29,8 @@ namespace vmime
{
class headerFieldFactory : public utility::singleton <headerFieldFactory>
class headerFieldFactory
{
friend class utility::singleton <headerFieldFactory>;
protected:
headerFieldFactory();
@ -46,6 +43,8 @@ protected:
public:
static headerFieldFactory* getInstance();
#ifndef VMIME_BUILDING_DOC
template <class TYPE>
class registerer

View File

@ -25,7 +25,6 @@
#include "vmime/types.hpp"
#include "vmime/base.hpp"
#include "vmime/utility/singleton.hpp"
#include "vmime/utility/stringUtils.hpp"
#include "vmime/messaging/serviceInfos.hpp"
@ -46,10 +45,8 @@ class session;
/** A factory to create 'service' objects for a specified protocol.
*/
class serviceFactory : public utility::singleton <serviceFactory>
class serviceFactory
{
friend class utility::singleton <serviceFactory>;
private:
serviceFactory();
@ -57,6 +54,8 @@ private:
public:
static serviceFactory* getInstance();
/** Information about a registered service. */
class registeredService
{

View File

@ -22,7 +22,6 @@
#include "vmime/base.hpp"
#include "vmime/utility/singleton.hpp"
namespace vmime
@ -32,10 +31,8 @@ namespace vmime
/** A class to set global options for VMime.
*/
class options : public utility::singleton <options>
class options
{
friend class utility::singleton <options>;
protected:
/** Message-related options.
@ -83,6 +80,8 @@ protected:
public:
static options* getInstance();
multipartOptions multipart;
messageOptions message;
};

View File

@ -22,7 +22,6 @@
#include "vmime/parameter.hpp"
#include "vmime/utility/singleton.hpp"
#include "vmime/utility/stringUtils.hpp"
@ -30,10 +29,8 @@ namespace vmime
{
class parameterFactory : public utility::singleton <parameterFactory>
class parameterFactory
{
friend class utility::singleton <parameterFactory>;
protected:
parameterFactory();
@ -46,6 +43,8 @@ protected:
public:
static parameterFactory* getInstance();
#ifndef VMIME_BUILDING_DOC
template <class TYPE>
class registerer

View File

@ -23,17 +23,14 @@
#include "vmime/textPart.hpp"
#include "vmime/mediaType.hpp"
#include "vmime/utility/singleton.hpp"
namespace vmime
{
class textPartFactory : public utility::singleton <textPartFactory>
class textPartFactory
{
friend class utility::singleton <textPartFactory>;
protected:
textPartFactory();
@ -60,6 +57,8 @@ protected:
public:
static textPartFactory* getInstance();
template <class T>
void registerType(const mediaType& type)
{

View File

@ -1,92 +0,0 @@
//
// VMime library (http://vmime.sourceforge.net)
// Copyright (C) 2002-2005 Vincent Richard <vincent@vincent-richard.net>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of
// the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
#ifndef VMIME_UTILITY_SINGLETON_HPP_INCLUDED
#define VMIME_UTILITY_SINGLETON_HPP_INCLUDED
#include <list>
namespace vmime {
namespace utility {
// Singleton abstract base class.
class abstractSingleton
{
friend class singletonManager;
protected:
abstractSingleton() { }
virtual ~abstractSingleton() { }
};
// Singleton manager
// (for automatic clean-up of all instanciated singletons).
class singletonManager
{
public:
static singletonManager* getInstance();
void manage(abstractSingleton* s);
private:
singletonManager();
~singletonManager();
std::list <abstractSingleton*> m_list;
};
// A singleton template.
template <class TYPE>
class singleton : public abstractSingleton
{
protected:
singleton() { }
~singleton() { }
public:
static TYPE* getInstance()
{
static TYPE* inst = NULL;
if (!inst)
singletonManager::getInstance()->manage(inst = new TYPE());
return (inst);
}
};
} // utility
} // vmime
#endif // VMIME_UTILITY_SINGLETON_HPP_INCLUDED