00001 00005 /* Copyright © 2009 James Legg. 00006 This program is free software: you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation, either version 3 of the License, or 00009 (at your option) any later version. 00010 */ 00011 00012 #ifndef LIBTRACK_DOCUMENT_REMOVE_DELTA_H 00013 #define LIBTRACK_DOCUMENT_REMOVE_DELTA_H 00014 00015 #include <boost/shared_ptr.hpp> 00016 00017 #include "DocumentDelta.h" 00018 00019 namespace Document 00020 { 00021 00031 template <class InsertRemoveIdentifer, class Object> 00032 class RemoveDelta 00033 : public DocumentDelta 00034 { 00035 public: 00038 RemoveDelta(InsertRemoveIdentifer identifier) 00039 : identifier(identifier) 00040 { 00041 } 00042 00043 virtual ~RemoveDelta() 00044 { 00045 } 00046 00048 virtual void apply(Track::Track & track) 00049 { 00050 // remove, but copy the object to restore it if wanted later. 00051 object = boost::shared_ptr<Object>(new Object(identifier.remove(track))); 00052 } 00053 00055 virtual void unapply(Track::Track & track) 00056 { 00057 identifier.insert(track, *object); 00058 } 00059 protected: 00060 boost::shared_ptr<Object> object; 00061 InsertRemoveIdentifer identifier; 00062 }; 00063 00064 } 00065 00066 #endif // LIBTRACK_DOCUMENT_REMOVE_DELTA_H
Generated at Mon Sep 6 00:41:11 2010 by Doxygen version 1.4.7 for Racer version svn335.