OpenIG  2.0.4
cross-platform open-source OpenSceneGraph Image Generator
Classes | Public Member Functions | Static Public Member Functions | Protected Types | Protected Attributes | List of all members
OpenIG::Base::IDPool Class Reference

Handy singleton class for ID numbers management. More...

#include <IDPool.h>

Classes

struct  IdGroup
 The IdGroup struct. Internal for ID management. More...
 

Public Member Functions

void initIdGroup (const std::string &group, unsigned int base, unsigned int size=0)
 Inits a ID group by a name, base ID and the size of this group. More...
 
bool getNextId (const std::string &group, unsigned int &id)
 Gets the next ID from a ID group. More...
 
void setAvailableIds (const std::string &group, const std::vector< unsigned int > &ids)
 Sets list of IDs to be reused. More...
 

Static Public Member Functions

static IDPoolinstance ()
 The singleton. More...
 

Protected Types

typedef std::map< std::string, IdGroupIdGroupMap
 

Protected Attributes

IdGroupMap _groups
 name based std::map of IdGroup
 

Detailed Description

Handy singleton class for ID numbers management.

The inherits of OpenIG::Base::ImageGenerator are exepcted to implement ID based scene management of OpenIG::Base::ImageGenerator::Entity, Lights .. etc. There are situation when one will need an automated ID generations, for example when reading a model definition from a file containing ID based constructs like Lights. As a reference see the ModelCompositionPlugin and LightingPlugin implementations/

Author
Trajce Nikolov Nick openi.nosp@m.g@co.nosp@m.mpro..nosp@m.net
Date
Sun Jan 11 2015

Member Function Documentation

bool OpenIG::Base::IDPool::getNextId ( const std::string &  group,
unsigned int &  id 
)

Gets the next ID from a ID group.

Parameters
Thename of the group ID
Thenext ID available
Returns
true on success, false if no more available IDs
Author
Trajce Nikolov Nick openi.nosp@m.g@co.nosp@m.mpro..nosp@m.net
Date
Sun Jan 11 2015
void OpenIG::Base::IDPool::initIdGroup ( const std::string &  group,
unsigned int  base,
unsigned int  size = 0 
)

Inits a ID group by a name, base ID and the size of this group.

Parameters
Thename of this ID group. You can have multiple groups identified by a name
Thebase ID. All consequent IDs are from this one and on
Thesize of the vector. If 10, then only 10 different IDs will be available
Author
Trajce Nikolov Nick openi.nosp@m.g@co.nosp@m.mpro..nosp@m.net
Date
Sun Jan 11 2015
static IDPool* OpenIG::Base::IDPool::instance ( )
static

The singleton.

Returns
The singleton
Author
Trajce Nikolov Nick openi.nosp@m.g@co.nosp@m.mpro..nosp@m.net
Date
Sun Jan 11 2015
void OpenIG::Base::IDPool::setAvailableIds ( const std::string &  group,
const std::vector< unsigned int > &  ids 
)

Sets list of IDs to be reused.

Sets list of IDs to be reused. Let explain it through an example. There is a plugin available, see RunwayLights that creates real Lights for a runway model Once this is paged out in a paged visual database, the IDs of these lights can be reused for another runway sitting on another tile

Parameters
TheID group name
Listof available IDs to be reused
Author
Trajce Nikolov Nick openi.nosp@m.g@co.nosp@m.mpro..nosp@m.net
Date
Sun Jan 11 2015

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