osg::TextFaceFactory Class Reference

#include <OSGTextFaceFactory.h>

List of all members.

Public Member Functions

 ~TextFaceFactory ()
TextVectorFacecreateVectorFace (const std::string &family, TextFace::Style style=TextFace::STYLE_PLAIN)
TextPixmapFacecreatePixmapFace (const std::string &family, TextFace::Style style=TextFace::STYLE_PLAIN, UInt32 size=32)
TextTXFFacecreateTXFFace (const std::string &family, TextFace::Style style=TextFace::STYLE_PLAIN, const TextTXFParam &param=TextTXFParam())
void clearCache ()
void getFontFamilies (std::vector< std::string > &families) const

Static Public Member Functions

static bool isValid (void)
static TextFaceFactorythe ()

Private Types

typedef std::multimap
< std::string, TextVectorFace * > 
VectorFaceMap
typedef std::multimap
< std::string, TextPixmapFace * > 
PixmapFaceMap
typedef std::multimap
< std::string, TextTXFFace * > 
TXFFaceMap

Private Member Functions

 TextFaceFactory ()
 TextFaceFactory (const TextFaceFactory &)
const TextFaceFactoryoperator= (const TextFaceFactory &)

Private Attributes

TextBackend_backend
VectorFaceMap _vectorFaceMap
PixmapFaceMap _pixmapFaceMap
TXFFaceMap _txfFaceMap

Static Private Attributes

static bool _valid = false
static TextFaceFactory _the


Detailed Description

A singleton used to create new faces. The TextFaceFactory keeps a cache of all currently created faces. When creating a new face, the factory first searches in the cache if the face already exists. If yes, it returns that face. If no, it creates a new face, adds it to the cache, and returns it. Usually you do not use the TextFaceFactory singleton directly, instead you use the create method of the TextFace classes.
Author:
Patrick Dähne

Definition at line 78 of file OSGTextFaceFactory.h.


Member Typedef Documentation

typedef std::multimap<std::string, TextVectorFace*> osg::TextFaceFactory::VectorFaceMap [private]

Defines the map that contains the vector faces

Definition at line 156 of file OSGTextFaceFactory.h.

typedef std::multimap<std::string, TextPixmapFace*> osg::TextFaceFactory::PixmapFaceMap [private]

Defines the map that contains the pixmap faces

Definition at line 162 of file OSGTextFaceFactory.h.

typedef std::multimap<std::string, TextTXFFace*> osg::TextFaceFactory::TXFFaceMap [private]

Defines the map that contains the TXF faces

Definition at line 168 of file OSGTextFaceFactory.h.


Constructor & Destructor Documentation

osg::TextFaceFactory::~TextFaceFactory (  ) 

Destroys the TextFaceFactory object.

Definition at line 118 of file OSGTextFaceFactory.cpp.

References _backend, _valid, and clearCache().

00119 {
00120     _valid = false;
00121     clearCache();
00122     delete _backend;
00123 }

osg::TextFaceFactory::TextFaceFactory (  )  [private]

Default Constructor

Definition at line 95 of file OSGTextFaceFactory.cpp.

References _backend, _valid, osg::addSystemExitFunction(), and osg::terminateFaceFactory().

00096 : _backend(), _vectorFaceMap(), _pixmapFaceMap(), _txfFaceMap()
00097 {
00098     _valid = true;
00099 #if defined(_WIN32)
00100     _backend = new TextWIN32Backend();
00101 #elif defined(__APPLE__)
00102     _backend = new TextMacBackend();
00103     //_backend = new TextFT2Backend();
00104 #elif defined(FT2_LIB)
00105     _backend = new TextFT2Backend();
00106 #else
00107     _backend = 0;
00108 #endif
00109 
00110     addSystemExitFunction(&terminateFaceFactory);
00111 }

osg::TextFaceFactory::TextFaceFactory ( const TextFaceFactory  )  [private]

Copy constructor (not implemented!)


Member Function Documentation

TextVectorFace* osg::TextFaceFactory::createVectorFace ( const std::string &  family,
TextFace::Style  style = TextFace::STYLE_PLAIN 
)

Tries to create a vector face.

Parameters:
family The font family of the face (Arial, Courier etc.)
style The style of the face (bold, italic etc.)
Returns:
The vector face object or 0 in case of an error.

