te::color::ColorSchemeCatalogManager Class Reference

The ColorSchemeCatalogManager is a singleton that can be used to manage all loaded color scheme catalogs. More...

#include <ColorSchemeCatalogManager.h>

Inheritance diagram for te::color::ColorSchemeCatalogManager:
te::common::Singleton< ColorSchemeCatalogManager >

Public Member Functions

ColorSchemeCatalogManager Accessor Method

Method used to access the data stored on this manager.

void init ()
 Inializes the manager from a JSON file containing instances of color schemes. More...
 
void insert (ColorSchemeCatalog *c)
 It inserts a new catalog that will be managed by ColorSchemeCatalogManager. More...
 
void disconnect (ColorSchemeCatalog *c)
 It removes the internal reference to the catalog. More...
 
void erase (ColorSchemeCatalog *c)
 It removes the catalog from the manager and clears it resources. More...
 
ColorSchemeCatalogfindByName (const std::string &name) const
 It returns the catalog identified by a given name or NULL if none is found. More...
 
std::pair< std::vector< ColorSchemeCatalog * >::const_iterator, std::vector< ColorSchemeCatalog * >::const_iterator > getIterator () const
 It returns a pair of iterators over the catalogs of this manager. More...
 
const std::vector< ColorSchemeCatalog * > & getCatalogs () const
 It returns the list of catalogs available in the system. More...
 
bool isEmpty () const
 It returns true if the manager contains at least one catalog. If no catalog exists, it returns false. More...
 
void clear ()
 It unloads all catalogs managed by ColorSchemeCatalogManager. More...
 

Static Public Member Functions

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

Private Member Functions

Copy Constructor and Assignment Operator

Copy constructor and assignment operator not allowed.

 ColorSchemeCatalogManager (const ColorSchemeCatalogManager &rhs)
 Copy constructor not allowed. More...
 
ColorSchemeCatalogManageroperator= (const ColorSchemeCatalogManager &rhs)
 Assignment operator not allowed. More...
 

Private Attributes

std::map< std::string, ColorSchemeCatalog * > m_catalogIdxByName
 An index from catalog's name to catalog's instance (note: we can not have duplicated names). More...
 
std::vector< ColorSchemeCatalog * > m_catalogs
 This is the list of all system's loaded catalogs. More...
 

Friends

class te::common::Singleton< ColorSchemeCatalogManager >
 

Initializer Methods

Methods related to instantiation and destruction.

 ~ColorSchemeCatalogManager ()
 Destructor. More...
 
 ColorSchemeCatalogManager ()
 It initializes the Singleton. More...
 

Detailed Description

The ColorSchemeCatalogManager is a singleton that can be used to manage all loaded color scheme catalogs.

Use this class to keep the loaded catalogs and to be a point of entry for plugins that need to known what are the opened catalogs of your application. When the singleton finishes its life time it automatically clears all loaded catalogs stored on it. You can also use it only inside a given window, where a list of catalogs will be displayed and then when the window gets closed, you clear the catalogs to save memory.

Note
You can save memory not loading all catalogs and keeping then opened during the entire life of your application.
See also
Singleton, ColorScheme, ColorSchemeGroup, ColorSchemeCatalog

Definition at line 75 of file ColorSchemeCatalogManager.h.

Constructor & Destructor Documentation

te::color::ColorSchemeCatalogManager::~ColorSchemeCatalogManager ( )

Destructor.

te::color::ColorSchemeCatalogManager::ColorSchemeCatalogManager ( )
protected

It initializes the Singleton.

te::color::ColorSchemeCatalogManager::ColorSchemeCatalogManager ( const ColorSchemeCatalogManager rhs)
private

Copy constructor not allowed.

Parameters
rhsThe right-hand-side copy that would be used to copy from.

Member Function Documentation

void te::color::ColorSchemeCatalogManager::clear ( )

It unloads all catalogs managed by ColorSchemeCatalogManager.

void te::color::ColorSchemeCatalogManager::disconnect ( ColorSchemeCatalog c)

It removes the internal reference to the catalog.

Parameters
cThe catalog to be removed.
Exceptions
ExceptionIf the catalog doesn't exist it will raise an exception.
Note
The caller of this method will take the ownership of the catalog.
void te::color::ColorSchemeCatalogManager::erase ( ColorSchemeCatalog c)

It removes the catalog from the manager and clears it resources.

Parameters
cThe catalog to be removed.
Exceptions
ExceptionIf the catalog doesn't exist it will raise an exception.
Note
The memory pointed by c will be deallocated. Don't reference it anymore.
ColorSchemeCatalog* te::color::ColorSchemeCatalogManager::findByName ( const std::string &  name) const

It returns the catalog identified by a given name or NULL if none is found.

Parameters
nameThe name of the catalog we are looking for.
Returns
A pointer to a catalog (don't free the pointer) or NULL if none is found.
const std::vector<ColorSchemeCatalog*>& te::color::ColorSchemeCatalogManager::getCatalogs ( ) const

It returns the list of catalogs available in the system.

Returns
The list of catalogs available in the system.
static ColorSchemeCatalogManager & te::common::Singleton< ColorSchemeCatalogManager >::getInstance ( )
staticinherited

It returns a reference to the singleton instance.

Returns
A reference to the singleton instance.
std::pair<std::vector<ColorSchemeCatalog*>::const_iterator, std::vector<ColorSchemeCatalog*>::const_iterator> te::color::ColorSchemeCatalogManager::getIterator ( ) const

It returns a pair of iterators over the catalogs of this manager.

Returns
A pair of iterators over the catalogs of this manager where pair.first will be the beginning and pair.second will be the end iterator.
void te::color::ColorSchemeCatalogManager::init ( )

Inializes the manager from a JSON file containing instances of color schemes.

This methods reads the file "TE_JSON_FILES_LOCATION/color_ramps.json" for color schemes definitions and insert them on the manager if it is empty.

Exceptions
te::srs::Exceptionif the JSON file is not well formed.
void te::color::ColorSchemeCatalogManager::insert ( ColorSchemeCatalog c)

It inserts a new catalog that will be managed by ColorSchemeCatalogManager.

Parameters
cThe new catalog to be managed by this manager.
Exceptions
ExceptionIf the catalog already exists it will raise an exception.
Note
Don't free the resources used by the catalog, the manager will take the ownership of it.
bool te::color::ColorSchemeCatalogManager::isEmpty ( ) const

It returns true if the manager contains at least one catalog. If no catalog exists, it returns false.

Returns
True if the manager contains at least one catalog. If no catalog exists, it returns false.
ColorSchemeCatalogManager& te::color::ColorSchemeCatalogManager::operator= ( const ColorSchemeCatalogManager rhs)
private

Assignment operator not allowed.

Parameters
rhsThe right-hand-side copy that would be used to copy from.
Returns
A reference to this object.

Friends And Related Function Documentation

Definition at line 77 of file ColorSchemeCatalogManager.h.

Member Data Documentation

std::map<std::string, ColorSchemeCatalog*> te::color::ColorSchemeCatalogManager::m_catalogIdxByName
private

An index from catalog's name to catalog's instance (note: we can not have duplicated names).

Definition at line 214 of file ColorSchemeCatalogManager.h.

std::vector<ColorSchemeCatalog*> te::color::ColorSchemeCatalogManager::m_catalogs
private

This is the list of all system's loaded catalogs.

Definition at line 213 of file ColorSchemeCatalogManager.h.


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