NLSOUND::CSoundSerializer Class Reference


Detailed Description

Pseudo serializer for packed sheet loading/saving. This class act as a wrapper to create sound from xml document being read, call the serialisation method to read/write packed sheet and to delete sounds that are no more needed.

Definition at line 170 of file sound_bank.cpp.

Public Member Functions

 CSoundSerializer ()
 Default constructor.

void readGeorges (const NLMISC::CSmartPtr< NLGEORGES::UForm > &form, const std::string &name)
void removed ()
void serial (NLMISC::IStream &s)

Static Public Member Functions

uint getVersion ()

Data Fields

CSoundSound
 The sound beeing managed by this serializer.


Constructor & Destructor Documentation

NLSOUND::CSoundSerializer::CSoundSerializer  )  [inline]
 

Default constructor.

Definition at line 177 of file sound_bank.cpp.

00178                 : Sound(0)
00179         {}


Member Function Documentation

uint NLSOUND::CSoundSerializer::getVersion  )  [inline, static]
 

Definition at line 269 of file sound_bank.cpp.

References uint.

00269 { return 3; }

void NLSOUND::CSoundSerializer::readGeorges const NLMISC::CSmartPtr< NLGEORGES::UForm > &  form,
const std::string &  name
[inline]
 

Definition at line 182 of file sound_bank.cpp.

00183         {
00184                 // just call the sound creation method with the xml form.
00185                 Sound = CSound::createSound(name, form->getRootNode());
00186 
00187                 // success ?
00188 //              if (_Sound != 0)
00189 //                      CSoundBank::instance()->addSound(_Sound);
00190         }

void NLSOUND::CSoundSerializer::removed  )  [inline]
 

called by GEORGE::loadForm when a sheet read from the packed sheet is no more in the directories.

Definition at line 258 of file sound_bank.cpp.

00259         {
00260                 if (Sound != 0)
00261                 {
00262                         // we remove the sound from the bank and delete it.
00263 //                      CSoundBank::instance()->removeSound(_Sound->getName());
00264                         delete Sound;
00265                 }
00266         }

void NLSOUND::CSoundSerializer::serial NLMISC::IStream s  )  [inline]
 

Definition at line 193 of file sound_bank.cpp.

References NLSOUND::CSound::getSoundType(), s, NLSOUND::CSound::serial(), type, and uint32.

00194         {
00195                 NL_ALLOC_CONTEXT(NLSOUND_CSoundSerializer);
00196                 if (s.isReading())
00197                 {
00198                         // read the first item to find the type
00199                         CSound::TSOUND_TYPE type;
00200                         s.serialEnum(type);
00201                         // read the sound name
00202 //                      std::string name;
00203 //                      s.serial(name);
00204 
00205                         // Instantiate the corresponding sound.
00206                         switch(CSound::TSOUND_TYPE(type))
00207                         {
00208                         case CSound::SOUND_SIMPLE:
00209                                 Sound = new CSimpleSound();
00210                                 break;
00211                         case CSound::SOUND_COMPLEX:
00212                                 Sound = new CComplexSound();
00213                                 break;
00214                         case CSound::SOUND_CONTEXT:
00215                                 Sound = new CContextSound();
00216                                 break;
00217                         case CSound::SOUND_BACKGROUND:
00218                                 Sound = new CBackgroundSound();
00219                                 break;
00220                         default:
00221                                 Sound = 0;
00222                         }
00223 
00224 //                      nlassert(_Sound != 0);
00225                         if (Sound)
00226                         {
00227                                 // read the sound data
00228                                 Sound->serial(s);
00229 //                              CSoundBank::instance()->addSound(_Sound);
00230                         }
00231                 }
00232                 else
00233                 {
00234                         if (Sound == 0)
00235                         {
00236                                 // the sound doesn't exist
00237                                 uint32 i = -1;
00238                                 s.serialEnum(i);
00239 //                              s.serial(std::string("bad sound"));
00240                         }
00241                         else
00242                         {
00243                                 // write the sound type.
00244                                 CSound::TSOUND_TYPE type = Sound->getSoundType();
00245                                 s.serialEnum(type);
00246                                 // write the sound name
00247 //                              s.serial(const_cast<std::string&>(_Sound->getName()));
00248 
00249                                 // and write the sound data
00250                                 Sound->serial(s);
00251                         }
00252                 }
00253         }


Field Documentation

CSound* NLSOUND::CSoundSerializer::Sound
 

The sound beeing managed by this serializer.

Definition at line 174 of file sound_bank.cpp.


The documentation for this class was generated from the following file:
Generated on Tue Mar 16 14:45:41 2004 for NeL by doxygen 1.3.6