Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
/*
   Copyright (c) 2014 DIVIDE-Studio
   Copyright (c) 2009 Ionut Cava

   This file is part of DIVIDE Framework.

   Permission is hereby granted, free of charge, to any person obtaining a copy of this software
   and associated documentation files (the "Software"), to deal in the Software without restriction,
   including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
   and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
   subject to the following conditions:

   The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
   INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
   IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
   OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

 */

#ifndef _HASH_MAP_H_
#define _HASH_MAP_H_

#include "String.h"

#if defined(HASH_MAP_IMP) && HASH_MAP_IMP == 0
    #include <boost/Unordered_Map.hpp>
    
    namespace hashAlg = boost;

    template<typename K, typename V, typename HashFun = boost::hash<K> >
    using hashMapImpl = boost::unordered_map<K, V, HashFun>;

    namespace boost {

#   if defined(STRING_IMP) && STRING_IMP == 0
        template<>
        struct hash<stringImpl>
        {
            size_t operator()(const stringImpl& v) const {
                return std::hash<std::string>()(v.c_str());
            }
        };
#   endif

        template<typename K, typename V, typename HashFun = boost::hash<K> >
        using hashPairReturn = std::pair<typename hashMapImpl<K, V, HashFun>::iterator, bool>;

		template<typename T1, typename T2>
		using pair = std::pair<T1, T2>;

        template<typename K, typename V, typename HashFun = hashAlg::hash<K> >
        inline hashPairReturn<K, V, HashFun> emplace(hashMapImpl<K, V, HashFun>& map, 
                                                     K key, 
                                                     const V& val) {
            return map.emplace(key, val);
        }

        template<typename K, typename V, typename HashFun = hashAlg::hash<K> >
        inline hashPairReturn<K, V, HashFun> insert(hashMapImpl<K, V, HashFun>& map,
                                                    const typename hashMapImpl<K, V, HashFun>::value_type& valuePair) {
            return map.insert(valuePair);
        }

        template<typename K, typename V, typename HashFun = hashAlg::hash<K> >
        inline void fastClear(hashMapImpl<K, V,HashFun>& map){
            map.clear();
        }

#	ifndef BOOST_PAIR_FUNCS
#	define BOOST_PAIR_FUNCS
			template<typename K, typename V>
			inline std::pair<K, V> makePair(const K& key, const V& val) {
				return std::make_pair(key, val);
			}

			template<typename K, typename V>
			inline std::pair<K, V> makePairCpy(const K& key, V val) {
				return std::make_pair(key, val);
			}
#	endif
    };

#elif defined(HASH_MAP_IMP) && HASH_MAP_IMP == 1

    #include <EASTL/hash_map.h>

    namespace hashAlg = eastl;

    template<typename K, typename V, typename HashFun = eastl::hash<K> >
    using hashMapImpl = eastl::hash_map<K, V, HashFun>;

    namespace eastl {

        template<>
        struct hash<std::string>
        {
            size_t operator()(const std::string & x) const
            {
                return std::hash<std::string>()(x);
            }
        };

        template<typename K, typename V, typename HashFun = eastl::hash<K> >
        using hashPairReturn = eastl::pair<typename hashMapImpl<K, V, HashFun>::iterator, bool>;

        template<typename K, typename V, typename HashFun = eastl::hash<K> >
        inline hashPairReturn<K, V, HashFun> emplace(hashMapImpl<K, V, HashFun>& map,
                                                     K key, 
                                                     const V& val) {
            hashMapImpl<K, V, HashFun>::value_type value(key);
            value.second = val;
            return map.insert(value); 
        }
    
        template<typename K, typename V, typename HashFun = hashAlg::hash<K> >
        inline hashPairReturn<K, V, HashFun> insert(hashMapImpl<K, V, HashFun>& map,
                                                    const typename hashMapImpl<K, V, HashFun>::value_type& valuePair) {
            return map.insert(valuePair);
        }
    
        template<typename K, typename V, typename HashFun = hashAlg::hash<K> >
        inline void fastClear(hashMapImpl<K, V, HashFun>& map) {
            //map.reset(); // leaks memory -Ionut
			map.clear();
        }

#	ifndef EASTL_PAIR_FUNCS
#	define EASTL_PAIR_FUNCS
			template<typename K, typename V>
			inline eastl::pair<K, V> makePair(const K& key, const V& val) {
				return eastl::make_pair_ref(key, val);
			}
   
			template<typename K, typename V>
			inline eastl::pair<K, V> makePairCpy(const K& key, V val) {
				return eastl::make_pair_ref(key, val);
			}
#	endif
    };

#else //defined(HASH_MAP_IMP) && HASH_MAP_IMP == 2
    #include <unordered_map>

    namespace hashAlg = std;

    template<typename K, typename V, typename HashFun = std::hash<K> >
    using hashMapImpl = std::unordered_map<K, V, HashFun>;

    namespace std {

        template<>
        struct hash<eastl::string>
        {
            size_t operator()(const eastl::string & x) const
            {
                return std::hash<std::string>()(x.c_str());
            }
        };

        template<typename K, typename V, typename HashFun = std::hash<K> >
        using hashPairReturn = std::pair<typename hashMapImpl<K, V, HashFun>::iterator, bool>;

        template<typename K, typename V, typename HashFun = hashAlg::hash<K> >
        inline hashPairReturn<K, V, HashFun> emplace(hashMapImpl<K, V, HashFun>& map,
                                                    K key, 
                                                    const V& val) {
            return map.emplace(key, val);
        }

        template<typename K, typename V, typename HashFun = hashAlg::hash<K> >
        inline hashPairReturn<K, V, HashFun> insert(hashMapImpl<K, V, HashFun>& map, 
                                                    const typename hashMapImpl<K, V, HashFun>::value_type& valuePair) {
            return map.insert(valuePair);
        }

        template<typename K, typename V, typename HashFun = hashAlg::hash<K> >
        inline void fastClear(hashMapImpl<K, V, HashFun>& map){
            map.clear();
        }

#	ifndef STD_PAIR_FUNCS
#	define STD_PAIR_FUNCS
			template<typename K, typename V>
			inline std::pair<K, V> makePair(const K& key, const V& val) {
				return std::make_pair(key, val);
			}

			template<typename K, typename V>
			inline std::pair<K, V> makePairCpy(const K& key, V val) {
				return std::make_pair(key, val);
			}
#	endif
    };

