19 #ifndef INCLUDE_SF_STREAM_HPP 20 #define INCLUDE_SF_STREAM_HPP 25 #include <RCF/Export.hpp> 27 #include <SF/DataPtr.hpp> 28 #include <SF/Encoding.hpp> 29 #include <SF/I_Stream.hpp> 35 class SerializationProtocolIn;
36 class SerializationProtocolOut;
48 class Encoding :
public I_Encoding
51 virtual UInt32 getCount(
53 const std::type_info & type)
55 return countElements( (E *) 0, data, type);
61 const std::type_info & type,
64 encodeElements( (E *) 0, data, pvObject, type, nCount);
67 virtual void toObject(
70 const std::type_info & type,
73 decodeElements( (E *) 0, data, pvObject, type, nCount);
80 class RCF_EXPORT ContextRead
85 void add(SF::UInt32 nid,
const ObjectId &
id);
86 void add(
void *ptr,
const std::type_info &objType,
void *pObj);
87 bool query(SF::UInt32 nid, ObjectId &
id);
88 bool query(
void *ptr,
const std::type_info &objType,
void *&pObj);
91 void setEnabled(
bool enabled);
92 bool getEnabled()
const;
96 std::unique_ptr<std::map<UInt32, ObjectId> > mNidToIdMap;
97 std::unique_ptr<std::map<std::string, std::map< void *, void * > > > mTypeToObjMap;
100 class RCF_EXPORT ContextWrite
105 void setEnabled(
bool enabled);
106 bool getEnabled()
const;
107 void add(
const ObjectId &
id, UInt32 &nid);
108 bool query(
const ObjectId &
id, UInt32 &nid);
113 std::unique_ptr<std::map<ObjectId, UInt32> > mIdToNidMap;
119 class RCF_EXPORT LocalStorage : Noncopyable
124 void setNode(Node *);
135 class SerializerBase;
145 RCF::MemIstream & is,
146 std::size_t archiveSize = 0,
147 int runtimeVersion = 0,
148 int archiveVersion = 0);
153 std::size_t archiveSize = 0,
154 int runtimeVersion = 0,
155 int archiveVersion = 0);
161 std::size_t archiveSize = 0,
162 int runtimeVersion = 0,
163 int archiveVersion = 0);
167 UInt32 read(Byte8 *pBytes, UInt32 nLength);
169 bool verifyAgainstArchiveSize(std::size_t bytesToRead);
171 bool begin(Node &node);
172 bool get(DataPtr &value);
174 UInt32 read_int(UInt32 &n);
175 UInt32 read_byte(Byte8 &byte);
176 void putback_byte(Byte8 byte);
178 std::size_t tell()
const;
179 void seek(std::size_t newPos);
185 int getRuntimeVersion();
188 int getArchiveVersion();
191 void setArchiveVersion(
int archiveVersion);
194 void setRuntimeVersion(
int runtimeVersion);
196 void ignoreVersionStamp(
bool ignore =
true);
198 void setRemoteCallContext(
199 RCF::SerializationProtocolIn * pSerializationProtocolIn);
201 RCF::SerializationProtocolIn *
202 getRemoteCallContext();
204 ContextRead & getTrackingContext();
205 const ContextRead & getTrackingContext()
const;
206 LocalStorage & getLocalStorage();
208 void setEnablePointerTracking(
bool enable);
209 bool getEnablePointerTracking()
const;
219 IStream & operator>>(
const T &t);
223 ContextRead mContextRead;
224 LocalStorage mLocalStorage;
227 std::size_t mArchiveSize;
230 bool mIgnoreVersionStamp;
232 RCF::SerializationProtocolIn * mpSerializationProtocolIn;
242 RCF::MemOstream & os,
243 int runtimeVersion = 0,
244 int archiveVersion = 0);
249 int runtimeVersion = 0,
250 int archiveVersion = 0);
256 int runtimeVersion = 0,
257 int archiveVersion = 0);
261 UInt32 writeRaw(
const Byte8 *pBytes, UInt32 nLength);
263 void begin(
const Node &node);
264 void put(
const DataPtr &value);
266 UInt32 write_int(UInt32 n);
267 UInt32 write_byte(Byte8 byte);
268 UInt32 write(
const Byte8 *pBytes, UInt32 nLength);
274 int getRuntimeVersion();
277 int getArchiveVersion();
280 void setArchiveVersion(
int archiveVersion);
283 void setRuntimeVersion(
int runtimeVersion);
285 void suppressArchiveMetadata(
bool suppress =
true);
287 void setRemoteCallContext(
288 RCF::SerializationProtocolOut * pSerializationProtocolOut);
290 RCF::SerializationProtocolOut *
291 getRemoteCallContext();
293 ContextWrite & getTrackingContext();
294 const ContextWrite & getTrackingContext()
const;
296 LocalStorage & getLocalStorage();
298 void setEnablePointerTracking(
bool enable);
299 bool getEnablePointerTracking()
const;
305 OStream & operator<<(
const T &t);
309 void writeArchiveMetadata();
311 ContextWrite mContextWrite;
312 LocalStorage mLocalStorage;
317 bool mSuppressArchiveMetadata;
318 bool mArchiveMetadataWritten;
320 RCF::SerializationProtocolOut * mpSerializationProtocolOut;
325 #include <SF/Archive.hpp> 333 Archive ar(Archive::READ,
this);
341 Archive ar(Archive::READ,
this);
349 Archive ar(Archive::WRITE,
this);
356 #endif // !INCLUDE_SF_STREAM_HPP Represents an archive, in which serialized objects are stored.
Definition: Archive.hpp:32
Definition: ByteBuffer.hpp:189
Base class for output streams using SF serialization. Use operator <<() to serialize objects into the...
Definition: Stream.hpp:236
Definition: AmiIoHandler.hpp:24
Base class for input streams using SF serialization. Use operator >>() to deserialize objects from th...
Definition: Stream.hpp:138