VR-Forces 4.1.1 Class Documentation
DtAudioSettingsRecord.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright (c) 2012 MaK Technologies, Inc.
3  * All rights reserved.
4  *****************************************************************************/
5 
9 
10 #pragma once
11 
14 
16 
17 #include <string>
18 #include <vector>
19 
20 namespace makVrv
21 {
22 
27  {
28  public:
31  typedef std::vector<DtEntitySoundMapRecord> EntityMapRecordList;
32 
35  typedef std::vector<DtFireSoundMapRecord> FireMapRecordList;
36 
39  typedef std::vector<DtDetonationSoundMapRecord> DetonationMapRecordList;
40 
43 
47 
49  virtual ~DtAudioSettingsRecord();
50 
54  DtAudioSettingsRecord& operator = ( DtAudioSettingsRecord rhs );
55 
59  virtual void swap( DtAudioSettingsRecord& other );
60 
62  virtual void sort();
63 
65  virtual void clearMaps();
66 
69  virtual void setAudioEnabled( bool val );
70 
74  virtual bool audioEnabled() const;
75 
78  virtual void setVolume( double val );
79 
82  virtual double volume() const;
83 
86  virtual void setSoundRangeEnabled( bool val );
87 
91  virtual bool soundRangeEnabled() const;
92 
95  virtual void setSoundRange( double val );
96 
99  virtual double soundRange() const;
100 
103  virtual unsigned int entityMapSize() const;
104 
107  virtual unsigned int weaponFireMapSize() const;
108 
111  virtual unsigned int detonationMapSize() const;
112 
115  virtual EntityMapRecordList& entityMap();
116 
121  virtual EntityMapRecordList::iterator
122  entityMapFind( DtEntitySoundMapRecord& record );
123 
128  virtual EntityMapRecordList::const_iterator
129  entityMapFind( const DtEntitySoundMapRecord& record );
130 
135  virtual const DtEntitySoundMapRecord&
136  entityMapAt( unsigned int index ) const;
137 
141  virtual unsigned int
142  entityMapIndex( const DtEntitySoundMapRecord& record ) const;
143 
146  virtual FireMapRecordList& weaponFireMap();
147 
152  virtual FireMapRecordList::iterator
153  weaponFireMapFind( DtFireSoundMapRecord& record );
154 
159  virtual FireMapRecordList::const_iterator
160  weaponFireMapFind( const DtFireSoundMapRecord& record );
161 
166  virtual const DtEntitySoundMapRecord&
167  weaponFireMapAt( unsigned int index ) const;
168 
172  virtual unsigned int
173  weaponFireMapIndex( const DtFireSoundMapRecord& record ) const;
174 
177  virtual DetonationMapRecordList& detonationMap();
178 
183  virtual DetonationMapRecordList::iterator
184  detonationMapFind( DtDetonationSoundMapRecord& record );
185 
190  virtual DetonationMapRecordList::const_iterator
191  detonationMapFind( const DtDetonationSoundMapRecord& record );
192 
197  virtual const DtEntitySoundMapRecord&
198  detonationMapAt( unsigned int index ) const;
199 
203  virtual unsigned int
204  detonationMapIndex( const DtDetonationSoundMapRecord& record ) const;
205 
208  virtual void entityMapAdd( const DtEntitySoundMapRecord& record );
209 
212  virtual void entityMapRemove( const DtEntitySoundMapRecord& record );
213 
217  virtual void weaponFireMapAdd( const DtFireSoundMapRecord& record );
218 
221  virtual void weaponFireMapRemove( const DtFireSoundMapRecord& record );
222 
226  virtual void
227  detonationMapAdd( const DtDetonationSoundMapRecord& record );
228 
231  virtual void
232  detonationMapRemove( const DtDetonationSoundMapRecord& record );
233 
237  virtual void setFilename( const std::string& mtlFile );
238 
242  virtual const std::string& filename() const;
243 
244  protected:
245 
246  friend class boost::serialization::access;
247 
252  template<class Archive>
253  void serialize( Archive& ar, const unsigned int version )
254  {
255  if ( version < 2 )
256  {
257  myAudioOn = myAudioEnabled;
258  ar & BOOST_SERIALIZATION_NVP( myVolume );
259  ar & BOOST_SERIALIZATION_NVP( mySoundRange );
260  ar & BOOST_SERIALIZATION_NVP( myAudioOn );
261  ar & BOOST_SERIALIZATION_NVP( mySoundRangeEnabled );
262  ar & BOOST_SERIALIZATION_NVP( myFilename );
263  myAudioEnabled = myAudioOn;
264  }
265  else
266  {
267  ar & BOOST_SERIALIZATION_NVP( myVolume );
268  ar & BOOST_SERIALIZATION_NVP( mySoundRange );
269  ar & BOOST_SERIALIZATION_NVP( myAudioEnabled );
270  ar & BOOST_SERIALIZATION_NVP( mySoundRangeEnabled );
271  ar & BOOST_SERIALIZATION_NVP( myEntitySounds );
272  ar & BOOST_SERIALIZATION_NVP( myWeaponFireSounds );
273  ar & BOOST_SERIALIZATION_NVP( myDetonationSounds );
274  }
275  }
276 
282  template<typename MapType>
283  typename MapType::iterator
284  mapFind( DtEntitySoundMapRecord& record, MapType& sndMap ) const
285  {
286  typename MapType::iterator iter( sndMap.begin() );
287  typename MapType::iterator endr( sndMap.end() );
288  for( ; iter != endr; ++iter )
289  {
290  if ( ( *iter ) == record )
291  {
292  return iter;
293  }
294  }
295  return endr;
296  }
297 
303  template<typename MapType>
304  typename MapType::const_iterator
305  mapFind( const DtEntitySoundMapRecord& record, MapType& sndMap ) const
306  {
307  typename MapType::const_iterator iter( sndMap.begin() );
308  typename MapType::const_iterator endr( sndMap.end() );
309  for( ; iter != endr; ++iter )
310  {
311  if ( ( *iter ) == record )
312  {
313  return iter;
314  }
315  }
316  return endr;
317  }
318 
324  template<typename RecType, typename MapType>
325  const RecType& at( unsigned int index, MapType& sndMap ) const
326  {
327  return sndMap.at( index );
328  }
329 
334  template<typename RecType, typename MapType>
335  unsigned int index( const RecType& record, MapType& sndMap ) const
336  {
337  return static_cast<unsigned int>
338  ( std::distance( sndMap.begin(), mapFind( record, sndMap ) ) );
339  }
340 
343  template<typename MapType>
344  void clearMap( MapType& sndMap )
345  {
346  sndMap.clear();
347  }
348 
349 
350  protected:
351  int myVolume;
352  double mySoundRange;
358 
359  std::string myFilename;
360  bool myAudioOn;
361  };
362 
363 }
364 

Document ID: Generated on Mon Apr 8 19:24:01 EDT 2013 from SVN revision 125877
Copyright © 2005-2013 VT MÄK. All Rights Reserved (www.mak.com)