Index: src/libchcore/TModificationTracker.h =================================================================== diff -u -N -rb7655a8f0721e5454befd29e3e067748eb0521e9 -r73583f2ca01fa1b2eae49bbc63bce46b9ecff5db --- src/libchcore/TModificationTracker.h (.../TModificationTracker.h) (revision b7655a8f0721e5454befd29e3e067748eb0521e9) +++ src/libchcore/TModificationTracker.h (.../TModificationTracker.h) (revision 73583f2ca01fa1b2eae49bbc63bce46b9ecff5db) @@ -29,66 +29,36 @@ public: TModificationTracker() : m_tValue(), - m_bModified(false) + m_chModified(eMod_None) { } - template - TModificationTracker(const V& rValue) : - m_tValue(rValue), - m_bModified(true) + TModificationTracker(const TModificationTracker& rSrc) : + m_chModified(rSrc.m_chModified), + m_tValue(rSrc.m_tValue) { } template - TModificationTracker& operator=(const V& rValue) + TModificationTracker(const V& rValue, bool bAdded) : + m_tValue(rValue), + m_chModified((char)eMod_Modified | (bAdded ? (char)eMod_Added : (char)eMod_None)) { - m_tValue = rValue; - m_bModified = true; } - operator const T&() const + TModificationTracker& operator=(const TModificationTracker& rSrc) { - return m_tValue; - } + m_chModified = rSrc.m_chModified; + m_tValue = rSrc.m_tValue; - operator T&() const - { - m_bModified = true; - return m_tValue; + return *this; } - bool IsModified() const - { - return m_bModified; - } - -private: - T m_tValue; - bool m_bModified; -}; - -template -class TSharedModificationTracker -{ -private: - TSharedModificationTracker& operator=(const TSharedModificationTracker& rValue); - -public: - TSharedModificationTracker(bool& rbSharedFlag) : m_tValue(), m_rbModified(rbSharedFlag) - { - } - template - TSharedModificationTracker(const V& rValue, bool& rbSharedFlag) : m_tValue(rValue), m_rbModified(rbSharedFlag) + TModificationTracker& operator=(const V& rValue) { - } - - template - TSharedModificationTracker& operator=(const V& rValue) - { m_tValue = rValue; - m_rbModified = true; + m_chModified |= eMod_Modified; return *this; } @@ -98,9 +68,9 @@ return m_tValue; } - operator T&() + T& Value() { - m_rbModified = true; + m_chModified |= eMod_Modified; return m_tValue; } @@ -109,20 +79,31 @@ return &m_tValue; } - T* operator->() + void ClearModifications() { - m_rbModified = true; - return &m_tValue; + m_chModified = eMod_None; } bool IsModified() const { - return m_rbModified; + return (m_chModified & eMod_Modified) != 0; } + bool IsAdded() const + { + return (m_chModified & eMod_Added) != 0; + } + private: + enum EModifiedFlags + { + eMod_None = 0, + eMod_Added = 1, + eMod_Modified = 2 + }; + T m_tValue; - bool& m_rbModified; + char m_chModified; }; END_CHCORE_NAMESPACE