mirror of
https://github.com/love2d/love.git
synced 2026-08-21 05:00:08 +02:00
Add Memoizer class
--HG-- branch : box2d-update
This commit is contained in:
@@ -216,6 +216,7 @@
|
||||
A9D1D20D14229B6500A8BC2F /* wrap_ChainShape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A9D1D20C14229B5800A8BC2F /* wrap_ChainShape.cpp */; };
|
||||
A9D307EA106635C3004FEDF8 /* physfs.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A9D307E9106635C3004FEDF8 /* physfs.framework */; };
|
||||
A9D307F2106635D3004FEDF8 /* physfs.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = A9D307E9106635C3004FEDF8 /* physfs.framework */; };
|
||||
A9D5C47D142E32EE0044ECF7 /* Memoizer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A9D5C47C142E32ED0044ECF7 /* Memoizer.cpp */; };
|
||||
A9DEC1C11046EFA70049C70C /* Love.icns in Resources */ = {isa = PBXBuildFile; fileRef = A9DEC1BF1046EFA60049C70C /* Love.icns */; };
|
||||
A9DEC1C21046EFA70049C70C /* LoveDocument.icns in Resources */ = {isa = PBXBuildFile; fileRef = A9DEC1C01046EFA70049C70C /* LoveDocument.icns */; };
|
||||
A9F16927109E7BAD00FC83D1 /* libmodplug.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A9F16926109E7BAD00FC83D1 /* libmodplug.framework */; };
|
||||
@@ -685,6 +686,8 @@
|
||||
A9D1D20C14229B5800A8BC2F /* wrap_ChainShape.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = wrap_ChainShape.cpp; sourceTree = "<group>"; };
|
||||
A9D1D20E14229B7300A8BC2F /* wrap_ChainShape.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = wrap_ChainShape.h; sourceTree = "<group>"; };
|
||||
A9D307E9106635C3004FEDF8 /* physfs.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = physfs.framework; path = /Library/Frameworks/physfs.framework; sourceTree = "<absolute>"; };
|
||||
A9D5C47B142E31350044ECF7 /* Memoizer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Memoizer.h; sourceTree = "<group>"; };
|
||||
A9D5C47C142E32ED0044ECF7 /* Memoizer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Memoizer.cpp; sourceTree = "<group>"; };
|
||||
A9DEC1BF1046EFA60049C70C /* Love.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; name = Love.icns; path = icons/Love.icns; sourceTree = "<group>"; };
|
||||
A9DEC1C01046EFA70049C70C /* LoveDocument.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; name = LoveDocument.icns; path = icons/LoveDocument.icns; sourceTree = "<group>"; };
|
||||
A9F16926109E7BAD00FC83D1 /* libmodplug.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = libmodplug.framework; path = /Library/Frameworks/libmodplug.framework; sourceTree = "<absolute>"; };
|
||||
@@ -810,6 +813,8 @@
|
||||
A93E69E210420ABF007D418B /* math.h */,
|
||||
A93E69E310420ABF007D418B /* Matrix.cpp */,
|
||||
A93E69E410420ABF007D418B /* Matrix.h */,
|
||||
A9D5C47C142E32ED0044ECF7 /* Memoizer.cpp */,
|
||||
A9D5C47B142E31350044ECF7 /* Memoizer.h */,
|
||||
A93E69E510420ABF007D418B /* MemoryData.cpp */,
|
||||
A93E69E610420ABF007D418B /* MemoryData.h */,
|
||||
A93E69E710420ABF007D418B /* Module.h */,
|
||||
@@ -1819,6 +1824,7 @@
|
||||
A9D1D20D14229B6500A8BC2F /* wrap_ChainShape.cpp in Sources */,
|
||||
A958F911142D364C007F320F /* wrap_Fixture.cpp in Sources */,
|
||||
A958F917142D6B3A007F320F /* Body.cpp in Sources */,
|
||||
A9D5C47D142E32EE0044ECF7 /* Memoizer.cpp in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2011 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
**/
|
||||
#include "Memoizer.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
|
||||
std::map<void *, void *> Memoizer::objectMap;
|
||||
|
||||
void Memoizer::add(void * key, void * val)
|
||||
{
|
||||
objectMap[key] = val;
|
||||
}
|
||||
|
||||
void Memoizer::remove(void * key)
|
||||
{
|
||||
objectMap.erase(key);
|
||||
}
|
||||
|
||||
void * Memoizer::find(void * key)
|
||||
{
|
||||
if (objectMap.count(key)) return objectMap[key];
|
||||
return NULL;
|
||||
}
|
||||
|
||||
} // love
|
||||
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2011 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
**/
|
||||
|
||||
#ifndef LOVE_MEMOIZER_H
|
||||
#define LOVE_MEMOIZER_H
|
||||
|
||||
#include <map>
|
||||
|
||||
namespace love
|
||||
{
|
||||
class Memoizer
|
||||
{
|
||||
private:
|
||||
|
||||
static std::map<void *, void *> objectMap;
|
||||
|
||||
public:
|
||||
|
||||
static void add(void * key, void * val);
|
||||
|
||||
static void remove(void * key);
|
||||
|
||||
static void * find(void * key);
|
||||
|
||||
}; // Memoizer
|
||||
|
||||
} // love
|
||||
|
||||
#endif // LOVE_MEMOIZER_H
|
||||
Reference in New Issue
Block a user