MediaLookupTable Class Reference

Collaboration diagram for MediaLookupTable:

Collaboration graph
[legend]

Public Member Functions

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

Static Public Member Functions

static MediaLookupTableourMedia (UsageEnvironment &env)

Protected Member Functions

 MediaLookupTable (UsageEnvironment &env)
virtual ~MediaLookupTable ()

Private Attributes

UsageEnvironmentfEnv
HashTablefTable
unsigned fNameGenerator

Detailed Description

Definition at line 25 of file Media.cpp.


Constructor & Destructor Documentation

MediaLookupTable::MediaLookupTable ( UsageEnvironment env  )  [protected]

Definition at line 185 of file Media.cpp.

Referenced by ourMedia().

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

Definition at line 189 of file Media.cpp.

References fTable.

00189                                     {
00190   delete fTable;
00191 }


Member Function Documentation

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

Definition at line 145 of file Media.cpp.

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

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

00145                                                                   {
00146   _Tables* ourTables = _Tables::getOurTables(env);
00147   if (ourTables->mediaTable == NULL) {
00148     // Create a new table to record the media that are to be created in
00149     // this environment:
00150     ourTables->mediaTable = new MediaLookupTable(env);
00151   }
00152   return (MediaLookupTable*)(ourTables->mediaTable);
00153 }

Medium * MediaLookupTable::lookup ( char const *  name  )  const

Definition at line 155 of file Media.cpp.

References fTable, and HashTable::Lookup().

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

00155                                                        {
00156   return (Medium*)(fTable->Lookup(name));
00157 }

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

Definition at line 159 of file Media.cpp.

References HashTable::Add(), and fTable.

Referenced by Medium::Medium().

00159                                                               {
00160   fTable->Add(mediumName, (void*)medium);
00161 }

void MediaLookupTable::remove ( char const *  name  ) 

Definition at line 163 of file Media.cpp.

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

Referenced by Medium::close().

00163                                               {
00164   Medium* medium = lookup(name);
00165   if (medium != NULL) {
00166     fTable->Remove(name);
00167     if (fTable->IsEmpty()) {
00168       // We can also delete ourselves (to reclaim space):
00169       _Tables* ourTables = _Tables::getOurTables(fEnv);
00170       delete this;
00171       ourTables->mediaTable = NULL;
00172       ourTables->reclaimIfPossible();
00173     }
00174 
00175     delete medium;
00176   }
00177 }

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

Definition at line 179 of file Media.cpp.

References fNameGenerator.

Referenced by Medium::Medium().

00180                                                             {
00181   // We should really use snprintf() here, but not all systems have it
00182   sprintf(mediumName, "liveMedia%d", fNameGenerator++);
00183 }


Field Documentation

UsageEnvironment& MediaLookupTable::fEnv [private]

Definition at line 42 of file Media.cpp.

Referenced by remove().

HashTable* MediaLookupTable::fTable [private]

Definition at line 43 of file Media.cpp.

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

unsigned MediaLookupTable::fNameGenerator [private]

Definition at line 44 of file Media.cpp.

Referenced by generateNewName().


The documentation for this class was generated from the following file:
Generated on Tue Oct 7 15:39:45 2008 for live by  doxygen 1.5.2