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