diff options
Diffstat (limited to 'Swiften/Avatars/AvatarMemoryStorage.h')
-rw-r--r-- | Swiften/Avatars/AvatarMemoryStorage.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/Swiften/Avatars/AvatarMemoryStorage.h b/Swiften/Avatars/AvatarMemoryStorage.h new file mode 100644 index 0000000..f60f603 --- /dev/null +++ b/Swiften/Avatars/AvatarMemoryStorage.h @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2010 Remko Tronçon + * Licensed under the GNU General Public License v3. + * See Documentation/Licenses/GPLv3.txt for more information. + */ + +#pragma once + +#include <map> + +#include "Swiften/Base/String.h" +#include "Swiften/Base/ByteArray.h" +#include "Swiften/Avatars/AvatarStorage.h" + +namespace Swift { + class AvatarMemoryStorage : public AvatarStorage { + public: + virtual bool hasAvatar(const String& hash) const { return avatars.find(hash) != avatars.end(); } + virtual void addAvatar(const String& hash, const ByteArray& avatar) { avatars[hash] = avatar; } + virtual ByteArray getAvatar(const String& hash) const { + std::map<String, ByteArray>::const_iterator i = avatars.find(hash); + return i == avatars.end() ? ByteArray() : i->second; + } + + virtual boost::filesystem::path getAvatarPath(const String& hash) const { + return boost::filesystem::path(); + } + + private: + std::map<String, ByteArray> avatars; + }; +} |