llinventorytype.cpp

Go to the documentation of this file.
00001 
00032 #include "linden_common.h"
00033 
00034 #include "llinventorytype.h"
00035 
00039 
00040 // Unlike asset type names, not limited to 8 characters.
00041 // Need not match asset type names.
00042 static const char* INVENTORY_TYPE_NAMES[LLInventoryType::IT_COUNT] =
00043 { 
00044         "texture",      // 0
00045         "sound",
00046         "callcard",
00047         "landmark",
00048         NULL,
00049         NULL,           // 5
00050         "object",
00051         "notecard",
00052         "category",
00053         "root",
00054         "script",       // 10
00055         NULL,
00056         NULL,
00057         NULL,
00058         NULL,
00059         "snapshot",     // 15
00060         NULL,
00061         "attach",
00062         "wearable",
00063         "animation",
00064         "gesture",              // 20
00065 };
00066 
00067 // This table is meant for decoding to human readable form. Put any
00068 // and as many printable characters you want in each one.
00069 // See also LLAssetType::mAssetTypeHumanNames
00070 static const char* INVENTORY_TYPE_HUMAN_NAMES[LLInventoryType::IT_COUNT] =
00071 { 
00072         "texture",      // 0
00073         "sound",
00074         "calling card",
00075         "landmark",
00076         NULL,
00077         NULL,           // 5
00078         "object",
00079         "note card",
00080         "folder",
00081         "root",
00082         "script",       // 10
00083         NULL,
00084         NULL,
00085         NULL,
00086         NULL,
00087         "snapshot",     // 15
00088         NULL,
00089         "attachment",
00090         "wearable",
00091         "animation",
00092         "gesture",              // 20
00093 };
00094 
00095 // Maps asset types to the default inventory type for that kind of asset.
00096 // Thus, "Lost and Found" is a "Category"
00097 static const LLInventoryType::EType
00098 DEFAULT_ASSET_FOR_INV_TYPE[LLAssetType::AT_COUNT] =
00099 {
00100         LLInventoryType::IT_TEXTURE,            // AT_TEXTURE
00101         LLInventoryType::IT_SOUND,                      // AT_SOUND
00102         LLInventoryType::IT_CALLINGCARD,        // AT_CALLINGCARD
00103         LLInventoryType::IT_LANDMARK,           // AT_LANDMARK
00104         LLInventoryType::IT_LSL,                        // AT_SCRIPT
00105         LLInventoryType::IT_WEARABLE,           // AT_CLOTHING
00106         LLInventoryType::IT_OBJECT,                     // AT_OBJECT
00107         LLInventoryType::IT_NOTECARD,           // AT_NOTECARD
00108         LLInventoryType::IT_CATEGORY,           // AT_CATEGORY
00109         LLInventoryType::IT_ROOT_CATEGORY,      // AT_ROOT_CATEGORY
00110         LLInventoryType::IT_LSL,                        // AT_LSL_TEXT
00111         LLInventoryType::IT_LSL,                        // AT_LSL_BYTECODE
00112         LLInventoryType::IT_TEXTURE,            // AT_TEXTURE_TGA
00113         LLInventoryType::IT_WEARABLE,           // AT_BODYPART
00114         LLInventoryType::IT_CATEGORY,           // AT_TRASH
00115         LLInventoryType::IT_CATEGORY,           // AT_SNAPSHOT_CATEGORY
00116         LLInventoryType::IT_CATEGORY,           // AT_LOST_AND_FOUND
00117         LLInventoryType::IT_SOUND,                      // AT_SOUND_WAV
00118         LLInventoryType::IT_NONE,                       // AT_IMAGE_TGA
00119         LLInventoryType::IT_NONE,                       // AT_IMAGE_JPEG
00120         LLInventoryType::IT_ANIMATION,          // AT_ANIMATION
00121         LLInventoryType::IT_GESTURE,            // AT_GESTURE
00122 };
00123 
00124 static const int MAX_POSSIBLE_ASSET_TYPES = 2;
00125 static const LLAssetType::EType
00126 INVENTORY_TO_ASSET_TYPE[LLInventoryType::IT_COUNT][MAX_POSSIBLE_ASSET_TYPES] =
00127 {
00128         { LLAssetType::AT_TEXTURE, LLAssetType::AT_NONE },              // IT_TEXTURE
00129         { LLAssetType::AT_SOUND, LLAssetType::AT_NONE },                // IT_SOUND
00130         { LLAssetType::AT_CALLINGCARD, LLAssetType::AT_NONE },  // IT_CALLINGCARD
00131         { LLAssetType::AT_LANDMARK, LLAssetType::AT_NONE },             // IT_LANDMARK
00132         { LLAssetType::AT_NONE, LLAssetType::AT_NONE },
00133         { LLAssetType::AT_NONE, LLAssetType::AT_NONE },
00134         { LLAssetType::AT_OBJECT, LLAssetType::AT_NONE },               // IT_OBJECT
00135         { LLAssetType::AT_NOTECARD, LLAssetType::AT_NONE },             // IT_NOTECARD
00136         { LLAssetType::AT_NONE, LLAssetType::AT_NONE },                 // IT_CATEGORY
00137         { LLAssetType::AT_NONE, LLAssetType::AT_NONE },                 // IT_ROOT_CATEGORY
00138         { LLAssetType::AT_LSL_TEXT, LLAssetType::AT_LSL_BYTECODE }, // IT_LSL
00139         { LLAssetType::AT_NONE, LLAssetType::AT_NONE },
00140         { LLAssetType::AT_NONE, LLAssetType::AT_NONE },
00141         { LLAssetType::AT_NONE, LLAssetType::AT_NONE },
00142         { LLAssetType::AT_NONE, LLAssetType::AT_NONE },
00143         { LLAssetType::AT_TEXTURE, LLAssetType::AT_NONE },              // IT_SNAPSHOT
00144         { LLAssetType::AT_NONE, LLAssetType::AT_NONE },
00145         { LLAssetType::AT_OBJECT, LLAssetType::AT_NONE },               // IT_ATTACHMENT
00146         { LLAssetType::AT_CLOTHING, LLAssetType::AT_BODYPART }, // IT_WEARABLE
00147         { LLAssetType::AT_ANIMATION, LLAssetType::AT_NONE },    // IT_ANIMATION
00148         { LLAssetType::AT_GESTURE, LLAssetType::AT_NONE },              // IT_GESTURE
00149 };
00150 
00151 // static
00152 const char* LLInventoryType::lookup(EType type)
00153 {
00154         if((type >= 0) && (type < IT_COUNT))
00155         {
00156                 return INVENTORY_TYPE_NAMES[S32(type)];
00157         }
00158         else
00159         {
00160                 return NULL;
00161         }
00162 }
00163 
00164 // static
00165 LLInventoryType::EType LLInventoryType::lookup(const char* name)
00166 {
00167         for(S32 i = 0; i < IT_COUNT; ++i)
00168         {
00169                 if((INVENTORY_TYPE_NAMES[i])
00170                    && (0 == strcmp(name, INVENTORY_TYPE_NAMES[i])))
00171                 {
00172                         // match
00173                         return (EType)i;
00174                 }
00175         }
00176         return IT_NONE;
00177 }
00178 
00179 // XUI:translate
00180 // translation from a type to a human readable form.
00181 // static
00182 const char* LLInventoryType::lookupHumanReadable(EType type)
00183 {
00184         if((type >= 0) && (type < IT_COUNT))
00185         {
00186                 return INVENTORY_TYPE_HUMAN_NAMES[S32(type)];
00187         }
00188         else
00189         {
00190                 return NULL;
00191         }
00192 }
00193 
00194 // return the default inventory for the given asset type.
00195 // static
00196 LLInventoryType::EType LLInventoryType::defaultForAssetType(LLAssetType::EType asset_type)
00197 {
00198         if((asset_type >= 0) && (asset_type < LLAssetType::AT_COUNT))
00199         {
00200                 return DEFAULT_ASSET_FOR_INV_TYPE[S32(asset_type)];
00201         }
00202         else
00203         {
00204                 return IT_NONE;
00205         }
00206 }
00207 
00208 bool inventory_and_asset_types_match(
00209         LLInventoryType::EType inventory_type,
00210         LLAssetType::EType asset_type)
00211 {
00212         bool rv = false;
00213         if((inventory_type >= 0) && (inventory_type < LLInventoryType::IT_COUNT))
00214         {
00215                 for(S32 i = 0; i < MAX_POSSIBLE_ASSET_TYPES; ++i)
00216                 {
00217                         if(INVENTORY_TO_ASSET_TYPE[inventory_type][i] == asset_type)
00218                         {
00219                                 rv = true;
00220                                 break;
00221                         }
00222                 }
00223         }
00224         return rv;
00225 }

Generated on Fri May 16 08:32:12 2008 for SecondLife by  doxygen 1.5.5