MediaLookupTable Class Reference

#include <Media.hh>

Collaboration diagram for MediaLookupTable:

Collaboration graph
[legend]

Public Member Functions

HashTable const & getTable ()

Static Public Member Functions

static MediaLookupTableourMedia (UsageEnvironment &env)

Protected Member Functions

 MediaLookupTable (UsageEnvironment &env)
virtual ~MediaLookupTable ()

Private Member Functions

Mediumlookup (char const *name) const
void addNew (Medium *medium, char *mediumName)
void remove (char const *name)
void generateNewName (char *mediumName, unsigned maxLen)

Private Attributes

UsageEnvironmentfEnv
HashTablefTable
unsigned fNameGenerator

Friends

class Medium

Detailed Description

Definition at line 92 of file Media.hh.


Constructor & Destructor Documentation

MediaLookupTable::MediaLookupTable ( UsageEnvironment env  )  [protected]

Definition at line 161 of file Media.cpp.

Referenced by ourMedia().

MediaLookupTable::~MediaLookupTable (  )  [protected, virtual]

Definition at line 165 of file Media.cpp.

References fTable.

00165                                     {
00166   delete fTable;
00167 }


Member Function Documentation

MediaLookupTable * MediaLookupTable::ourMedia ( UsageEnvironment env  )  [static]

Definition at line 121 of file Media.cpp.

References env, _Tables::getOurTables(), MediaLookupTable(), _Tables::mediaTable, and NULL.

Referenced by Medium::close(), Medium::lookupByName(), and Medium::Medium().

00121                                                                   {
00122   _Tables* ourTables = _Tables::getOurTables(env);
00123   if (ourTables->mediaTable == NULL) {
00124     // Create a new table to record the media that are to be created in
00125     // this environment:
00126     ourTables->mediaTable = new MediaLookupTable(env);
00127   }
00128   return ourTables->mediaTable;
00129 }

HashTable const& MediaLookupTable::getTable (  )  [inline]

Definition at line 95 of file Media.hh.

References fTable.

00095 { return *fTable; }

Medium * MediaLookupTable::lookup ( char const *  name  )  const [private]

Definition at line 131 of file Media.cpp.

References fTable, and HashTable::Lookup().

Referenced by Medium::lookupByName(), and remove().

00131                                                        {
00132   return (Medium*)(fTable->Lookup(name));
00133 }

void MediaLookupTable::addNew ( Medium medium,
char *  mediumName 
) [private]

Definition at line 135 of file Media.cpp.

References HashTable::Add(), and fTable.

Referenced by Medium::Medium().

00135                                                               {
00136   fTable->Add(mediumName, (void*)medium);
00137 }

void MediaLookupTable::remove ( char const *  name  )  [private]

Definition at line 139 of file Media.cpp.

References fEnv, fTable, _Tables::getOurTables(), HashTable::IsEmpty(), lookup(), _Tables::mediaTable, NULL, and HashTable::Remove().

Referenced by Medium::close().

00139                                               {
00140   Medium* medium = lookup(name);
00141   if (medium != NULL) {
00142     fTable->Remove(name);
00143     if (fTable->IsEmpty()) {
00144       // We can also delete ourselves (to reclaim space):
00145       _Tables* ourTables = _Tables::getOurTables(fEnv);
00146       delete this;
00147       ourTables->mediaTable = NULL;
00148       ourTables->reclaimIfPossible();
00149     }
00150 
00151     delete medium;
00152   }
00153 }

void MediaLookupTable::generateNewName ( char *  mediumName,
unsigned  maxLen 
) [private]

Definition at line 155 of file Media.cpp.

References fNameGenerator.

Referenced by Medium::Medium().

00156                                                             {
00157   // We should really use snprintf() here, but not all systems have it
00158   sprintf(mediumName, "liveMedia%d", fNameGenerator++);
00159 }


Friends And Related Function Documentation

friend class Medium [friend]

Definition at line 102 of file Media.hh.


Field Documentation

UsageEnvironment& MediaLookupTable::fEnv [private]

Definition at line 113 of file Media.hh.

Referenced by remove().

HashTable* MediaLookupTable::fTable [private]

Definition at line 114 of file Media.hh.

Referenced by addNew(), getTable(), lookup(), remove(), and ~MediaLookupTable().

unsigned MediaLookupTable::fNameGenerator [private]

Definition at line 115 of file Media.hh.

Referenced by generateNewName().


The documentation for this class was generated from the following files:
Generated on Tue Mar 25 14:39:50 2014 for live by  doxygen 1.5.2