ChangePropertyDelta.h

Go to the documentation of this file.
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 CHANGE_PROPERTY_DELTA_H_
00013 #define CHANGE_PROPERTY_DELTA_H_
00014 
00015 #include "DocumentDelta.h"
00016 
00017 namespace Document
00018 {
00019 
00025 template<class Data>
00026 class PropertyDeltaIdentifier
00027 {
00028 public:
00029     virtual ~PropertyDeltaIdentifier()
00030     {
00031     }
00036     virtual void read(const Track::Track & track, Data & data) = 0;
00041     virtual void write(Track::Track & track, const Data & data) = 0;
00042 };
00043 
00049 template <class Identifier, class Data>
00050 class ChangePropertyDelta
00051     :   public DocumentDelta
00052 {
00053 public:
00060     ChangePropertyDelta(Identifier identifier, Data data)
00061         :   identifier(identifier)
00062         ,   new_data(data)
00063     {
00064     }
00065     virtual void apply(Track::Track & track)
00066     {
00067         identifier.read(track, old_data);
00068         identifier.write(track, new_data);
00069     }
00070     virtual void unapply(Track::Track & track)
00071     {
00072         identifier.write(track, old_data);
00073     }
00074 protected:
00075     Identifier identifier;
00076     Data new_data;
00077     Data old_data;
00078 };
00079 
00080 }
00081 
00082 #endif

Get Racer at SourceForge.net. Fast, secure and Free Open Source software downloads

Generated at Mon Sep 6 00:41:11 2010 by Doxygen version 1.4.7 for Racer version svn335.