
00001 //***************************************************************************** 00002 // File : gzDistSerializeMemory.h 00003 // Module : gzDistribution 00004 // Description : Definition of gzDistSerializeAdapterMemory 00005 // Author : Christian Andersson 00006 // Product : GizmoDistribution 2.1.1 00007 // 00008 // Copyright © 2004 - Saab Training Systems AB, Sweden 00009 // 00010 // NOTE: GizmoDistribution is a toolkit used for implementing distributed 00011 // objects and events in C++ 00012 // 00013 // 00014 // Revision History... 00015 // 00016 // Who Date Description 00017 // 00018 // CAN 040305 Created file 00019 // 00020 //***************************************************************************** 00021 #ifndef __GZ_DIST_SERIALIZE_ADAPTER_MEMORY_H__ 00022 #define __GZ_DIST_SERIALIZE_ADAPTER_MEMORY_H__ 00023 00028 // Includes 00029 #include "gzDistBase.h" 00030 00031 // Constants 00032 #define GZ_DIST_MESSAGE_BUFFER_SIZE 1024 00033 #define GZ_DIST_MAX_CODED_BUFFER_FACTOR 2 00034 00035 00036 //----------------------- gzDistSerializeMemoryData ------------------------- 00037 00038 // Internal 00039 class gzDistSerializeMemoryData : public gzReference 00040 { 00041 public: 00042 00043 GZ_DIST_EXPORT gzDistSerializeMemoryData(); 00044 GZ_DIST_EXPORT virtual ~gzDistSerializeMemoryData(); 00045 00046 // The serialized data. 00047 gzUByte data[GZ_DIST_MESSAGE_BUFFER_SIZE]; 00048 00049 // Number of stored bytes in data. 00050 gzUInt numberOfBytes; 00051 }; 00052 00053 //----------------------- gzDistSerializeAdapterMemory ------------------------- 00054 00055 // Internal 00056 class gzDistSerializeAdapterMemory : public gzSerializeAdapterMemory 00057 { 00058 public: 00059 GZ_DIST_EXPORT gzDistSerializeAdapterMemory(); 00060 GZ_DIST_EXPORT virtual ~gzDistSerializeAdapterMemory(); 00061 00062 GZ_DIST_EXPORT gzVoid setStore(gzList<gzDistSerializeMemoryData>* store); 00063 GZ_DIST_EXPORT gzVoid setHeaderSize(gzUInt bytes); 00064 GZ_DIST_EXPORT gzBool setPosition(gzUInt position); 00065 GZ_DIST_EXPORT gzULong getPosition(); 00066 00067 protected: 00068 gzVoid write_imp(gzUByte data); 00069 gzUByte read_imp(); 00070 gzVoid write_imp(gzUByte *data, gzULong count); 00071 gzULong read_imp(gzUByte *data, gzULong maxcount); 00072 gzBool hasData_imp(); 00073 00074 private: 00075 gzVoid createNewBuffer(); 00076 gzVoid getNextBuffer(); 00077 gzBool moveForward(gzUInt bytes); 00078 00079 gzList<gzDistSerializeMemoryData>* m_store; 00080 gzUInt m_listIndex; 00081 00082 gzDistSerializeMemoryData* m_currentData; 00083 00084 gzUInt m_headerSize; 00085 00086 // The "global" position (Not only for fragment) 00087 gzUInt m_position; 00088 00089 // The "local" position (Only for fragment) 00090 gzUInt m_fragmentPosition; 00091 }; 00092 00093 #endif