Resource_Sound.cpp
Go to the documentation of this file.00001 //*** Resource_Sound.cpp *** 00002 00003 #include "Resource_Sound.h" 00004 #include "ResourceManager.h" 00005 #include "Sound.h" 00006 #include "Filename.h" 00007 00008 00009 //*** Constructor *** 00010 00011 Resource_Sound::Resource_Sound(): 00012 sound_(0) 00013 { 00014 } 00015 00016 00017 //*** Constructor *** 00018 00019 Resource_Sound::Resource_Sound(const Filename& filename) 00020 { 00021 sound_=siResourceManager->GetSound(filename.GetStringId()); 00022 siResourceManager->IncreaseReferenceCount(sound_); 00023 } 00024 00025 00026 //*** Constructor *** 00027 00028 Resource_Sound::Resource_Sound(const char* filenameStr) 00029 { 00030 Filename filename(filenameStr); 00031 sound_=siResourceManager->GetSound(filename.GetStringId()); 00032 siResourceManager->IncreaseReferenceCount(sound_); 00033 } 00034 00035 00036 //*** Constructor *** 00037 00038 Resource_Sound::Resource_Sound(StringId filenameId) 00039 { 00040 Filename filename(filenameId); 00041 sound_=siResourceManager->GetSound(filename.GetStringId()); 00042 siResourceManager->IncreaseReferenceCount(sound_); 00043 } 00044 00045 00046 //*** Destructor *** 00047 00048 Resource_Sound::~Resource_Sound() 00049 { 00050 if (sound_) 00051 { 00052 siResourceManager->DecreaseReferenceCount(sound_); 00053 } 00054 } 00055 00056 00058 00059 Resource_Sound::Resource_Sound(const Resource_Sound& resource): 00060 sound_(resource.sound_) 00061 { 00062 siResourceManager->IncreaseReferenceCount(sound_); 00063 } 00064 00065 00066 //*** Assignment operator *** 00067 00068 const Resource_Sound& Resource_Sound::operator =(const Resource_Sound& resource) 00069 { 00070 sound_=resource.sound_; 00071 siResourceManager->IncreaseReferenceCount(sound_); 00072 return *this; 00073 } 00074 00075 00076 //*** GetSound *** 00077 00078 const Sound* Resource_Sound::GetSound() const 00079 { 00080 return sound_; 00081 } 00082 00083 00084 //*** Play *** 00085 00086 void Resource_Sound::Play(float priority, bool looping) 00087 { 00088 if (sound_) 00089 { 00090 sound_->Play(priority,looping); 00091 } 00092 }
Reproduction/republishing of any material on this site without permission is strictly prohibited.