#endif //defined(HASH_MAP_IMP)
	
#endif

Commits for Divide-Framework/trunk/Source Code/Utility/Headers/HashMap.h

Diff revisions: vs.
Revision Author Commited Message
331 Diff Diff IonutCava picture IonutCava Sat 06 Dec, 2014 20:53:45 +0000

[Ionut]
- Limited line length to 132 characters to improve readability and diff-comparisons
- Refactored memory allocation/deallocation functions
- Fixed a few compatibility issues with HashMap.h
- Fixed a bug in GPU Skinning shaders (cast a float to int)

326 Diff Diff IonutCava picture IonutCava Tue 30 Sep, 2014 21:11:32 +0000

[Ionut]
- Fixed more memory leaks
- Simplified Task interface and timing System
- Improved compatibility between Boost, STL and EASTL with random combinations of vectors, strings and maps
- Simplified Light class by removing the “slot” member
- Random optimizations

323 Diff Diff IonutCava picture IonutCava Thu 11 Sep, 2014 20:58:50 +0000

[Ionut]
- Reworked GFXDevice API initialization system
- Added a separate map for boolean values in ParamHandler
- More cleanups in GFXDevice class
- Fixed an infinite loop issue in Task class

322 Diff Diff IonutCava picture IonutCava Sat 06 Sep, 2014 20:33:47 +0000

[Ionut]
- Refactored most of Boost related code to be C++11 based
— Boost is only used for ThreadPool, Mutex handling, XML parsing and networking (ASIO)
— Function binds, threads, regex, NonCopyable base, Hashing algorithms and more are now using C++11 libraries
- Replaced all FOR_EACH calls with standard, range, “for” calls

321 Diff Diff IonutCava picture IonutCava Wed 03 Sep, 2014 22:05:15 +0000

[Ionut]
- Added support (and enabled by default) for the EASTL library (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2271.html / https://github.com/paulhodge/EASTL)
— Strings, vectors and hash_maps can be combined from EASTL, STL and Boost (not all combinations work. e.g. EASTL strings with STL/Boost containers due to the lack of a proper hash function)

250 Diff Diff k1ngp1n picture k1ngp1n Wed 02 Apr, 2014 12:36:36 +0000

[Ionut] [[BR]]
- More C++11 work [[BR]]
- Renamed “for_each” macro to “FOR_EACH” to avoid name conflicts with the C++11 function [[BR]]

221 Diff Diff k1ngp1n picture k1ngp1n Wed 08 Jan, 2014 18:50:02 +0000

[Ionut] [[BR]]
- Merged branch “Shadows And Animations” back into trunk [[BR]]
- Added DoxygenGUI project file [[BR]]

  • Buggy *
170 Diff Diff k1ngp1n picture k1ngp1n Sun 03 Nov, 2013 17:24:57 +0000

-Moved hardware related code to a separate project [[BR]]
-More work on post-processing: [[BR]]
— HDR rendering is working, but final tonemapping needs more work [[BR]]
-Important changes in BloomPreRenderOperator.cpp, PostFX.cpp and glFrameBufferObject.cpp [[BR]]
-Trailing and leading whitespace cleanups [[BR]]

168 Diff Diff k1ngp1n picture k1ngp1n Sat 26 Oct, 2013 19:03:21 +0000

- Reworked the Camera class[[BR]]
— Now fully quaternion based [[BR]]
— Basic camera types added but not used yet (third person, first person, orbit) [[BR]]
- Cleaned up Material and Texture handling [[BR]]
- Added clipping plane support [[BR]]
— Similar to OpenGL fixed-function clip planes but fully shader driven [[BR]]
— Added a new class, “Plane”, that helps define clip planes [[BR]]
- Optimized the Singleton class to allow faster “getInstance” calls without performance penalties [[BR]]
-- “createInstance” must be called for each singleton class before usage. Or “gerOrCreateInstance” can be used, which is basically the former “getInstance” implementation [[BR]]
- Improved console logging by changing some heap allocations to stack and removing dependencies on the std::string class [[BR]]
- Added a lot of performance optimizations related to coding standards and redundant calculations [[BR]]
— e.g. Frustum AABB check didn’t need to recompute the AABB points as they were calculated already [[BR]]
— e.g. A vector did not need to be set to 0 on initialization as that is already it’s default state on creation [[BR]]
— e.g. Faster Framerate and Timing calculations by using less member variables that are not needed outsied of calling functions [[BR]]
- The SceneState now contains the SceneRenderState and is passed on to the SceneGraph’s update calls [[BR]]
- Better material export/import to/from XML format [[BR]]
- More bug fixes and cleanups [[BR]]

160 k1ngp1n picture k1ngp1n Wed 10 Jul, 2013 17:07:04 +0000

[Ionut] [[BR]]
- Changed licensing from LGPL to the MIT license [[BR]]
— Code can now be used in non-commercial or commercial closed or open source projects [[BR]]