Phonon::GlobalDescriptionContainer

Search for usage in LXR

#include <globaldescriptioncontainer.h>

Public Types

typedef int global_id_t
 
typedef QMap< global_id_t, D > GlobalDescriptorMap
 
typedef QMapIterator< global_id_t, D > GlobalDescriptorMapIterator
 
typedef QMapIterator< global_id_t, local_id_t > LocaIdMapIterator
 
typedef int local_id_t
 
typedef QMap< global_id_t, local_id_t > LocalIdMap
 

Public Member Functions

void add (void *obj, D descriptor)
 
void add (void *obj, local_id_t index, const QString &name, const QString &type=QString())
 
void clearListFor (void *obj)
 
fromIndex (global_id_t key)
 
QList< int > globalIndexes ()
 
QList< D > listFor (const void *obj) const
 
int localIdFor (const void *obj, global_id_t key) const
 
void register_ (void *obj)
 
void unregister_ (void *obj)
 

Static Public Member Functions

static GlobalDescriptionContainerinstance ()
 

Static Public Attributes

static GlobalDescriptionContainerself = 0
 

Protected Member Functions

global_id_t nextFreeIndex ()
 

Protected Attributes

GlobalDescriptorMap m_globalDescriptors
 
QMap< const void *, LocalIdMapm_localIds
 
global_id_t m_peak
 

Detailed Description

template<typename D>
class Phonon::GlobalDescriptionContainer< D >

A container for object descriptions. The primary use of this container is to turn ObjectDescriptions with unique id scope smaller than backend into globally unique ones.

For example a MediaController enhances a MediaObject, you may have multiple MediaObjects and thus MediaControllers in one application. The interface to query all subtitles is only available on the backend class itself though, so the index/id of the descriptions handed to a Phonon API user must be unique with global scope. This is where the GlobalDescriptionContainer comes in. It allows arbitrary objects to register (using object address) with the container (which is a singleton). The object hands its locally unique ObjectDescriptions to the container, which turns it into a globally unique description and maps the global id to the local id.

That way it is possible to easily map local to global description objects.

Author
Harald Sitter sitte.nosp@m.r@kd.nosp@m.e.org

Definition at line 60 of file globaldescriptioncontainer.h.

Member Typedef Documentation

◆ global_id_t

template<typename D >
int Phonon::GlobalDescriptionContainer< D >::global_id_t

Definition at line 63 of file globaldescriptioncontainer.h.

◆ GlobalDescriptorMap

template<typename D >
QMap<global_id_t, D> Phonon::GlobalDescriptionContainer< D >::GlobalDescriptorMap

Definition at line 66 of file globaldescriptioncontainer.h.

◆ GlobalDescriptorMapIterator

template<typename D >
QMapIterator<global_id_t, D> Phonon::GlobalDescriptionContainer< D >::GlobalDescriptorMapIterator

Definition at line 67 of file globaldescriptioncontainer.h.

◆ LocaIdMapIterator

template<typename D >
QMapIterator<global_id_t, local_id_t> Phonon::GlobalDescriptionContainer< D >::LocaIdMapIterator

Definition at line 70 of file globaldescriptioncontainer.h.

◆ local_id_t

template<typename D >
int Phonon::GlobalDescriptionContainer< D >::local_id_t

Definition at line 64 of file globaldescriptioncontainer.h.

◆ LocalIdMap

template<typename D >
QMap<global_id_t, local_id_t> Phonon::GlobalDescriptionContainer< D >::LocalIdMap

Definition at line 69 of file globaldescriptioncontainer.h.

Constructor & Destructor Documentation

◆ ~GlobalDescriptionContainer()

template<typename D >
virtual Phonon::GlobalDescriptionContainer< D >::~GlobalDescriptionContainer ( )
inlinevirtual

Definition at line 82 of file globaldescriptioncontainer.h.

◆ GlobalDescriptionContainer()

template<typename D >
Phonon::GlobalDescriptionContainer< D >::GlobalDescriptionContainer ( )
inlineprotected

Definition at line 262 of file globaldescriptioncontainer.h.

Member Function Documentation

◆ add() [1/2]

template<typename D >
void Phonon::GlobalDescriptionContainer< D >::add ( void * obj,
D descriptor )
inline

Overload function.

The index of the provided descriptor must be unique within the context of the container.

Parameters
objThe object
descriptorthe DescriptionObject with unique index

Definition at line 207 of file globaldescriptioncontainer.h.

