PageRenderTime 384ms CodeModel.GetById 201ms app.highlight 3ms RepoModel.GetById 178ms app.codeStats 0ms

/indra/lscript/llscriptresource.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 69 lines | 19 code | 12 blank | 38 comment | 0 complexity | 4f18d7be87fa9ae191b98047e57846d6 MD5 | raw file
 1/** 
 2 * @file llscriptresource.h
 3 * @brief LLScriptResource class definition
 4 *
 5 * $LicenseInfo:firstyear=2008&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_LLSCRIPTRESOURCE_H
28#define LL_LLSCRIPTRESOURCE_H
29
30#include "stdtypes.h"
31
32// An LLScriptResource is a limited resource per ID.
33class LLScriptResource
34{
35public:
36	LLScriptResource();
37
38	// If amount resources are available will mark amount resouces 
39	// used and returns true
40	// Otherwise returns false and doesn't mark any resources used.
41	bool request(S32 amount = 1);
42
43	// Release amount resources from use if at least amount resources are used and return true
44	// If amount is more than currently used no resources are released and return false
45	bool release(S32 amount = 1);
46
47	// Returns how many resources are available
48	S32 getAvailable() const;
49
50	// Sets the total amount of available resources
51	// It is possible to set the amount to less than currently used
52	// Most likely to happen on parcel ownership change
53	void setTotal(S32 amount);
54
55	// Get the total amount of available resources
56	S32 getTotal() const;
57
58	// Get the number of resources used
59	S32 getUsed() const;
60
61	// true if more resources used than total available
62	bool isOverLimit() const;
63
64private:
65	S32 mTotal; // How many resources have been set aside
66	S32 mUsed; // How many resources are currently in use
67};
68
69#endif // LL_LLSCRIPTRESOURCE_H