All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
TerraLib Class Reference

An utility class to control the startup and cleanup of the TerraLib Platform and its resources. More...

#include <TerraLib.h>

Inheritance diagram for TerraLib:
te::common::Singleton< TerraLib >

Classes

struct  Module
 This internal structure is used to model the basic information about a TerraLib module. More...
 

Public Types

typedef void(* CleanupFptr )(void)
 This is the type for call back functions that makes the cleanup of a module. More...
 
typedef void(* StartupFptr )(void)
 This is the type for call back functions that makes the startup of a module. More...
 

Public Member Functions

void add (const Module &m)
 It registers the module in the TerraLib Platform. More...
 
void finalize ()
 It finalizes the TerraLib Platform. More...
 
void finalize (const std::size_t i)
 It finalizes the i-th registered module in the TerraLib Platform. More...
 
void finalize (const std::string &moduleName)
 It finalizes the registered module in the TerraLib Platform. More...
 
std::size_t getModuleIdx (const std::string &moduleName) const
 It returns the module index inside the internal data structure. More...
 
const std::string & getModuleName (std::size_t i) const
 It return the i-th module name. More...
 
std::size_t getNumRegModules () const
 It returns the number of registered modules. More...
 
void initialize ()
 It initializes the TerraLib Platform. More...
 
void initialize (const std::size_t i)
 It initializes the i-th registered module in the TerraLib Platform. More...
 
void initialize (const std::string &moduleName)
 It initializes the registered module in the TerraLib Platform. More...
 
void remove (const std::string &moduleName)
 It removes the module entry identified by the given name. More...
 
void remove (const std::size_t i)
 It removes the i-th module entry. More...
 

Static Public Member Functions

static TerraLibgetInstance ()
 It returns a reference to the singleton instance. More...
 

Protected Member Functions

 TerraLib ()
 The singleton constructor is not callable outside the class. More...
 
 ~TerraLib ()
 

Private Attributes

std::vector< bool > m_initialized
 The list of modules to be initialized when initialize is called. More...
 
std::vector< Modulem_modules
 This static function is invoked automatically when the application finishes its execution. More...
 

Friends

class te::common::Singleton< TerraLib >
 

Detailed Description

An utility class to control the startup and cleanup of the TerraLib Platform and its resources.

This singleton will control the initialization and the cleanup of TerraLib modules and their resources. If you are creating a C++ application you may need to make an explicit initialization of the TerraLib Platform as showned in the code below:

...
int main(char** argv, int argc)
{
... // other initializations goes here!
... // now you can start using TerraLib!
TerraLib::getInstance().finalize(); // call this when you have finished using TerraLib
return EXIT_SUCCESS;
}

Notice the calling to the finalize function at the end of the example program, it is necessary in order to close/release any pending resource initialized by the modules.

Definition at line 70 of file TerraLib.h.

Member Typedef Documentation

void(* TerraLib::CleanupFptr)(void)

This is the type for call back functions that makes the cleanup of a module.

Definition at line 88 of file TerraLib.h.

void(* TerraLib::StartupFptr)(void)

This is the type for call back functions that makes the startup of a module.

Definition at line 81 of file TerraLib.h.

Constructor & Destructor Documentation

TerraLib::TerraLib ( )
protected

The singleton constructor is not callable outside the class.

Definition at line 152 of file TerraLib.cpp.

TerraLib::~TerraLib ( )
protected

Definition at line 157 of file TerraLib.cpp.

Member Function Documentation

void TerraLib::finalize ( )

It finalizes the TerraLib Platform.

Exceptions
ExceptionIt may throws an exception.
Note
The registered module shutdown functions will be invoked in an opposite order of registering (the last module to be registered will be the first module to be finalized).
Warning
Not thread safe!
If this method throws an exception we recommend you to quit the program, don't try to resume it because you can have intermittent errors!

Definition at line 64 of file TerraLib.cpp.

References m_modules.

Referenced by finalize(), te::qt::af::ApplicationController::finalize(), IDL_ExitHandler(), and main().

void TerraLib::finalize ( const std::size_t  i)

It finalizes the i-th registered module in the TerraLib Platform.

Exceptions
ExceptionIt may throws an exception.
Note
If there is a registered module cleaunp function it will be invoked.
Warning
Not thread safe!
Don't call this method in your code, it is used internally by TerraLib.

Definition at line 73 of file TerraLib.cpp.

References TerraLib::Module::m_cleanupFptr, m_initialized, and m_modules.

void TerraLib::finalize ( const std::string &  moduleName)

It finalizes the registered module in the TerraLib Platform.

Exceptions
ExceptionIt may throws an exception.
Note
If there is a registered module cleaunp function it will be invoked.
Warning
Not thread safe!
Don't call this method in your code, it is used internally by TerraLib.

Definition at line 89 of file TerraLib.cpp.

References finalize(), and getModuleIdx().

static TerraLib & te::common::Singleton< TerraLib >::getInstance ( )
staticinherited

It returns a reference to the singleton instance.

Returns
A reference to the singleton instance.

