llcategory.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /**
  2. * @file llcategory.h
  3. * @brief LLCategory class header file.
  4. *
  5. * $LicenseInfo:firstyear=2002&license=viewergpl$
  6. *
  7. * Copyright (c) 2002-2009, Linden Research, Inc.
  8. *
  9. * Second Life Viewer Source Code
  10. * The source code in this file ("Source Code") is provided by Linden Lab
  11. * to you under the terms of the GNU General Public License, version 2.0
  12. * ("GPL"), unless you have obtained a separate licensing agreement
  13. * ("Other License"), formally executed by you and Linden Lab. Terms of
  14. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  15. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  16. *
  17. * There are special exceptions to the terms and conditions of the GPL as
  18. * it is applied to this Source Code. View the full text of the exception
  19. * in the file doc/FLOSS-exception.txt in this software distribution, or
  20. * online at
  21. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  22. *
  23. * By copying, modifying or distributing this software, you acknowledge
  24. * that you have read and understood your obligations described above,
  25. * and agree to abide by those obligations.
  26. *
  27. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  28. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  29. * COMPLETENESS OR PERFORMANCE.
  30. * $/LicenseInfo$
  31. */
  32. #ifndef LL_LLCATEGORY_H
  33. #define LL_LLCATEGORY_H
  34. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  35. // Class LLCategory
  36. //
  37. // An instance of the LLCategory class represents a particular
  38. // category in a hierarchical classification system. For now, it is 4
  39. // levels deep with 255 (minus 1) possible values at each level. If a
  40. // non zero value is found at level 4, that is the leaf category,
  41. // otherwise, it is the first level that has a 0 in the next depth
  42. // level.
  43. //
  44. // To output the names of all top level categories, you could do the
  45. // following:
  46. //
  47. // S32 count = LLCategory::none.getSubCategoryCount();
  48. // for(S32 i = 0; i < count; i++)
  49. // {
  50. // llinfos << none.getSubCategory(i).lookupNmae() << llendl;
  51. // }
  52. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  53. class LLMessageSystem;
  54. class LLCategory
  55. {
  56. public:
  57. // Nice default static const.
  58. static const LLCategory none;
  59. // construction. Since this is really a POD type, destruction,
  60. // copy, and assignment are handled by the compiler.
  61. LLCategory();
  62. explicit LLCategory(U32 value) { init(value); }
  63. // methods
  64. void init(U32 value);
  65. U32 getU32() const;
  66. S32 getSubCategoryCount() const;
  67. // This method will return a category that is the nth
  68. // subcategory. If you're already at the bottom of the hierarchy,
  69. // then the method will return a copy of this.
  70. LLCategory getSubCategory(U8 n) const;
  71. // This method will return the name of the leaf category type
  72. const char* lookupName() const;
  73. // This method will return the full hierarchy name in an easily
  74. // interpreted (TOP)|(SUB1)|(SUB2) format. *NOTE: not implemented
  75. // because we don't have anything but top level categories at the
  76. // moment.
  77. //const char* lookupFullName() const;
  78. // message serialization
  79. void packMessage(LLMessageSystem* msg) const;
  80. void unpackMessage(LLMessageSystem* msg, const char* block);
  81. void unpackMultiMessage(LLMessageSystem* msg, const char* block,
  82. S32 block_num);
  83. protected:
  84. enum
  85. {
  86. CATEGORY_TOP = 0,
  87. CATEGORY_DEPTH = 4,
  88. };
  89. U8 mData[CATEGORY_DEPTH];
  90. };
  91. #endif // LL_LLCATEGORY_H