1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
|
// **********************************************************************
//
// Copyright (c) 2003
// ZeroC, Inc.
// Billerica, MA, USA
//
// All Rights Reserved.
//
// Ice is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License version 2 as published by
// the Free Software Foundation.
//
// **********************************************************************
#ifndef ICE_STREAM_H
#define ICE_STREAM_H
#include <Ice/InstanceF.h>
#include <Ice/ObjectF.h>
#include <Ice/ProxyF.h>
#include <Ice/ObjectFactoryF.h>
#include <Ice/Buffer.h>
namespace Ice
{
class UserException;
}
namespace IceInternal
{
class ICE_API BasicStream : public Buffer
{
public:
typedef void (*PatchFunc)(void*, Ice::ObjectPtr&);
BasicStream(Instance* = 0);
//
// Must return Instance*, because we don't hold an InstancePtr for
// optimization reasons (see comments below).
//
Instance* instance() const;
void swap(BasicStream&);
void resize(int);
void reserve(int);
void startWriteEncaps();
void endWriteEncaps();
void startReadEncaps();
void endReadEncaps();
void skipReadEncaps();
void checkReadEncaps();
Ice::Int getReadEncapsSize();
void skipEncaps();
void startWriteSlice();
void endWriteSlice();
void startReadSlice();
void endReadSlice();
void skipSlice();
void writeSize(Ice::Int);
void readSize(Ice::Int&);
void writeTypeId(const std::string&);
void readTypeId(std::string&);
void writeBlob(const std::vector<Ice::Byte>&);
void readBlob(std::vector<Ice::Byte>&, Ice::Int);
void writeBlob(const Ice::Byte*, size_t);
void readBlob(Ice::Byte*, size_t);
// Performance critical function inlined, as writing single bytes
// is used in many places in Ice code.
void write(Ice::Byte v)
{
b.push_back(v);
}
void write(const std::vector<Ice::Byte>&);
void read(Ice::Byte&);
void read(std::vector<Ice::Byte>&);
// Performance critical function inlined, as writing single bools
// is used in many places in Ice code.
void write(bool v)
{
b.push_back(static_cast<Ice::Byte>(v));
}
void write(const std::vector<bool>&);
void read(bool&);
void read(std::vector<bool>&);
void write(Ice::Short);
void write(const std::vector<Ice::Short>&);
void read(Ice::Short&);
void read(std::vector<Ice::Short>&);
void write(Ice::Int);
void write(const std::vector<Ice::Int>&);
void read(Ice::Int&);
void read(std::vector<Ice::Int>&);
void write(Ice::Long);
void write(const std::vector<Ice::Long>&);
void read(Ice::Long&);
void read(std::vector<Ice::Long>&);
void write(Ice::Float);
void write(const std::vector<Ice::Float>&);
void read(Ice::Float&);
void read(std::vector<Ice::Float>&);
void write(Ice::Double);
void write(const std::vector<Ice::Double>&);
void read(Ice::Double&);
void read(std::vector<Ice::Double>&);
void write(const std::string&);
void write(const std::vector<std::string>&);
void read(std::string&);
void read(std::vector<std::string>&);
void write(const Ice::ObjectPrx&);
void read(Ice::ObjectPrx&);
void write(const Ice::ObjectPtr&);
void read(PatchFunc, void*);
void write(const Ice::UserException&);
void throwException();
void writePendingObjects();
void readPendingObjects();
struct PatchEntry
{
PatchFunc patchFunc;
void* patchAddr;
};
typedef std::vector<PatchEntry> PatchList;
typedef std::map<Ice::Int, PatchList> PatchMap;
typedef std::map<Ice::Int, Ice::ObjectPtr> IndexToPtrMap;
typedef std::map<Ice::Int, std::string> TypeIdReadMap;
typedef std::map<Ice::ObjectPtr, Ice::Int> PtrToIndexMap;
typedef std::map<std::string, Ice::Int> TypeIdWriteMap;
private:
//
// Optimization. The instance may not be deleted while a
// stack-allocated BasicStream still holds it.
//
Instance* _instance;
class ICE_API ReadEncaps
{
public:
ReadEncaps();
ReadEncaps(const ReadEncaps&);
~ReadEncaps();
Container::size_type start;
Ice::Byte encodingMajor;
Ice::Byte encodingMinor;
PatchMap* patchMap;
IndexToPtrMap* unmarshaledMap;
Ice::Int typeIdIndex;
TypeIdReadMap* typeIdMap;
};
class ICE_API WriteEncaps
{
public:
WriteEncaps();
WriteEncaps(const WriteEncaps&);
~WriteEncaps();
Container::size_type start;
Ice::Int writeIndex;
PtrToIndexMap* toBeMarshaledMap;
PtrToIndexMap* marshaledMap;
Ice::Int typeIdIndex;
TypeIdWriteMap* typeIdMap;
};
std::vector<ReadEncaps> _readEncapsStack;
std::vector<WriteEncaps> _writeEncapsStack;
ReadEncaps* _currentReadEncaps;
WriteEncaps* _currentWriteEncaps;
Container::size_type _readSlice;
Container::size_type _writeSlice;
static const std::string _iceObjectId;
static const std::string _userExceptionId;
void writeInstance(const Ice::ObjectPtr&, Ice::Int);
void patchPointers(::Ice::Int, PatchMap::iterator, IndexToPtrMap::const_iterator);
};
}
#endif
|