Click here to Skip to main content
15,886,518 members
Articles / Database Development / SQL Server

PostgreSQL/libpqxx Class Generator

Rate me:
Please Sign up or sign in to vote.
4.87/5 (15 votes)
18 Aug 200627 min read 82.7K   1.9K   37  
Automated generation of PostgreSQL data transfer classes.
/***************************************************************************
 Singleton.h - Implementation of the Singleton design pattern.

 begin     : August 2006
 copyright : (C) 2006 by Phil Cairns
 email     : oti169@hotmail.com
 $Id: Singleton.h 2080 2006-08-18 01:53:19Z phil $

 This code may be used in compiled form in any way you desire (including
 commercial use). The code may be redistributed unmodified by any means
 providing it is not sold for profit without the authors written consent,
 and providing that this notice and the authors name and all copyright
 notices remains intact.

 This software is provided "as is" without express or implied warranty. Use
 it at your own risk!
 ***************************************************************************/

#pragma once

namespace Pagaros
{
	template <typename TYPE> 
	class Singleton
	{
	public:
		/// Global access point to the Singleton.
		static TYPE& instance(void)
		{
			Singleton<TYPE>& singleton = Singleton<TYPE>::instance_i();

			if (singleton._instance == 0)
			{
				singleton._instance = new TYPE;
			}

			return *singleton._instance;
		}

		/// Explicitly delete the Singleton instance.
		static void close(void)
		{
			Singleton<TYPE>& singleton = Singleton<TYPE>::instance_i();
			if (singleton._instance) 
			{
				delete singleton._instance;
			}
		}

	protected:
		/// Contained instance.
		TYPE* _instance;

		/// Get pointer to the Singleton instance.
		static Singleton<TYPE> &instance_i (void)
		{
			static Singleton<TYPE> _singleton;
			return _singleton;
		}
	};
};

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Australia Australia
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions