Skip to content

Commit

Permalink
Move xr_hash_map into separate file
Browse files Browse the repository at this point in the history
  • Loading branch information
Xottab-DUTY committed Jan 6, 2018
1 parent 838eb61 commit 82b415c
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 14 deletions.
1 change: 1 addition & 0 deletions src/Common/Common.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@
<ClInclude Include="..\xrCommon\xr_set.h" />
<ClInclude Include="..\xrCommon\xr_stack.h" />
<ClInclude Include="..\xrCommon\xr_string.h" />
<ClInclude Include="..\xrCommon\xr_unordered_map.h" />
<ClInclude Include="..\xrCommon\xr_vector.h" />
<ClInclude Include="Common.hpp" />
<ClInclude Include="Compiler.inl" />
Expand Down
3 changes: 3 additions & 0 deletions src/Common/Common.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@
<Filter>xrCommon</Filter>
</ClInclude>
<ClInclude Include="Common.hpp" />
<ClInclude Include="..\xrCommon\xr_unordered_map.h">
<Filter>xrCommon</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Filter Include="NvMender2003">
Expand Down
14 changes: 14 additions & 0 deletions src/xrCommon/xr_unordered_map.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#pragma once
// XXX: upgrade std hash structures
#ifndef _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS
#define _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS
#endif
#include <hash_map>
#include <unordered_map>
#include "xrCore/Memory/XRayAllocator.hpp"

template <typename K, class V, class _Traits = stdext::hash_compare<K, std::less<K>>, typename allocator = XRay::xray_allocator<std::pair<K, V>>>
using xr_hash_map = stdext::hash_map<K, V, _Traits, allocator>;

template<class Key, class T, class Hasher = std::hash<Key>, class KeyEqual = std::equal_to<Key>, class allocator = XRay::xray_allocator<std::pair<const Key, T>>>
using xr_unordered_map = std::unordered_map<Key, T, Hasher, KeyEqual, allocator>;
13 changes: 1 addition & 12 deletions src/xrCore/_stl_extensions.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,13 @@
#include "xrstring.h"
#include "xrCommon/inlining_macros.h"
#include "xrCommon/xr_string.h"
#include "xrCommon/xr_unordered_map.h"
#include "xrDebug_macros.h" // only for pragma todo. Remove once handled.

#pragma todo("tamlin: This header includes pretty much every std collection there are. Compiler-hog! FIX!")

using std::swap;

#ifndef _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS
#define _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS
#endif
#include <hash_map>
template <typename K, class V, class _Traits = stdext::hash_compare<K, std::less<K>>,
typename allocator = XRay::xray_allocator<std::pair<K, V>>>
class xr_hash_map : public stdext::hash_map<K, V, _Traits, allocator>
{
public:
u32 size() const { return (u32) __super ::size(); }
};

#include "xrCommon/predicates.h"

// tamlin: TODO (low priority, for a rainy day): Rename these macros from DEFINE_* to DECLARE_*
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/xrServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include "secure_messaging.h"
#include "xrServer_updates_compressor.h"
#include "xrClientsPool.h"
#include "xrCore/_stl_extensions.h" // xr_hash_map
#include "xrCommon/xr_unordered_map.h"

#ifdef DEBUG
//. #define SLOW_VERIFY_ENTITIES
Expand Down
2 changes: 1 addition & 1 deletion src/xrScriptEngine/script_engine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include "xrScriptEngine/script_space_forward.hpp"
#include "xrScriptEngine/Functor.hpp"
#include "xrCore/Threading/Lock.hpp"
#include "xrCore/_stl_extensions.h" // xr_hash_map
#include "xrCommon/xr_unordered_map.h"

struct lua_State;

Expand Down

0 comments on commit 82b415c

Please sign in to comment.