diff options
author | vng <viktor.govako@gmail.com> | 2011-09-22 22:37:45 +0400 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 01:24:17 +0300 |
commit | fa6b163e8fab79ab8fc3196f073b267f29ecc635 (patch) | |
tree | fce9b24cdb38f1e3419024fca700967ce7a34d2c /indexer/mwm_set.hpp | |
parent | b0382314df1901f265a8c0667589abd298a51aea (diff) |
Add MwmValue for storing in MwmSet cache => read feature::DataHeader once.
Diffstat (limited to 'indexer/mwm_set.hpp')
-rw-r--r-- | indexer/mwm_set.hpp | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/indexer/mwm_set.hpp b/indexer/mwm_set.hpp index 468149dfb2..291861b9ac 100644 --- a/indexer/mwm_set.hpp +++ b/indexer/mwm_set.hpp @@ -1,12 +1,14 @@ +#pragma once #include "../geometry/rect2d.hpp" + #include "../base/mutex.hpp" + #include "../std/deque.hpp" #include "../std/function.hpp" #include "../std/string.hpp" #include "../std/utility.hpp" #include "../std/vector.hpp" -class FilesContainerR; // Information about stored mwm. struct MwmInfo @@ -25,16 +27,22 @@ private: uint8_t m_status; // }; +class MwmValue; + class MwmSet { -public: +protected: + virtual void GetInfo(string const & name, MwmInfo & info) const = 0; + virtual MwmValue * CreateValue(string const & name) const = 0; + virtual void DestroyValue(MwmValue * p) const = 0; + void Cleanup(); + +public: typedef size_t MwmId; - explicit MwmSet(function<void (string const &, MwmInfo &)> const & fnGetMwmInfo, - function<FilesContainerR * (string const &)> const & fnCreateContainer, - size_t cacheSize = 5); - ~MwmSet(); + explicit MwmSet(size_t cacheSize = 5); + virtual ~MwmSet() = 0; // Mwm lock, which is used to lock mwm when its FileContainer is used. class MwmLock @@ -43,11 +51,12 @@ public: MwmLock(MwmSet const & mwmSet, MwmId mwmId); ~MwmLock(); - FilesContainerR * GetFileContainer() const; + inline MwmValue * GetValue() const { return m_pValue; } + private: MwmSet const & m_mwmSet; MwmId m_id; - FilesContainerR * m_pFileContainer; + MwmValue * m_pValue; }; // Add new mwm. Returns false, if mwm with given fileName already exists. @@ -67,13 +76,13 @@ private: static const MwmId INVALID_MWM_ID = static_cast<MwmId>(-1); - typedef deque<pair<MwmId, FilesContainerR *> > CacheType; + typedef deque<pair<MwmId, MwmValue *> > CacheType; // Update given MwmInfo. inline static void UpdateMwmInfo(MwmInfo & info); - FilesContainerR * LockContainer(MwmId id) const; - void UnlockContainer(MwmId id, FilesContainerR * pContainer) const; + MwmValue * LockValue(MwmId id) const; + void UnlockValue(MwmId id, MwmValue * p) const; // Find first removed mwm or add a new one. MwmId GetFreeId(); @@ -88,7 +97,5 @@ private: mutable vector<string> m_name; mutable CacheType m_cache; size_t m_cacheSize; - function<void (string const &, MwmInfo &)> const m_fnGetMwmInfo; - function<FilesContainerR * (string const &)> const m_fnCreateContainer; mutable threads::Mutex m_lock; }; |