HyperspaceExplorer 0.7.1
Classes | Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | Friends
ColorManagerManager Class Reference

Singleton to set the color scheme globally - proxies the color manager. More...

#include <ColorManager.h>

Collaboration diagram for ColorManagerManager:
Collaboration graph
[legend]

List of all members.

Classes

struct  BadColorManagerException
 Thrown by createColorManager() when name does not map to a ColorManager. More...
struct  ColorManagerUnsetException
 Thrown if a ColorManager function is called before a ColorManager has been set. More...

Public Types

typedef ColorManager *(* CreateColMgrCallback )()
 callback function generating a ColorManager and returning a ColorManager*

Public Member Functions

void setColorManager (ColorManager *cm)
 determine which coloring scheme to use
void setFunction (Displayable *_f)
 proxy function for ColorManager::setFunction()
void calibrateColor (const VecMath::Vector< 4 > &, const Color &=Color())
 proxy function for ColorManager::calibrateColor()
void setColor (const VecMath::Vector< 4 > &x)
 proxy function for ColorManager::setColor()
Color getColor (const VecMath::Vector< 4 > &x)
 proxy function for ColorManager::getColor()
void depthCueColor (double wmax, double wmin, double w, const VecMath::Vector< 4 > &x)
 proxy function for ColorManager::depthCueColor()
void setRGB (const Color &_col)
 proxy function for ColorManager::setRGB()
std::string getContents ()
 debugging output
bool registerColorManager (const std::string &, CreateColMgrCallback)
 Register a ColorManager class with a name, so we can instantiate it.
bool unregisterColorManager (const std::string &)
 Unregister a ColorManager with the given name.
std::vector< std::stringgetRegisteredColorManagers ()
 Returns a list of registered ColorManager s.
void setColorManager (const std::string &)
 Set the ColorManager to a class registered by name.
bool isColorManagerSet () const
 Returns whether a ColorManager has already been set.

Private Types

typedef std::map< std::string,
CreateColMgrCallback
CallbackMap
 stores a creator function with a string containing the class name

Private Member Functions

 ColorManagerManager ()
 ColorManagerManager (const ColorManagerManager &)
ColorManagerManageroperator= (const ColorManagerManager &)
 ~ColorManagerManager ()

Private Attributes

std::auto_ptr< ColorManagercolorManager
 The proxied ColorManager.
CallbackMap callbacks
 Stores the ColorManager creators.

Friends

class Loki::CreateUsingNew< ColorManagerManager >
 Lets Loki::SingletonHolder instantiate a ColorManagerManager.

Detailed Description

Singleton to set the color scheme globally - proxies the color manager.

The object also serves as a Factory for ColorManager s, instantiating a ColorManager when given a string that describes it. It stores creator functions for all ColorManager implementations in a std::map indexed by a string.

It also returns a list of registered ColorManager s, which can be used to set up a menu to change the ColorManager (for example :-).

Todo:

implement a map<Function *, ColorManager *> to store one ColorManager per function - this will probably break the existing interface

Shouldn't htis class implement the ColorManager interface? It delegates all calls to a ColorManager and serves as one, doesn't it?


Constructor & Destructor Documentation

ColorManagerManager::ColorManagerManager ( ) [inline, private]

disabled default constructor

ColorManagerManager::ColorManagerManager ( const ColorManagerManager ) [private]

disabled copy constructor

ColorManagerManager::~ColorManagerManager ( ) [inline, private]

disabled destructor


Member Function Documentation

ColorManagerManager& ColorManagerManager::operator= ( const ColorManagerManager ) [private]

disabled assignment operator

bool ColorManagerManager::registerColorManager ( const std::string name,
CreateColMgrCallback  creator 
)

Register a ColorManager class with a name, so we can instantiate it.

Parameters:
nameThe name by which this class is called from outside. This name is passed to setColorManager() to select the desired ColorManager.
creatorA function which returns a new instance of the registered ColorManager
Returns:
Whether the registration succeeded. This return value is needed because registration takes place by defining a const bool in a global anonymous namespace.
See also:
ColorManager for an example usage of this function.

References callbacks, and std::map< _Key, _Tp, _Compare, _Alloc >::insert().

Here is the call graph for this function:

void ColorManagerManager::setColorManager ( const std::string name)

Set the ColorManager to a class registered by name.

Parameters:
nameName the ColorManager is known and registered by

References callbacks, std::map< _Key, _Tp, _Compare, _Alloc >::end(), std::map< _Key, _Tp, _Compare, _Alloc >::find(), and setColorManager().

Here is the call graph for this function:

bool ColorManagerManager::unregisterColorManager ( const std::string name)

Unregister a ColorManager with the given name.

I can't really think of a reason why one would want to unregister a ColorManager at runtime, so this function is just there for the sake of completeness. It's a one-liner anyway.

Parameters:
nameThe name by which the ColorManager is called from outside

References callbacks, and std::map< _Key, _Tp, _Compare, _Alloc >::erase().

Here is the call graph for this function:


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends

Generated on Mon Apr 9 2012 20:25:17 for HyperspaceExplorer 0.7.1 by doxygen 1.7.4  -  Hosted bySourceForge.net Logo