Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
unit_const_cache.cpp
Go to the documentation of this file.
1 #include <string>
2 #include <vector>
3 #include <gnuhash.h>
4 
5 #include "unit_generic.h"
6 #include "unit_const_cache.h"
7 #if (!defined (__GNUC__ ) ) || !(defined (__GNUC__) && ( ( __GNUC__ == 3 && __GNUC_MINOR__ >= 4) || __GNUC__ > 3 ) )
8 #if !defined (_WIN32) && __GNUC__ != 2
9 vsUMap< StringIntKey, Unit*, ConstHasher >UnitConstCache::unit_cache;
10 vsUMap< std::string, Mesh*, ConstHasher >WeaponMeshCache::unit_cache;
11 #else
12 vsUMap< StringIntKey, Unit* >UnitConstCache::unit_cache;
13 vsUMap< std::string, Mesh* >WeaponMeshCache::unit_cache;
14 #endif
15 #endif
16 
17 #if 0
18 typedef vsUMap< keyval, Unit* >UnitCacheType;
19 static UnitCacheType unit_cache;
20 const Unit * getCachedConstUnit( std::string name, int faction )
21 {
22  keyval kv( name, faction );
23  UnitCacheType::const_iterator i = unit_cache.find( kv );
24  if ( i != unit_cache.end() )
25  return (*i).second;
26  return NULL;
27 }
28 const Unit * setCachedConstUnit( std::string name, int faction, Unit *un )
29 {
30  unit_cache.insert( pair< keyval, Unit* > ( keyval( name, faction ), un ) );
31  return un;
32 }
33 void purgeCache()
34 {
35  UnitCacheType::iterator i = unit_cache.begin();
36  for (; i != unit_cache.end(); ++i)
37  (*i).second->Kill();
38  unit_cache.clear();
39 }
40 #endif
41