Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuri Gorshenin <y@maps.me>2015-04-27 16:55:03 +0300
committerAlex Zolotarev <alex@maps.me>2015-09-23 02:46:27 +0300
commit3cd1aabf377cbc5de2e74dc3ff196b018a8c6d34 (patch)
tree0907aedc125590ce2b204f23485136b68b7edb2c /indexer/mwm_set.hpp
parent6704c8e070ead2ab459b05c2c3b214eafc34b3a8 (diff)
[index] MwmValues are wrapped in shared_ptr's.
Diffstat (limited to 'indexer/mwm_set.hpp')
-rw-r--r--indexer/mwm_set.hpp22
1 files changed, 12 insertions, 10 deletions
diff --git a/indexer/mwm_set.hpp b/indexer/mwm_set.hpp
index 52cf1fc93f..27823ae8f9 100644
--- a/indexer/mwm_set.hpp
+++ b/indexer/mwm_set.hpp
@@ -8,6 +8,7 @@
#include "std/deque.hpp"
#include "std/mutex.hpp"
+#include "std/shared_ptr.hpp"
#include "std/string.hpp"
#include "std/utility.hpp"
#include "std/vector.hpp"
@@ -83,12 +84,13 @@ public:
MwmLock(MwmLock && lock);
virtual ~MwmLock();
+ // Returns a non-owning ptr.
template <typename T>
inline T * GetValue() const
{
- return static_cast<T *>(m_value);
+ return static_cast<T *>(m_value.get());
}
- inline bool IsLocked() const { return m_value; }
+ inline bool IsLocked() const { return m_value.get() != nullptr; }
inline MwmId GetId() const { return m_mwmId; }
MwmInfo const & GetInfo() const;
@@ -97,11 +99,11 @@ public:
private:
friend class MwmSet;
- MwmLock(MwmSet & mwmSet, MwmId mwmId, MwmValueBase * value);
+ MwmLock(MwmSet & mwmSet, MwmId mwmId, shared_ptr<MwmValueBase> value);
MwmSet * m_mwmSet;
MwmId m_mwmId;
- MwmValueBase * m_value;
+ shared_ptr<MwmValueBase> m_value;
NONCOPYABLE(MwmLock);
};
@@ -159,17 +161,17 @@ protected:
/// @return True when it's possible to get file format version - in
/// this case version is set to the file format version.
virtual bool GetVersion(string const & name, MwmInfo & info) const = 0;
- virtual MwmValueBase * CreateValue(string const & name) const = 0;
+ virtual shared_ptr<MwmValueBase> CreateValue(string const & name) const = 0;
void Cleanup();
private:
- typedef deque<pair<MwmId, MwmValueBase *> > CacheType;
+ typedef deque<pair<MwmId, shared_ptr<MwmValueBase>>> CacheType;
- MwmValueBase * LockValue(MwmId id);
- MwmValueBase * LockValueImpl(MwmId id);
- void UnlockValue(MwmId id, MwmValueBase * p);
- void UnlockValueImpl(MwmId id, MwmValueBase * p);
+ shared_ptr<MwmValueBase> LockValue(MwmId id);
+ shared_ptr<MwmValueBase> LockValueImpl(MwmId id);
+ void UnlockValue(MwmId id, shared_ptr<MwmValueBase> p);
+ void UnlockValueImpl(MwmId id, shared_ptr<MwmValueBase> p);
/// Find first removed mwm or add a new one.
/// @precondition This function is always called under mutex m_lock.