18 #ifndef INCLUDE_SF_STREAM_HPP 19 #define INCLUDE_SF_STREAM_HPP 24 #include <RCF/Export.hpp> 26 #include <SF/DataPtr.hpp> 27 #include <SF/Encoding.hpp> 28 #include <SF/I_Stream.hpp> 34 class SerializationProtocolIn;
35 class SerializationProtocolOut;
47 class Encoding :
public I_Encoding
50 virtual UInt32 getCount(
52 const std::type_info & type)
54 return countElements( (E *) 0, data, type);
60 const std::type_info & type,
63 encodeElements( (E *) 0, data, pvObject, type, nCount);
66 virtual void toObject(
69 const std::type_info & type,
72 decodeElements( (E *) 0, data, pvObject, type, nCount);
79 class RCF_EXPORT ContextRead
84 void add(SF::UInt32 nid,
const ObjectId &
id);
85 void add(
void *ptr,
const std::type_info &objType,
void *pObj);
86 bool query(SF::UInt32 nid, ObjectId &
id);
87 bool query(
void *ptr,
const std::type_info &objType,
void *&pObj);
90 void setEnabled(
bool enabled);
91 bool getEnabled()
const;
95 std::unique_ptr<std::map<UInt32, ObjectId> > mNidToIdMap;
96 std::unique_ptr<std::map<std::string, std::map< void *, void * > > > mTypeToObjMap;
99 class RCF_EXPORT ContextWrite
104 void setEnabled(
bool enabled);
105 bool getEnabled()
const;
106 void add(
const ObjectId &
id, UInt32 &nid);
107 bool query(
const ObjectId &
id, UInt32 &nid);
112 std::unique_ptr<std::map<ObjectId, UInt32> > mIdToNidMap;
118 class RCF_EXPORT LocalStorage : Noncopyable
123 void setNode(Node *);
134 class SerializerBase;
144 RCF::MemIstream & is,
145 std::size_t archiveSize = 0,
146 int runtimeVersion = 0,
147 int archiveVersion = 0);
152 std::size_t archiveSize = 0,
153 int runtimeVersion = 0,
154 int archiveVersion = 0);
160 std::size_t archiveSize = 0,
161 int runtimeVersion = 0,
162 int archiveVersion = 0);
166 UInt32 read(Byte8 *pBytes, UInt32 nLength);
168 bool verifyAgainstArchiveSize(std::size_t bytesToRead);
170 bool begin(Node &node);
171 bool get(DataPtr &value);
173 UInt32 read_int(UInt32 &n);
174 UInt32 read_byte(Byte8 &byte);
175 void putback_byte(Byte8 byte);
177 std::size_t tell()
const;
178 void seek(std::size_t newPos);
184 int getRuntimeVersion();
187 int getArchiveVersion();
190 void setArchiveVersion(
int archiveVersion);
193 void setRuntimeVersion(
int runtimeVersion);
195 void ignoreVersionStamp(
bool ignore =
true);
197 void setRemoteCallContext(
198 RCF::SerializationProtocolIn * pSerializationProtocolIn);
200 RCF::SerializationProtocolIn *
201 getRemoteCallContext();
203 ContextRead & getTrackingContext();
204 const ContextRead & getTrackingContext()
const;
205 LocalStorage & getLocalStorage();
207 void setEnablePointerTracking(
bool enable);
208 bool getEnablePointerTracking()
const;
218 IStream & operator>>(
const T &t);
222 ContextRead mContextRead;
223 LocalStorage mLocalStorage;
226 std::size_t mArchiveSize;
229 bool mIgnoreVersionStamp;
231 RCF::SerializationProtocolIn * mpSerializationProtocolIn;
241 RCF::MemOstream & os,
242 int runtimeVersion = 0,
243 int archiveVersion = 0);
248 int runtimeVersion = 0,
249 int archiveVersion = 0);
255 int runtimeVersion = 0,
256 int archiveVersion = 0);
260 UInt32 writeRaw(
const Byte8 *pBytes, UInt32 nLength);
262 void begin(
const Node &node);
263 void put(
const DataPtr &value);
265 UInt32 write_int(UInt32 n);
266 UInt32 write_byte(Byte8 byte);
267 UInt32 write(
const Byte8 *pBytes, UInt32 nLength);
273 int getRuntimeVersion();
276 int getArchiveVersion();
279 void setArchiveVersion(
int archiveVersion);
282 void setRuntimeVersion(
int runtimeVersion);
284 void suppressArchiveMetadata(
bool suppress =
true);
286 void setRemoteCallContext(
287 RCF::SerializationProtocolOut * pSerializationProtocolOut);
289 RCF::SerializationProtocolOut *
290 getRemoteCallContext();
292 ContextWrite & getTrackingContext();
293 const ContextWrite & getTrackingContext()
const;
295 LocalStorage & getLocalStorage();
297 void setEnablePointerTracking(
bool enable);
298 bool getEnablePointerTracking()
const;
304 OStream & operator<<(
const T &t);
308 void writeArchiveMetadata();
310 ContextWrite mContextWrite;
311 LocalStorage mLocalStorage;
316 bool mSuppressArchiveMetadata;
317 bool mArchiveMetadataWritten;
319 RCF::SerializationProtocolOut * mpSerializationProtocolOut;
324 #include <SF/Archive.hpp> 332 Archive ar(Archive::READ,
this);
340 Archive ar(Archive::READ,
this);
348 Archive ar(Archive::WRITE,
this);
355 #endif // !INCLUDE_SF_STREAM_HPP Represents an archive, in which serialized objects are stored.
Definition: Archive.hpp:31
Definition: ByteBuffer.hpp:188
Base class for output streams using SF serialization. Use operator <<() to serialize objects into the...
Definition: Stream.hpp:235
Definition: AmiIoHandler.hpp:23
Base class for input streams using SF serialization. Use operator >>() to deserialize objects from th...
Definition: Stream.hpp:137