Ocean
Ocean::Media::Manager Class Reference

This class is the manager for all media objects. More...

Inheritance diagram for Ocean::Media::Manager:

Public Types

typedef std::vector< std::string > Names
 Definition of a vector holding library names. More...
 

Public Member Functions

MediumRef newMedium (const std::string &url, bool useExclusive=false)
 Creates a new medium by a given url. More...
 
MediumRef newMedium (const std::string &url, const Medium::Type type, bool useExclusive=false)
 Creates a new medium by a given url and an expected type. More...
 
MediumRef newMedium (const std::string &url, const std::string &library, const Medium::Type type, bool useExclusive=false)
 Creates a new medium by a given url, a library name and an expected type. More...
 
RecorderRef newRecorder (const Recorder::Type type, const std::string &library=std::string())
 Creates a new recorder specified by the recorder type. More...
 
Library::Definitions selectableMedia () const
 Returns a list of selectable mediums. More...
 
Library::Definitions selectableMedia (const Medium::Type type) const
 Returns a list of specific selectable mediums. More...
 
Names libraries () const
 Returns the names currently registered media libraries. More...
 
void release ()
 Releases all registered libraries. More...
 
 Manager ()
 Creates a new manager object. More...
 
virtual ~Manager ()
 Destructs the manager, called by the singleton object. More...
 
template<typename T >
bool registerLibrary (const std::string &name)
 Registers a new library. More...
 
bool unregisterLibrary (const std::string &name)
 Unregisters a library. More...
 

Protected Attributes

Libraries libraries_
 Registered libraries. More...
 
Lock lock_
 Lock for the libraries. More...
 

Private Types

typedef std::pair< LibraryRef, unsigned int > LibraryCounterPair
 Definition of a pair combining a library with a reference counter. More...
 
typedef std::vector< LibraryCounterPairLibraries
 Definition of a vector holding library pairs. More...
 

Friends

class Singleton< Manager >
 
class Library
 

Additional Inherited Members

- Static Public Member Functions inherited from Ocean::Singleton< Manager >
static Manager & get ()
 Returns a reference to the unique object. More...
 
- Protected Member Functions inherited from Ocean::Singleton< Manager >
 Singleton ()=default
 Default constructor. More...
 

Detailed Description

This class is the manager for all media objects.

As media objects cannot be created directly this manager is necessary to create individual media object.
Further, this manager encapsulates individual media libraries and allows to create media objects from specific or random libraries during one unique interface.

See also
Library, Medium.

Member Typedef Documentation

◆ Libraries

Definition of a vector holding library pairs.

◆ LibraryCounterPair

typedef std::pair<LibraryRef, unsigned int> Ocean::Media::Manager::LibraryCounterPair
private

Definition of a pair combining a library with a reference counter.

◆ Names

typedef std::vector<std::string> Ocean::Media::Manager::Names

Definition of a vector holding library names.

Constructor & Destructor Documentation

◆ Manager()

Ocean::Media::Manager::Manager ( )

Creates a new manager object.

◆ ~Manager()

virtual Ocean::Media::Manager::~Manager ( )
virtual

Destructs the manager, called by the singleton object.

Beware: The release function should be called before the singleton invokes the destructor. In common cases the singleton is released to late for internal library objects.

Member Function Documentation

◆ libraries()

Names Ocean::Media::Manager::libraries ( ) const

Returns the names currently registered media libraries.

Returns
Registered media libraries

◆ newMedium() [1/3]

MediumRef Ocean::Media::Manager::newMedium ( const std::string &  url,
bool  useExclusive = false 
)

Creates a new medium by a given url.

If no medium can be created an empty reference is returned.

Parameters
urlUrl of the medium
useExclusiveDetermines whether the caller would like to use this medium exclusively
Returns
Reference to the new medium

◆ newMedium() [2/3]

MediumRef Ocean::Media::Manager::newMedium ( const std::string &  url,
const Medium::Type  type,
bool  useExclusive = false 
)

Creates a new medium by a given url and an expected type.

If no medium can be created an empty reference is returned.

Parameters
urlUrl of the medium
typeType of the expected medium
useExclusiveDetermines whether the caller would like to use this medium exclusively
Returns
Reference to the new medium

◆ newMedium() [3/3]

MediumRef Ocean::Media::Manager::newMedium ( const std::string &  url,
const std::string &  library,
const Medium::Type  type,
bool  useExclusive = false 
)

Creates a new medium by a given url, a library name and an expected type.

If no medium can be created an empty reference is returned.

Parameters
urlUrl of the medium
libraryName of the library to use for this medium
typeType of the expected medium
useExclusiveDetermines whether the caller would like to use this medium exclusively
Returns
Reference to the new medium

◆ newRecorder()

RecorderRef Ocean::Media::Manager::newRecorder ( const Recorder::Type  type,
const std::string &  library = std::string() 
)

Creates a new recorder specified by the recorder type.

Parameters
typeType of the recorder to return
libraryThe optional name of the library to be used, empty to use any library
Returns
Reference to the new recorder

◆ registerLibrary()

template<typename T >
bool Ocean::Media::Manager::registerLibrary ( const std::string &  name)

Registers a new library.

With each register call, the reference counter for a specific library will be incremented. Each call to registerLibrary() needs to be balanced with a corresponding call of unregisterLibrary() before shutting down.

Parameters
nameThe name of the library to register, must be valid
Returns
True, if the library has not been registered before
Template Parameters
TThe data type of the library to register
See also
unregisterLibrary().

◆ release()

void Ocean::Media::Manager::release ( )

Releases all registered libraries.

This function should be called once before the application is shutting down. However this function should be called after all medium reference have been released.

◆ selectableMedia() [1/2]

Library::Definitions Ocean::Media::Manager::selectableMedia ( ) const

Returns a list of selectable mediums.

Returns
Selectable mediums

◆ selectableMedia() [2/2]

Library::Definitions Ocean::Media::Manager::selectableMedia ( const Medium::Type  type) const

Returns a list of specific selectable mediums.

Parameters
typeType of the selectable mediums
Returns
Selectable mediums

◆ unregisterLibrary()

bool Ocean::Media::Manager::unregisterLibrary ( const std::string &  name)

Unregisters a library.

With each unregister call, the reference counter for a specific library will be decremented and removed from the system if the counter reaches zero. Each call to registerLibrary() needs to be balanced with a corresponding call of unregisterLibrary() before shutting down.

Parameters
nameThe name of the library to unregister, must be valid
Returns
True, if the library was actually removed from the system (as the reference counter reached zero); False, if the library is still used by someone else
See also
registerLibrary().

Friends And Related Function Documentation

◆ Library

friend class Library
friend

◆ Singleton< Manager >

friend class Singleton< Manager >
friend

Field Documentation

◆ libraries_

Libraries Ocean::Media::Manager::libraries_
protected

Registered libraries.

◆ lock_

Lock Ocean::Media::Manager::lock_
mutableprotected

Lock for the libraries.


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