00001 #ifndef SCT_IOMANAGER_H
00002 #define SCT_IOMANAGER_H
00003
00004 #include "IoExceptions.h"
00005 #include <map>
00006 #include <boost/shared_ptr.hpp>
00007 #include <boost/utility.hpp>
00008
00009 using std::map;
00010 using boost::shared_ptr;
00011
00012 namespace Sct {
00013
00014 class Streamer;
00015 class Streamable;
00016 class Serializable;
00017 class OStream;
00018 class IStream;
00019
00024 class IOParams {
00025 public:
00026 virtual ~IOParams(){}
00027 };
00028
00043 class IOManager : private boost::noncopyable {
00044 public:
00045 virtual ~IOManager() {};
00046
00049
00056 virtual void write(const Serializable& ob, const IOParams* params = 0) const = 0;
00057
00064 virtual shared_ptr<Serializable> read(const string& name, const IOParams* params = 0) const = 0;
00066
00067
00068
00071
00079 virtual void writeImpl(OStream& out, const Streamable& ob, bool writeClassName) const ;
00080
00088 virtual shared_ptr<Streamable> readImpl(IStream& in) const;
00089
00098 virtual shared_ptr<Streamable> readImpl(IStream& in, const string& className) const;
00099
00107 virtual void readImpl(IStream& in, Streamable& ob, bool readClassName) const;
00108
00117 virtual void writeClassName(OStream& out, const string& className) const;
00118
00127 virtual string readClassName(IStream& in) const;
00128
00135 static bool addToMap(const std::string& className, std::auto_ptr<Streamer> s) throw();
00136
00137
00138
00139
00140 protected:
00141
00143
00150 virtual Streamer& getStreamer(const string& className) const;
00151
00152
00153 typedef map<string, shared_ptr<Streamer> > StreamerMap;
00154 static StreamerMap& getMap() throw();
00155 };
00156
00157 }
00158
00159 #endif //SCT_IOMANAGER_H