PageRenderTime 26ms CodeModel.GetById 18ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/llmessage/lltemplatemessagebuilder.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 115 lines | 67 code | 20 blank | 28 comment | 0 complexity | 447efcd697c10ff3cba0d8d8a4cd912f MD5 | raw file
  1/** 
  2 * @file lltemplatemessagebuilder.h
  3 * @brief Declaration of LLTemplateMessageBuilder class.
  4 *
  5 * $LicenseInfo:firstyear=2007&license=viewerlgpl$
  6 * Second Life Viewer Source Code
  7 * Copyright (C) 2010, Linden Research, Inc.
  8 * 
  9 * This library is free software; you can redistribute it and/or
 10 * modify it under the terms of the GNU Lesser General Public
 11 * License as published by the Free Software Foundation;
 12 * version 2.1 of the License only.
 13 * 
 14 * This library is distributed in the hope that it will be useful,
 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 17 * Lesser General Public License for more details.
 18 * 
 19 * You should have received a copy of the GNU Lesser General Public
 20 * License along with this library; if not, write to the Free Software
 21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 22 * 
 23 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
 24 * $/LicenseInfo$
 25 */
 26
 27#ifndef LL_LLTEMPLATEMESSAGEBUILDER_H
 28#define LL_LLTEMPLATEMESSAGEBUILDER_H
 29
 30#include <map>
 31
 32#include "llmessagebuilder.h"
 33#include "llmsgvariabletype.h"
 34
 35class LLMsgData;
 36class LLMessageTemplate;
 37class LLMsgBlkData;
 38class LLMessageTemplate;
 39
 40class LLTemplateMessageBuilder : public LLMessageBuilder
 41{
 42public:
 43	
 44	typedef std::map<const char* , LLMessageTemplate*> message_template_name_map_t;
 45
 46	LLTemplateMessageBuilder(const message_template_name_map_t&);
 47	virtual ~LLTemplateMessageBuilder();
 48
 49	virtual void newMessage(const char* name);
 50
 51	virtual void nextBlock(const char* blockname);
 52	virtual BOOL removeLastBlock(); // TODO: babbage: remove this horror...
 53
 54	/** All add* methods expect pointers to canonical varname strings. */
 55	virtual void addBinaryData(const char *varname, const void *data, 
 56							   S32 size);
 57	virtual void addBOOL(const char* varname, BOOL b);
 58	virtual void addS8(const char* varname, S8 s);
 59	virtual void addU8(const char* varname, U8 u);
 60	virtual void addS16(const char* varname, S16 i);
 61	virtual void addU16(const char* varname, U16 i);
 62	virtual void addF32(const char* varname, F32 f);
 63	virtual void addS32(const char* varname, S32 s);
 64	virtual void addU32(const char* varname, U32 u);
 65	virtual void addU64(const char* varname, U64 lu);
 66	virtual void addF64(const char* varname, F64 d);
 67	virtual void addVector3(const char* varname, const LLVector3& vec);
 68	virtual void addVector4(const char* varname, const LLVector4& vec);
 69	virtual void addVector3d(const char* varname, const LLVector3d& vec);
 70	virtual void addQuat(const char* varname, const LLQuaternion& quat);
 71	virtual void addUUID(const char* varname, const LLUUID& uuid);
 72	virtual void addIPAddr(const char* varname, const U32 ip);
 73	virtual void addIPPort(const char* varname, const U16 port);
 74	virtual void addString(const char* varname, const char* s);
 75	virtual void addString(const char* varname, const std::string& s);
 76
 77	virtual BOOL isMessageFull(const char* blockname) const;
 78	virtual void compressMessage(U8*& buf_ptr, U32& buffer_length);
 79
 80	virtual BOOL isBuilt() const;
 81	virtual BOOL isClear() const;
 82	virtual U32 buildMessage(U8* buffer, U32 buffer_size, U8 offset_to_data);
 83        /**< Return built message size */
 84	
 85	virtual void clearMessage();
 86
 87	// TODO: babbage: remove this horror.
 88	virtual void setBuilt(BOOL b);
 89
 90	virtual S32 getMessageSize();
 91	virtual const char* getMessageName() const;
 92
 93	virtual void copyFromMessageData(const LLMsgData& data);
 94	virtual void copyFromLLSD(const LLSD&);
 95
 96	LLMsgData* getCurrentMessage() const { return mCurrentSMessageData; }
 97private:
 98	void addData(const char* varname, const void* data, 
 99					 EMsgVariableType type, S32 size);
100	
101	void addData(const char* varname, const void* data, 
102						EMsgVariableType type);
103
104	LLMsgData* mCurrentSMessageData;
105	const LLMessageTemplate* mCurrentSMessageTemplate;
106	LLMsgBlkData* mCurrentSDataBlock;
107	char* mCurrentSMessageName;
108	char* mCurrentSBlockName;
109	BOOL mbSBuilt;
110	BOOL mbSClear;
111	S32	 mCurrentSendTotal;
112	const message_template_name_map_t& mMessageTemplates;
113};
114
115#endif // LL_LLTEMPLATEMESSAGEBUILDER_H