Referenced by osg::TextVectorFace::create().

TextPixmapFace* osg::TextFaceFactory::createPixmapFace ( const std::string &  family,
TextFace::Style  style = TextFace::STYLE_PLAIN,
UInt32  size = 32 
)

Tries to create a pixmap face.

Parameters:
family The font family of the face (Arial, Courier etc.)
style The style of the face (bold, italic etc.)
size The size of the pixmap font in pixels.
Returns:
The pixmap face object or 0 in case of an error.

Referenced by osg::TextPixmapFace::create().

TextTXFFace* osg::TextFaceFactory::createTXFFace ( const std::string &  family,
TextFace::Style  style = TextFace::STYLE_PLAIN,
const TextTXFParam param = TextTXFParam() 
)

Tries to create a TXF face.

Parameters:
family The font family of the face (Arial, Courier etc.)
style The style of the face (bold, italic etc.)
param Parameters that affect the creation of the TXF face.
Returns:
The TXF face object or 0 in case of an error.

void osg::TextFaceFactory::clearCache (  ) 

Removes all faces from the face cache.

Definition at line 219 of file OSGTextFaceFactory.cpp.

References _pixmapFaceMap, _txfFaceMap, _vectorFaceMap, and osg::subRefP().

Referenced by ~TextFaceFactory().

00220 {
00221     // Vector faces
00222     VectorFaceMap::iterator vIt;
00223     for (vIt = _vectorFaceMap.begin(); vIt != _vectorFaceMap.end(); ++vIt)
00224     {
00225         assert(vIt->second != 0);
00226         subRefP(vIt->second);
00227     }
00228     _vectorFaceMap.clear();
00229 
00230     // Pixmap faces
00231     PixmapFaceMap::iterator pIt;
00232     for (pIt = _pixmapFaceMap.begin(); pIt != _pixmapFaceMap.end(); ++pIt)
00233     {
00234         assert(pIt->second != 0);
00235         subRefP(pIt->second);
00236     }
00237     _pixmapFaceMap.clear();
00238 
00239     // TXF faces
00240     TXFFaceMap::iterator tIt;
00241     for (tIt = _txfFaceMap.begin(); tIt != _txfFaceMap.end(); ++tIt)
00242     {
00243         assert(tIt->second != 0);
00244         subRefP(tIt->second);
00245     }
00246     _txfFaceMap.clear();
00247 }

void osg::TextFaceFactory::getFontFamilies ( std::vector< std::string > &  families  )  const

Returns the names of all font families available.

Parameters:
families A vector that gets filled with the names of all font families.

bool osg::TextFaceFactory::isValid ( void   )  [static]

Definition at line 261 of file OSGTextFaceFactory.cpp.

References _valid.

00262 {
00263     return _valid;
00264 }

TextFaceFactory & osg::TextFaceFactory::the ( void   )  [inline, static]

Returns the single instance of the FaceFactory singleton.

Returns:
The single instance.

Definition at line 43 of file OSGTextFaceFactory.inl.

References _the.

Referenced by osg::TextVectorFace::create(), and osg::TextPixmapFace::create().

00043 { return _the; } 

const TextFaceFactory& osg::TextFaceFactory::operator= ( const TextFaceFactory  )  [private]

Copy operator (not implemented!)


Member Data Documentation

bool osg::TextFaceFactory::_valid = false [static, private]

The single instance of the TextFaceFactory singleton

Definition at line 149 of file OSGTextFaceFactory.h.

Referenced by isValid(), TextFaceFactory(), and ~TextFaceFactory().

Definition at line 150 of file OSGTextFaceFactory.h.

Referenced by the().

The backend that creates all faces

Definition at line 153 of file OSGTextFaceFactory.h.

Referenced by TextFaceFactory(), and ~TextFaceFactory().

The map of vector faces currently instantiated (face cache)

Definition at line 159 of file OSGTextFaceFactory.h.

Referenced by clearCache().

The map of pixmap faces currently instanciated (face cache)

Definition at line 165 of file OSGTextFaceFactory.h.

Referenced by clearCache().

The map of TXF faces currently instantiated (face cache)

Definition at line 171 of file OSGTextFaceFactory.h.

Referenced by clearCache().


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

Generated on Mon Mar 17 11:20:26 2008 for OpenSG by  doxygen 1.5.5