Index: src/libchcore/TModificationTracker.h =================================================================== diff -u -N -r4fe995b304ea342b50293f92d3c1992b43b820f7 -ra4635addad389b9e117679437a3e1b64a739ea96 --- src/libchcore/TModificationTracker.h (.../TModificationTracker.h) (revision 4fe995b304ea342b50293f92d3c1992b43b820f7) +++ src/libchcore/TModificationTracker.h (.../TModificationTracker.h) (revision a4635addad389b9e117679437a3e1b64a739ea96) @@ -1,111 +1,111 @@ -// ============================================================================ -// Copyright (C) 2001-2014 by Jozef Starosczyk -// ixen@copyhandler.com -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU Library General Public License -// (version 2) as published by the Free Software Foundation; -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this program; if not, write to the -// Free Software Foundation, Inc., -// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// ============================================================================ -#ifndef __TMODIFICATIONTRACKER_H__ -#define __TMODIFICATIONTRACKER_H__ - -namespace chcore -{ - template - class TModificationTracker - { - public: - TModificationTracker() : - m_tValue(), - m_chModified(eMod_Modified) - { - } - - template - TModificationTracker(const V& rValue, bool bAdded) : - m_tValue(rValue), - m_chModified((char)eMod_Modified | (bAdded ? (char)eMod_Added : (char)eMod_None)) - { - } - - TModificationTracker(const TModificationTracker& rSrc) : - m_chModified(rSrc.m_chModified), - m_tValue(rSrc.m_tValue) - { - } - - TModificationTracker& operator=(const TModificationTracker& rSrc) - { - m_chModified = rSrc.m_chModified; - m_tValue = rSrc.m_tValue; - - return *this; - } - - template - TModificationTracker& operator=(const V& rValue) - { - if (m_tValue != rValue) - { - m_tValue = rValue; - m_chModified |= eMod_Modified; - } - - return *this; - } - - operator const T&() const - { - return m_tValue; - } - - const T& Get() const - { - return m_tValue; - } - - T& Modify() - { - m_chModified |= eMod_Modified; - return m_tValue; - } - - void ClearModifications() const - { - m_chModified = eMod_None; - } - - bool IsModified() const - { - return m_chModified != 0; // must also include 'Added' status! - } - - bool IsAdded() const - { - return (m_chModified & eMod_Added) != 0; - } - - private: - enum EModifiedFlags - { - eMod_None = 0, - eMod_Added = 1, - eMod_Modified = 2 - }; - - T m_tValue; - mutable char m_chModified; - }; -} - -#endif +// ============================================================================ +// Copyright (C) 2001-2014 by Jozef Starosczyk +// ixen@copyhandler.com +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Library General Public License +// (version 2) as published by the Free Software Foundation; +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// ============================================================================ +#ifndef __TMODIFICATIONTRACKER_H__ +#define __TMODIFICATIONTRACKER_H__ + +namespace chcore +{ + template + class TModificationTracker + { + public: + TModificationTracker() : + m_tValue(), + m_chModified(eMod_Modified) + { + } + + template + TModificationTracker(const V& rValue, bool bAdded) : + m_tValue(rValue), + m_chModified((char)eMod_Modified | (bAdded ? (char)eMod_Added : (char)eMod_None)) + { + } + + TModificationTracker(const TModificationTracker& rSrc) : + m_chModified(rSrc.m_chModified), + m_tValue(rSrc.m_tValue) + { + } + + TModificationTracker& operator=(const TModificationTracker& rSrc) + { + m_chModified = rSrc.m_chModified; + m_tValue = rSrc.m_tValue; + + return *this; + } + + template + TModificationTracker& operator=(const V& rValue) + { + if (m_tValue != rValue) + { + m_tValue = rValue; + m_chModified |= eMod_Modified; + } + + return *this; + } + + operator const T&() const + { + return m_tValue; + } + + const T& Get() const + { + return m_tValue; + } + + T& Modify() + { + m_chModified |= eMod_Modified; + return m_tValue; + } + + void ClearModifications() const + { + m_chModified = eMod_None; + } + + bool IsModified() const + { + return m_chModified != 0; // must also include 'Added' status! + } + + bool IsAdded() const + { + return (m_chModified & eMod_Added) != 0; + } + + private: + enum EModifiedFlags + { + eMod_None = 0, + eMod_Added = 1, + eMod_Modified = 2 + }; + + T m_tValue; + mutable char m_chModified; + }; +} + +#endif