Referenced by te::qt::af::ApplicationController::finalize(), IDL_ExitHandler(), IDL_Load(), te::qt::af::ApplicationController::initialize(), te::plugin::PluginManager::load(), main(), te::map::Module::Module(), te::cellspace::Module::Module(), te::attributefill::Module::Module(), te::dt::Module::Module(), te::mem::Module::Module(), te::cl::Module::Module(), te::md::Module::Module(), te::edit::Module::Module(), te::plugin::Module::Module(), te::color::Module::Module(), te::fe::Module::Module(), te::rst::Module::Module(), te::gm::Module::Module(), te::sa::Module::Module(), te::se::Module::Module(), te::gml::Module::Module(), te::graph::Module::Module(), te::stat::Module::Module(), te::layout::Module::Module(), te::vp::Module::Module(), te::xml::Module::Module(), te::addressgeocoding::Module::Module(), te::da::Module::Module(), te::at::Module::Module(), te::st::Module::Module(), te::stmem::Module::Module(), te::qt::widgets::Module::Module(), te::srs::Module::Module(), te::rp::Module::Module(), te::common::Module::Module(), te::qt::plugins::layout::LayoutEditorAction::~LayoutEditorAction(), te::rst::Module::~Module(), te::cl::Module::~Module(), te::xml::Module::~Module(), te::mem::Module::~Module(), te::addressgeocoding::Module::~Module(), te::map::Module::~Module(), te::sa::Module::~Module(), te::se::Module::~Module(), te::color::Module::~Module(), te::vp::Module::~Module(), te::gml::Module::~Module(), te::graph::Module::~Module(), te::attributefill::Module::~Module(), te::md::Module::~Module(), te::plugin::Module::~Module(), te::gm::Module::~Module(), te::edit::Module::~Module(), te::stat::Module::~Module(), te::at::Module::~Module(), te::dt::Module::~Module(), te::fe::Module::~Module(), te::layout::Module::~Module(), te::cellspace::Module::~Module(), te::da::Module::~Module(), te::st::Module::~Module(), te::stmem::Module::~Module(), te::qt::widgets::Module::~Module(), te::srs::Module::~Module(), te::rp::Module::~Module(), and te::common::Module::~Module().

std::size_t TerraLib::getModuleIdx ( const std::string &  moduleName) const

It returns the module index inside the internal data structure.

Parameters
moduleNameThe name of a valid module registered in this singleton.
Returns
The module index inside the internal data structure.

Definition at line 133 of file TerraLib.cpp.

References m_modules.

Referenced by finalize(), and initialize().

const std::string & TerraLib::getModuleName ( std::size_t  i) const

It return the i-th module name.

Parameters
iThe module you are looking for its name.
Returns
The module name for the i-th module.

Definition at line 146 of file TerraLib.cpp.

References m_modules.

std::size_t TerraLib::getNumRegModules ( ) const

It returns the number of registered modules.

Returns
The number of registered modules.

Definition at line 128 of file TerraLib.cpp.

References m_modules.

Referenced by te::plugin::PluginManager::load().

void TerraLib::initialize ( )

It initializes the TerraLib Platform.

This method will perform the startup of all registered modules. If there isn't modules to be initialized this method has no effect.

Exceptions
ExceptionIt may throws an exception.
Note
The registered module startup functions will be invoked in a direct order of registering (the first module to be registered will be the first to be initialized).
Warning
Not thread safe!
If this method throws an exception we recommend you to quit the program, don't try to resume it because you can have intermittent errors!

Definition at line 33 of file TerraLib.cpp.

References m_modules.

Referenced by IDL_Load(), initialize(), te::qt::af::ApplicationController::initialize(), te::plugin::PluginManager::load(), and main().

void TerraLib::initialize ( const std::size_t  i)

It initializes the i-th registered module in the TerraLib Platform.

Exceptions
ExceptionIt may throws an exception.
Note
If there is a registered module startup function it will be invoked.
Warning
Not thread safe!
Don't call this method in your code, it is used internally by TerraLib.

Definition at line 42 of file TerraLib.cpp.

References m_initialized, m_modules, and TerraLib::Module::m_startFptr.

void TerraLib::initialize ( const std::string &  moduleName)

It initializes the registered module in the TerraLib Platform.

Exceptions
ExceptionIt may throws an exception.
Note
If there is a registered module startup function it will be invoked.
Warning
Not thread safe!
Don't call this method in your code, it is used internally by TerraLib.

Definition at line 58 of file TerraLib.cpp.

References getModuleIdx(), and initialize().

void TerraLib::remove ( const std::size_t  i)

It removes the i-th module entry.

Parameters
iThe i-th TerraLib module to be removed from the platform control.

Definition at line 120 of file TerraLib.cpp.

References m_initialized, and m_modules.

Friends And Related Function Documentation

friend class te::common::Singleton< TerraLib >
friend

Definition at line 72 of file TerraLib.h.

Member Data Documentation

std::vector<bool> TerraLib::m_initialized
private

The list of modules to be initialized when initialize is called.

Definition at line 265 of file TerraLib.h.

Referenced by add(), finalize(), initialize(), and remove().

std::vector<Module> TerraLib::m_modules
private

This static function is invoked automatically when the application finishes its execution.

Exceptions
ExceptionIt may throws an exception.
Note
This function will be automatically called at the end of your program.
The registered module shutdown functions will be invoked in an opposite order of registering (the last module to be registered will be the first module to be finalized).
Warning
Not thread safe!
If this method throws an exception we recommend you to quit the program, don't try to resume it because you can have intermittent errors!The list of registered modules.

Definition at line 264 of file TerraLib.h.

Referenced by add(), finalize(), getModuleIdx(), getModuleName(), getNumRegModules(), initialize(), and remove().


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