PageRenderTime 22ms CodeModel.GetById 12ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/llmessage/llmessagethrottle.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 80 lines | 40 code | 15 blank | 25 comment | 0 complexity | 2cfb09a88ff4a8a52bf1becca8db10fd MD5 | raw file
 1/** 
 2 * @file llmessagethrottle.h
 3 * @brief LLMessageThrottle class used for throttling messages.
 4 *
 5 * $LicenseInfo:firstyear=2004&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_LLMESSAGETHROTTLE_H
28#define LL_LLMESSAGETHROTTLE_H
29
30#include <deque>
31
32#include "linden_common.h"
33#include "lluuid.h"
34
35typedef enum e_message_throttle_categories
36{
37	MTC_VIEWER_ALERT,
38	MTC_AGENT_ALERT,
39	MTC_EOF
40} EMessageThrottleCats;
41
42class LLMessageThrottleEntry
43{
44public:
45	LLMessageThrottleEntry(const size_t hash, const U64 entry_time)
46		: mHash(hash), mEntryTime(entry_time) {}
47
48	size_t	getHash() const { return mHash; }
49	U64		getEntryTime() const { return mEntryTime; }
50protected:
51	size_t	mHash;
52	U64		mEntryTime;
53};
54
55
56class LLMessageThrottle
57{
58public:
59	LLMessageThrottle();
60	~LLMessageThrottle();
61
62	BOOL addViewerAlert	(const LLUUID& to, const std::string& mesg);
63	BOOL addAgentAlert	(const LLUUID& agent, const LLUUID& task, const std::string& mesg);
64
65	void pruneEntries();
66
67protected:
68	typedef std::deque<LLMessageThrottleEntry>							message_list_t;
69	typedef std::deque<LLMessageThrottleEntry>::iterator				message_list_iterator_t;
70	typedef std::deque<LLMessageThrottleEntry>::reverse_iterator		message_list_reverse_iterator_t;
71	typedef std::deque<LLMessageThrottleEntry>::const_iterator			message_list_const_iterator_t;
72	typedef std::deque<LLMessageThrottleEntry>::const_reverse_iterator	message_list_const_reverse_iterator_t;
73	message_list_t	mMessageList[MTC_EOF];
74};
75
76extern LLMessageThrottle gMessageThrottle;
77
78#endif
79
80