An utility class to control the startup and cleanup of the TerraLib Platform and its resources.
More...
#include <TerraLib.h>
|
typedef void(* | CleanupFptr) (void) |
| This is the type for call back functions that makes the cleanup of a module.
|
|
typedef void(* | StartupFptr) (void) |
| This is the type for call back functions that makes the startup of a module.
|
|
|
| TerraLib () |
| The singleton constructor is not callable outside the class.
|
|
| ~TerraLib () |
|
|
std::vector< bool > | m_initialized |
| The list of modules to be initialized when initialize is called.
|
|
std::vector< std::weak_ptr< Module > > | m_modules |
| The list of registered modules.
|
|
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)
{
...
...
return EXIT_SUCCESS;
}
void initialize()
It initializes the TerraLib Platform.
void finalize()
It finalizes the TerraLib Platform.
static TerraLib & getInstance()
It returns a reference to the singleton instance.
An utility class to control the startup and cleanup of the TerraLib Platform and its resources.
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 71 of file TerraLib.h.
◆ CleanupFptr
void(* TerraLib::CleanupFptr)(void) |
This is the type for call back functions that makes the cleanup of a module.
Definition at line 89 of file TerraLib.h.
◆ StartupFptr
void(* TerraLib::StartupFptr)(void) |
This is the type for call back functions that makes the startup of a module.
Definition at line 82 of file TerraLib.h.
◆ TerraLib()
The singleton constructor is not callable outside the class.
◆ ~TerraLib()
◆ add()
void TerraLib::add |
( |
std::weak_ptr< Module > |
m | ) |
|
It registers the module in the TerraLib Platform.
Each registered module will be initialized when TerraLib Platform is explicitly started and then finalized when the application finalizes.
- Parameters
-
◆ finalize() [1/3]
void TerraLib::finalize |
( |
| ) |
|
It finalizes the TerraLib Platform.
- Exceptions
-
Exception | It 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!
◆ finalize() [2/3]
void TerraLib::finalize |
( |
const std::size_t |
i | ) |
|
It finalizes the i-th registered module in the TerraLib Platform.
- Exceptions
-
Exception | It 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.
◆ finalize() [3/3]
void TerraLib::finalize |
( |
const std::string & |
moduleName | ) |
|
It finalizes the registered module in the TerraLib Platform.
- Exceptions
-
Exception | It 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.
◆ getInstance()
It returns a reference to the singleton instance.
- Returns
- A reference to the singleton instance.
Definition at line 109 of file Singleton.h.
◆ getModuleIdx()
std::size_t TerraLib::getModuleIdx |
( |
const std::string & |
moduleName | ) |
const |
It returns the module index inside the internal data structure.
- Parameters
-
moduleName | The name of a valid module registered in this singleton. |
- Returns
- The module index inside the internal data structure.
◆ getModuleName()
const std::string & TerraLib::getModuleName |
( |
std::size_t |
i | ) |
const |
It return the i-th module name.
- Parameters
-
i | The module you are looking for its name. |
- Returns
- The module name for the i-th module.
◆ getNumRegModules()
std::size_t TerraLib::getNumRegModules |
( |
| ) |
const |
It returns the number of registered modules.
- Returns
- The number of registered modules.
◆ initialize() [1/3]
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
-
Exception | It 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!
◆ initialize() [2/3]
void TerraLib::initialize |
( |
const std::size_t |
i | ) |
|
It initializes the i-th registered module in the TerraLib Platform.
- Exceptions
-
Exception | It 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.
◆ initialize() [3/3]
void TerraLib::initialize |
( |
const std::string & |
moduleName | ) |
|
It initializes the registered module in the TerraLib Platform.
- Exceptions
-
Exception | It 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.
◆ initializeTranslations()
void TerraLib::initializeTranslations |
( |
| ) |
|
|
private |
This static function is invoked automatically when the application finishes its execution.
- Exceptions
-
Exception | It 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!
This is a internal function that loads all translations on the default TerraLib share folder. it will be invoked after loading all plugins.
◆ remove() [1/2]
void TerraLib::remove |
( |
const std::size_t |
i | ) |
|
It removes the i-th module entry.
- Parameters
-
i | The i-th TerraLib module to be removed from the platform control. |
◆ remove() [2/2]
void TerraLib::remove |
( |
const std::string & |
moduleName | ) |
|
It removes the module entry identified by the given name.
- Parameters
-
moduleName | The TerraLib module to be removed from the platform control. |
◆ te::common::Singleton< TerraLib >
◆ m_initialized
std::vector<bool> TerraLib::m_initialized |
|
private |
The list of modules to be initialized when initialize is called.
Definition at line 279 of file TerraLib.h.
◆ m_modules
std::vector<std::weak_ptr<Module> > TerraLib::m_modules |
|
private |
The list of registered modules.
Definition at line 278 of file TerraLib.h.
The documentation for this class was generated from the following file:
- /home/castejon/castejon_files/develop/terralib5/git_release/src/terralib/common/TerraLib.h