◆ add() [2/2]

template<typename D >
void Phonon::GlobalDescriptionContainer< D >::add ( void * obj,
local_id_t index,
const QString & name,
const QString & type = QString() )
inline

Adds a new description object for a specific object.

A description object must have a global unique id, which is ensured by using this function, which will either reuse an existing equal ObjectDescription or use the next free unique ID. Using the provided index the unique ID is then mapped to the one of the specific object.

Parameters
objThe object
indexlocal ID (i.e. within the object @obj)
nameName of the description
typeType of the description (e.g. file)

Definition at line 166 of file globaldescriptioncontainer.h.

◆ clearListFor()

template<typename D >
void Phonon::GlobalDescriptionContainer< D >::clearListFor ( void * obj)
inline

Clear the internal mapping of global to local id for a given object.

Parameters
objThe object

Definition at line 144 of file globaldescriptioncontainer.h.

◆ fromIndex()

template<typename D >
D Phonon::GlobalDescriptionContainer< D >::fromIndex ( global_id_t key)
inline
Parameters
keythe global ID of the ObjectDescription
Returns
ObjectDescriptions associated with a given ID

Definition at line 103 of file globaldescriptioncontainer.h.

◆ globalIndexes()

template<typename D >
QList< int > Phonon::GlobalDescriptionContainer< D >::globalIndexes ( )
inline
Returns
a list of all global unique IDs of all stored ObjectDescriptions

Definition at line 87 of file globaldescriptioncontainer.h.

◆ instance()

template<typename D >
static GlobalDescriptionContainer * Phonon::GlobalDescriptionContainer< D >::instance ( )
inlinestatic

Definition at line 75 of file globaldescriptioncontainer.h.

◆ listFor()

template<typename D >
QList< D > Phonon::GlobalDescriptionContainer< D >::listFor ( const void * obj) const
inline

List of ObjectDescriptions for a given object, the descriptions are limied by the scope of the type (obviously), so you only get ObjectDescription from the container.

Parameters
objThe object
Returns
the list of ObjectDescriptions for a given object, the descriptions are limied by the scope of the type (obviously), so you only get subtitle descriptions from a subtitle container.

Definition at line 229 of file globaldescriptioncontainer.h.

◆ localIdFor()

template<typename D >
int Phonon::GlobalDescriptionContainer< D >::localIdFor ( const void * obj,
global_id_t key ) const
inline
Parameters
objThe object
keythe global ID (i.e. index of an ObjectDescription)
Returns
the local ID associated with the description object

Definition at line 250 of file globaldescriptioncontainer.h.

◆ nextFreeIndex()

template<typename D >
global_id_t Phonon::GlobalDescriptionContainer< D >::nextFreeIndex ( )
inlineprotected
Returns
next free unique index to be used as global ID for an ObjectDescription

Definition at line 270 of file globaldescriptioncontainer.h.

◆ register_()

template<typename D >
void Phonon::GlobalDescriptionContainer< D >::register_ ( void * obj)
inline

Registers a new object within the container.

This essentially creates a new empty ID map.

Parameters
objThe reference object

Definition at line 116 of file globaldescriptioncontainer.h.

◆ unregister_()

template<typename D >
void Phonon::GlobalDescriptionContainer< D >::unregister_ ( void * obj)
inline

Unregisters a object from the container.

This essentially clears the ID map and removes all traces of the object.

Parameters
objThe object

Definition at line 130 of file globaldescriptioncontainer.h.

Member Data Documentation

◆ m_globalDescriptors

template<typename D >
GlobalDescriptorMap Phonon::GlobalDescriptionContainer< D >::m_globalDescriptors
protected

Definition at line 275 of file globaldescriptioncontainer.h.

◆ m_localIds

template<typename D >
QMap<const void *, LocalIdMap> Phonon::GlobalDescriptionContainer< D >::m_localIds
protected

Definition at line 276 of file globaldescriptioncontainer.h.

◆ m_peak

template<typename D >
global_id_t Phonon::GlobalDescriptionContainer< D >::m_peak
protected

Definition at line 278 of file globaldescriptioncontainer.h.

◆ self

template<typename D >
GlobalDescriptionContainer< D > * Phonon::GlobalDescriptionContainer< D >::self = 0
static

Definition at line 73 of file globaldescriptioncontainer.h.


The documentation for this class was generated from the following file:
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 20 2024 11:49:26 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.