te::common::Singleton< T > Class Template Reference

Template support for singleton pattern. More...

#include <Singleton.h>

Inheritance diagram for te::common::Singleton< T >:
te::color::ColorSchemeCatalogManager te::common::SystemApplicationSettings te::edit::Renderer te::fe::serialize::Expression te::map::ChartRendererManager te::map::serialize::Layer te::se::serialize::Symbolizer

Static Public Member Functions

static T & getInstance ()
 It returns a reference to the singleton instance. More...
 

Protected Member Functions

 Singleton ()
 The singleton constructor is protected. More...
 
virtual ~Singleton ()
 This will avoid clients trying to release pointers to base class. More...
 

Private Member Functions

Singletonoperator= (const Singleton &other)
 
 Singleton (const Singleton &other)
 

Detailed Description

template<class T>
class te::common::Singleton< T >

Template support for singleton pattern.

In TerraLib, classes that manage resources like DataSourceManager and ProjectManager are singletons. The basic interface of a singleton is defined by this singleton class. If you want to get access to the singleton instance you can write a code like:

DataSourceManager& dsm = DataSourceManager::getInstance();

or

std::vector<DataSource*> datasources = DataSourceManager::getInstance().getDataSourceList();

If you want to use this template class in order to create your singleton class, the type T must satisfy the following requirements:

  • It must have an empty constructor;

You can create a singleton class as follow:

class MySingletonClass : public te::common::Singleton<MySingletonClass>
{
friend class te::common::Singleton<MySingletonClass>;
public:
// Singleton methods (just as an example).
int getId()
{
return id;
}
...
protected:
// Empty constructor
MySingletonClass()
{
...
}
private:
// My private data
int id;
...
};

Definition at line 100 of file Singleton.h.

Constructor & Destructor Documentation

template<class T >
te::common::Singleton< T >::Singleton ( )
inlineprotected

The singleton constructor is protected.

Definition at line 133 of file Singleton.h.

template<class T >
te::common::Singleton< T >::~Singleton ( )
inlineprotectedvirtual

This will avoid clients trying to release pointers to base class.

Definition at line 137 of file Singleton.h.

template<class T>
te::common::Singleton< T >::Singleton ( const Singleton< T > &  other)
private

Member Function Documentation

template<class T >
T & te::common::Singleton< T >::getInstance ( )
inlinestatic

It returns a reference to the singleton instance.

Returns
A reference to the singleton instance.

Definition at line 126 of file Singleton.h.

Referenced by te::qt::plugins::vp::AbstractAction::addNewLayer(), te::qt::widgets::applyRasterMultiResolution(), BBOXReader(), BBOXWriter(), BetweenReader(), BetweenWriter(), BinaryComparsionOpReader(), BinaryComparsionOpWriter(), BinaryOperatorReader(), BinarySpatialOpReader(), BinarySpatialOpWriter(), te::map::QueryLayerRenderer::buildChart(), te::map::AbstractLayerRenderer::buildChart(), te::qt::widgets::ClassifierWizard::buildLegend(), DistanceBufferOpWriter(), DistanceBufferReader(), te::edit::MergeGeometriesTool::draw(), te::edit::EditInfoTool::draw(), te::edit::AddCommand::draw(), te::edit::SubtractAreaTool::draw(), te::edit::AggregateAreaTool::draw(), te::edit::RotateGeometryTool::draw(), te::edit::CreatePointTool::draw(), te::edit::DeleteGeometryByAreaTool::draw(), te::edit::CreateLineTool::draw(), te::edit::CreatePolygonTool::draw(), te::edit::MoveGeometryTool::draw(), te::edit::SplitPolygonTool::draw(), te::edit::VertexTool::draw(), te::edit::CreatePolygonTool::drawLine(), te::edit::SubtractAreaTool::drawPolygon(), te::edit::AggregateAreaTool::drawPolygon(), te::edit::DeleteGeometryByAreaTool::drawPolygon(), te::edit::CreatePolygonTool::drawPolygon(), te::qt::plugins::edit::Plugin::drawStashed(), te::color::Module::finalize(), te::qt::widgets::Module::finalize(), FolderLayerReader(), FolderLayerWriter(), te::sa::GetColorBar(), te::rp::GetSensorFilename(), te::color::Module::initialize(), te::qt::widgets::Module::initialize(), te::qt::plugins::rp::RasterConfigWidget::initialize(), te::qt::plugins::vp::VectorProcessingConfigWidget::initialize(), te::qt::af::GeneralConfigWidget::initialize(), te::qt::af::ApplicationController::initialize(), te::qt::af::ApplicationController::initializePlugins(), LikeReader(), LikeWriter(), te::qt::widgets::ColorCatalogWidget::loadDefaultColorCatalog(), LoadProject(), NullReader(), NullWriter(), te::qt::widgets::ColorCatalogWidget::onCatalogComboBoxActivated(), te::qt::widgets::ColorCatalogWidget::onGroupComboBoxActivated(), te::qt::widgets::ColorCatalogWidget::onSchemaComboBoxActivated(), te::qt::af::AppCtrlSingleton::prepareQtEnvironment(), te::se::serialize::ReadGeometryPropertyHelper(), te::se::serialize::ReadParameterValue(), te::se::serialize::ReadRule(), te::qt::widgets::CloudDetectionDialog::readStyle(), te::se::serialize::ReadSvgParameter(), te::qt::widgets::ReadSymbol(), te::se::serialize::Save(), SaveProject(), te::color::ColorSchemeCatalog::setName(), te::wms::Module::startup(), te::ws::ogc::wms::da::Module::startup(), TerraViewController::TerraViewController(), te::qt::af::UpdateUserSettingsFile(), te::se::serialize::WriteGeometryPropertyHelper(), and te::qt::widgets::CloudDetectionDialog::writeStyle().

template<class T>
Singleton& te::common::Singleton< T >::operator= ( const Singleton< T > &  other)
private

The documentation for this class was generated from the following file: