PageRenderTime 12ms CodeModel.GetById 7ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/llinventory/llcategory.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 98 lines | 27 code | 13 blank | 58 comment | 0 complexity | fd140e1ed7cec22435790c917c2a3031 MD5 | raw file
 1/** 
 2 * @file llcategory.h
 3 * @brief LLCategory class header file.
 4 *
 5 * $LicenseInfo:firstyear=2002&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_LLCATEGORY_H
28#define LL_LLCATEGORY_H
29
30//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
31// Class LLCategory
32//
33// An instance of the LLCategory class represents a particular
34// category in a hierarchical classification system. For now, it is 4
35// levels deep with 255 (minus 1) possible values at each level. If a
36// non zero value is found at level 4, that is the leaf category,
37// otherwise, it is the first level that has a 0 in the next depth
38// level.
39//
40// To output the names of all top level categories, you could do the
41// following:
42//
43//	S32 count = LLCategory::none.getSubCategoryCount();
44//	for(S32 i = 0; i < count; i++)
45//	{
46//		llinfos << none.getSubCategory(i).lookupNmae() << llendl;
47//	}
48//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
49
50class LLMessageSystem;
51
52class LLCategory
53{
54public:
55	// Nice default static const.
56	static const LLCategory none;
57
58	// construction. Since this is really a POD type, destruction,
59	// copy, and assignment are handled by the compiler.
60	LLCategory();
61	explicit LLCategory(U32 value) { init(value); }
62
63	// methods
64	void init(U32 value);
65	U32 getU32() const;
66	S32 getSubCategoryCount() const;
67
68	// This method will return a category that is the nth
69	// subcategory. If you're already at the bottom of the hierarchy,
70	// then the method will return a copy of this.
71	LLCategory getSubCategory(U8 n) const;
72
73	// This method will return the name of the leaf category type
74	const char* lookupName() const;
75
76	// This method will return the full hierarchy name in an easily
77	// interpreted (TOP)|(SUB1)|(SUB2) format. *NOTE: not implemented
78	// because we don't have anything but top level categories at the
79	// moment.
80	//const char* lookupFullName() const;
81
82	// message serialization
83	void packMessage(LLMessageSystem* msg) const;
84	void unpackMessage(LLMessageSystem* msg, const char* block);
85	void unpackMultiMessage(LLMessageSystem* msg, const char* block,
86							S32 block_num);
87protected:
88	enum
89	{
90		CATEGORY_TOP = 0,
91		CATEGORY_DEPTH = 4,
92	};
93
94	U8 mData[CATEGORY_DEPTH];
95};
96
97
98#endif // LL_LLCATEGORY_H