aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llmessage/llmessagetemplate.h
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/llmessage/llmessagetemplate.h')
-rw-r--r--linden/indra/llmessage/llmessagetemplate.h83
1 files changed, 71 insertions, 12 deletions
diff --git a/linden/indra/llmessage/llmessagetemplate.h b/linden/indra/llmessage/llmessagetemplate.h
index 8847ddc..804c343 100644
--- a/linden/indra/llmessage/llmessagetemplate.h
+++ b/linden/indra/llmessage/llmessagetemplate.h
@@ -1,3 +1,31 @@
1/**
2 * @file llmessagetemplate.h
3 * @brief Declaration of the message template classes.
4 *
5 * Copyright (c) 2007-2007, Linden Research, Inc.
6 *
7 * Second Life Viewer Source Code
8 * The source code in this file ("Source Code") is provided by Linden Lab
9 * to you under the terms of the GNU General Public License, version 2.0
10 * ("GPL"), unless you have obtained a separate licensing agreement
11 * ("Other License"), formally executed by you and Linden Lab. Terms of
12 * the GPL can be found in doc/GPL-license.txt in this distribution, or
13 * online at http://secondlife.com/developers/opensource/gplv2
14 *
15 * There are special exceptions to the terms and conditions of the GPL as
16 * it is applied to this Source Code. View the full text of the exception
17 * in the file doc/FLOSS-exception.txt in this software distribution, or
18 * online at http://secondlife.com/developers/opensource/flossexception
19 *
20 * By copying, modifying or distributing this software, you acknowledge
21 * that you have read and understood your obligations described above,
22 * and agree to abide by those obligations.
23 *
24 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
25 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
26 * COMPLETENESS OR PERFORMANCE.
27 */
28
1#ifndef LL_LLMESSAGETEMPLATE_H 29#ifndef LL_LLMESSAGETEMPLATE_H
2#define LL_LLMESSAGETEMPLATE_H 30#define LL_LLMESSAGETEMPLATE_H
3 31
@@ -123,7 +151,7 @@ public:
123 mName = name; 151 mName = name;
124 } 152 }
125 153
126 LLMessageVariable(char *name, const EMsgVariableType type, const S32 size) : mType(type), mSize(size) 154 LLMessageVariable(const char *name, const EMsgVariableType type, const S32 size) : mType(type), mSize(size)
127 { 155 {
128 mName = gMessageStringTable.getString(name); 156 mName = gMessageStringTable.getString(name);
129 } 157 }
@@ -154,14 +182,14 @@ typedef enum e_message_block_type
154class LLMessageBlock 182class LLMessageBlock
155{ 183{
156public: 184public:
157 LLMessageBlock(char *name, EMsgBlockType type, S32 number = 1) : mType(type), mNumber(number), mTotalSize(0) 185 LLMessageBlock(const char *name, EMsgBlockType type, S32 number = 1) : mType(type), mNumber(number), mTotalSize(0)
158 { 186 {
159 mName = gMessageStringTable.getString(name); 187 mName = gMessageStringTable.getString(name);
160 } 188 }
161 189
162 ~LLMessageBlock() 190 ~LLMessageBlock()
163 { 191 {
164 for_each(mMemberVariables.begin(), mMemberVariables.end(), DeletePairedPointer()); 192 for_each(mMemberVariables.begin(), mMemberVariables.end(), DeletePointer());
165 } 193 }
166 194
167 void addVariable(char *name, const EMsgVariableType type, const S32 size) 195 void addVariable(char *name, const EMsgVariableType type, const S32 size)
@@ -193,9 +221,15 @@ public:
193 return (mMemberVariables[name])->getSize(); 221 return (mMemberVariables[name])->getSize();
194 } 222 }
195 223
224 const LLMessageVariable* getVariable(char* name) const
225 {
226 message_variable_map_t::const_iterator iter = mMemberVariables.find(name);
227 return iter != mMemberVariables.end()? *iter : NULL;
228 }
229
196 friend std::ostream& operator<<(std::ostream& s, LLMessageBlock &msg); 230 friend std::ostream& operator<<(std::ostream& s, LLMessageBlock &msg);
197 231
198 typedef std::map<const char *, LLMessageVariable*> message_variable_map_t; 232 typedef LLDynamicArrayIndexed<LLMessageVariable*, const char *, 8> message_variable_map_t;
199 message_variable_map_t mMemberVariables; 233 message_variable_map_t mMemberVariables;
200 char *mName; 234 char *mName;
201 EMsgBlockType mType; 235 EMsgBlockType mType;
@@ -224,6 +258,13 @@ enum EMsgEncoding
224 ME_ZEROCODED 258 ME_ZEROCODED
225}; 259};
226 260
261enum EMsgDeprecation
262{
263 MD_NOTDEPRECATED,
264 MD_UDPDEPRECATED,
265 MD_DEPRECATED
266};
267
227class LLMessageTemplate 268class LLMessageTemplate
228{ 269{
229public: 270public:
@@ -234,7 +275,8 @@ public:
234 mFrequency(freq), 275 mFrequency(freq),
235 mTrust(MT_NOTRUST), 276 mTrust(MT_NOTRUST),
236 mEncoding(ME_ZEROCODED), 277 mEncoding(ME_ZEROCODED),
237 mMessageNumber(message_number), 278 mDeprecation(MD_NOTDEPRECATED),
279 mMessageNumber(message_number),
238 mTotalSize(0), 280 mTotalSize(0),
239 mReceiveCount(0), 281 mReceiveCount(0),
240 mReceiveBytes(0), 282 mReceiveBytes(0),
@@ -253,8 +295,8 @@ public:
253 295
254 ~LLMessageTemplate() 296 ~LLMessageTemplate()
255 { 297 {
256 for_each(mMemberBlocks.begin(), mMemberBlocks.end(), DeletePairedPointer()); 298 for_each(mMemberBlocks.begin(), mMemberBlocks.end(), DeletePointer());
257 } 299}
258 300
259 void addBlock(LLMessageBlock *blockp) 301 void addBlock(LLMessageBlock *blockp)
260 { 302 {
@@ -289,7 +331,7 @@ public:
289 mTrust = t; 331 mTrust = t;
290 } 332 }
291 333
292 EMsgTrust getTrust(void) 334 EMsgTrust getTrust(void) const
293 { 335 {
294 return mTrust; 336 return mTrust;
295 } 337 }
@@ -299,18 +341,28 @@ public:
299 { 341 {
300 mEncoding = e; 342 mEncoding = e;
301 } 343 }
302 EMsgEncoding getEncoding() 344 EMsgEncoding getEncoding() const
303 { 345 {
304 return mEncoding; 346 return mEncoding;
305 } 347 }
306 348
349 void setDeprecation(EMsgDeprecation d)
350 {
351 mDeprecation = d;
352 }
353
354 EMsgDeprecation getDeprecation() const
355 {
356 return mDeprecation;
357 }
358
307 void setHandlerFunc(void (*handler_func)(LLMessageSystem *msgsystem, void **user_data), void **user_data) 359 void setHandlerFunc(void (*handler_func)(LLMessageSystem *msgsystem, void **user_data), void **user_data)
308 { 360 {
309 mHandlerFunc = handler_func; 361 mHandlerFunc = handler_func;
310 mUserData = user_data; 362 mUserData = user_data;
311 } 363 }
312 364
313 BOOL callHandlerFunc(LLMessageSystem *msgsystem) 365 BOOL callHandlerFunc(LLMessageSystem *msgsystem) const
314 { 366 {
315 if (mHandlerFunc) 367 if (mHandlerFunc)
316 { 368 {
@@ -320,20 +372,27 @@ public:
320 return FALSE; 372 return FALSE;
321 } 373 }
322 374
323 bool isBanned(bool trustedSource) 375 bool isBanned(bool trustedSource) const
324 { 376 {
325 return trustedSource ? mBanFromTrusted : mBanFromUntrusted; 377 return trustedSource ? mBanFromTrusted : mBanFromUntrusted;
326 } 378 }
327 379
328 friend std::ostream& operator<<(std::ostream& s, LLMessageTemplate &msg); 380 friend std::ostream& operator<<(std::ostream& s, LLMessageTemplate &msg);
329 381
382 const LLMessageBlock* getBlock(char* name) const
383 {
384 message_block_map_t::const_iterator iter = mMemberBlocks.find(name);
385 return iter != mMemberBlocks.end()? *iter : NULL;
386 }
387
330public: 388public:
331 typedef std::map<char*, LLMessageBlock*> message_block_map_t; 389 typedef LLDynamicArrayIndexed<LLMessageBlock*, char*, 8> message_block_map_t;
332 message_block_map_t mMemberBlocks; 390 message_block_map_t mMemberBlocks;
333 char *mName; 391 char *mName;
334 EMsgFrequency mFrequency; 392 EMsgFrequency mFrequency;
335 EMsgTrust mTrust; 393 EMsgTrust mTrust;
336 EMsgEncoding mEncoding; 394 EMsgEncoding mEncoding;
395 EMsgDeprecation mDeprecation;
337 U32 mMessageNumber; 396 U32 mMessageNumber;
338 S32 mTotalSize; 397 S32 mTotalSize;
339 U32 mReceiveCount; // how many of this template have been received since last reset 398 U32 mReceiveCount; // how many of this template have been received since last reset