00001 /* 00002 * @(#)Serializable.h 3.00 7 Jun 1999 00003 * 00004 * Copyright (c) 2000 Pete Goodliffe (pete@cthree.org) 00005 * 00006 * This file is part of TSE3 - the Trax Sequencer Engine version 3.00. 00007 * 00008 * This library is modifiable/redistributable under the terms of the GNU 00009 * General Public License. 00010 * 00011 * You should have received a copy of the GNU General Public License along 00012 * with this program; see the file COPYING. If not, write to the Free Software 00013 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00014 * 00015 */ 00016 00017 #ifndef TSE3_SERIALIZABLE_H 00018 #define TSE3_SERIALIZABLE_H 00019 00020 #include <iosfwd> 00021 #include <iomanip> 00022 #include <cstddef> 00023 00024 namespace TSE3 00025 { 00026 class Song; 00027 class Progress; 00028 00036 struct SerializableLoadInfo 00037 { 00044 int PPQN; 00045 00051 Song *song; 00052 00060 int major; 00061 00069 int minor; 00070 00080 bool unknownChunks; 00081 00091 bool unknownData; 00092 00101 size_t noChunks; 00102 00110 Progress *progress; 00111 00124 SerializableLoadInfo(); 00125 }; 00126 00170 class Serializable 00171 { 00172 public: 00173 00174 Serializable() {} 00175 00176 virtual ~Serializable() {} 00177 00200 virtual void save(std::ostream &out, int indentLevel) const; 00201 00224 virtual void load(std::istream &in, SerializableLoadInfo &info); 00225 00226 protected: 00227 00228 class indent 00229 { 00230 public: 00231 indent(int lvl) : level(lvl) {} 00232 int level; 00233 }; 00234 00235 friend std::ostream &operator<<(std::ostream &, const indent &); 00236 00237 private: 00238 00239 Serializable &operator=(const Serializable &); 00240 Serializable(const Serializable &); 00241 }; 00242 00253 inline std::ostream &operator<<(std::ostream &s, 00254 const Serializable::indent &i) 00255 { 00256 for (int n = 0; n < i.level; ++n) s << " "; 00257 return s; 00258 } 00259 } 00260 00261 #endif