Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6119 in orxonox.OLD


Ignore:
Timestamp:
Dec 15, 2005, 12:11:27 AM (18 years ago)
Author:
bensch
Message:

orxonox/branches/objectManger: better algorithm for transforming from OM_LIST to string and back (thanks to manuel, who supposed this (much better) version)

Location:
branches/objectmanager/src/util
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/objectmanager/src/util/object_manager.cc

    r6091 r6119  
    150150const char* ObjectManager::OMListToString(OM_LIST omList)
    151151{
    152   switch (omList)
    153   {
    154     case OM_DEAD:
    155       return "dead";
    156     case OM_ENVIRON_NOTICK:
    157       return "environ-notick";
    158     case OM_ENVIRON:
    159       return "environ";
    160     case OM_COMMON:
    161       return "common";
    162     case OM_GROUP_00:
    163       return "group00";
    164     case OM_GROUP_00_PROJ:
    165       return "group00-proj";
    166     case OM_GROUP_01:
    167       return "group01";
    168     case OM_GROUP_01_PROJ:
    169       return "group01-proj";
    170     case OM_GROUP_02:
    171       return "group02";
    172     case OM_GROUP_02_PROJ:
    173       return "group02-proj";
    174     case OM_GROUP_03:
    175       return "group03";
    176     case OM_GROUP_03_PROJ:
    177       return "group03-proj";
    178     case OM_GROUP_04:
    179       return "group04";
    180     case OM_GROUP_04_PROJ:
    181       return "group04-proj";
    182     case OM_GROUP_05:
    183       return "group05";
    184     case OM_GROUP_05_PROJ:
    185       return "group05-proj";
    186     case OM_GROUP_06:
    187       return "group06";
    188     case OM_GROUP_06_PROJ:
    189       return "group06-proj";
    190     case OM_GROUP_07:
    191       return "group07";
    192     case OM_GROUP_07_PROJ:
    193       return "group07-proj";
    194     case OM_GROUP_08:
    195       return "group08";
    196     case OM_GROUP_08_PROJ:
    197       return "group08-proj";
    198     case OM_GROUP_09:
    199       return "group09";
    200     case OM_GROUP_09_PROJ:
    201       return "group09-proj";
    202     case OM_GROUP_10:
    203       return "group10";
    204     case OM_GROUP_10_PROJ:
    205       return "group10-proj";
    206     case OM_GROUP_11:
    207       return "group11";
    208     case OM_GROUP_11_PROJ:
    209       return "group11-proj";
    210     case OM_GROUP_12:
    211       return "group11";
    212     case OM_GROUP_12_PROJ:
    213       return "group12-proj";
    214     case OM_GROUP_13:
    215       return "group03";
    216     case OM_GROUP_13_PROJ:
    217       return "group13-proj";
    218     case OM_GROUP_14:
    219       return "group14";
    220     case OM_GROUP_14_PROJ:
    221       return "group14-proj";
    222     case OM_GROUP_15:
    223       return "group15";
    224     case OM_GROUP_15_PROJ:
    225       return "group15-proj";
    226     default:
    227       return "null";
    228   }
    229 
    230 }
    231 
    232 
    233 
     152  return ObjectManager::objectManagerListNames[omList];
     153}
     154
     155
     156
     157/**
     158 * @brief transforms a String into an OM_LIST (usefull for debugging/Loading).
     159 * @param listName the OM_LIST-name to be transformed into an OM_LIST.
     160 * @returns the OM_LIST transformed from listName. or the default, if not found or NULL.
     161 */
    234162OM_LIST ObjectManager::StringToOMList(const char* listName)
    235163{
    236164  if (unlikely(listName == NULL)) return OM_DEFAULT_LIST;
    237165
    238   if (!strcmp(listName, "dead")) return OM_DEAD;
    239   if (!strcmp(listName, "environ-notick")) return OM_ENVIRON_NOTICK;
    240   if (!strcmp(listName, "environ")) return OM_ENVIRON;
    241   if (!strcmp(listName, "common")) return OM_COMMON;
    242 
    243   if (!strcmp(listName, "group00")) return OM_GROUP_00;
    244   if (!strcmp(listName, "group00-proj")) return OM_GROUP_00_PROJ;
    245   if (!strcmp(listName, "group01")) return OM_GROUP_01;
    246   if (!strcmp(listName, "group01-proj")) return OM_GROUP_01_PROJ;
    247   if (!strcmp(listName, "group02")) return OM_GROUP_02;
    248   if (!strcmp(listName, "group02-proj")) return OM_GROUP_02_PROJ;
    249   if (!strcmp(listName, "group03")) return OM_GROUP_03;
    250   if (!strcmp(listName, "group03-proj")) return OM_GROUP_03_PROJ;
    251   if (!strcmp(listName, "group04")) return OM_GROUP_04;
    252   if (!strcmp(listName, "group04-proj")) return OM_GROUP_04_PROJ;
    253   if (!strcmp(listName, "group05")) return OM_GROUP_05;
    254   if (!strcmp(listName, "group05-proj")) return OM_GROUP_05_PROJ;
    255   if (!strcmp(listName, "group06")) return OM_GROUP_06;
    256   if (!strcmp(listName, "group06-proj")) return OM_GROUP_06_PROJ;
    257   if (!strcmp(listName, "group07")) return OM_GROUP_07;
    258   if (!strcmp(listName, "group07-proj")) return OM_GROUP_07_PROJ;
    259   if (!strcmp(listName, "group08")) return OM_GROUP_08;
    260   if (!strcmp(listName, "group08-proj")) return OM_GROUP_08_PROJ;
    261   if (!strcmp(listName, "group09")) return OM_GROUP_09;
    262   if (!strcmp(listName, "group09-proj")) return OM_GROUP_09_PROJ;
    263   if (!strcmp(listName, "group10")) return OM_GROUP_10;
    264   if (!strcmp(listName, "group10-proj")) return OM_GROUP_10_PROJ;
    265   if (!strcmp(listName, "group11")) return OM_GROUP_11;
    266   if (!strcmp(listName, "group11-proj")) return OM_GROUP_11_PROJ;
    267   if (!strcmp(listName, "group12")) return OM_GROUP_12;
    268   if (!strcmp(listName, "group12-proj")) return OM_GROUP_12_PROJ;
    269   if (!strcmp(listName, "group13")) return OM_GROUP_13;
    270   if (!strcmp(listName, "group13-proj")) return OM_GROUP_13_PROJ;
    271   if (!strcmp(listName, "group14")) return OM_GROUP_14;
    272   if (!strcmp(listName, "group14-proj")) return OM_GROUP_14_PROJ;
    273   if (!strcmp(listName, "group15")) return OM_GROUP_15;
    274   if (!strcmp(listName, "group15-proj")) return OM_GROUP_15_PROJ;
    275 
     166  for(unsigned int i = 0; i < OM_SIZE; ++i) {
     167    if(!strcmp(listName, ObjectManager::objectManagerListNames[i])) {
     168      return (OM_LIST)i;
     169    }
     170  }
    276171  return OM_DEFAULT_LIST;
    277172}
    278173
     174
     175
     176const char* ObjectManager::objectManagerListNames[] = {
     177    "null",
     178    "dead",
     179    "environ-notick",
     180    "environ",
     181    "common",
     182
     183    "group00",
     184    "group00-proj",
     185    "group01",
     186    "group01-proj",
     187    "group02",
     188    "group02-proj",
     189    "group03",
     190    "group03-proj",
     191    "group04",
     192    "group04-proj",
     193    "group05",
     194    "group05-proj",
     195    "group06",
     196    "group06-proj",
     197    "group07",
     198    "group07-proj",
     199    "group08",
     200    "group08-proj",
     201    "group09",
     202    "group09-proj",
     203    "group10",
     204    "group10-proj",
     205    "group11",
     206    "group11-proj",
     207    "group12",
     208    "group12-proj",
     209    "group13",
     210    "group13-proj",
     211    "group14",
     212    "group14-proj",
     213    "group15",
     214    "group15-proj"
     215};
  • branches/objectmanager/src/util/object_manager.h

    r6091 r6119  
    9898  std::list<WorldEntity*>                 objectLists[OM_SIZE];
    9999
     100  static const char*                      objectManagerListNames[]; //!< Names of all the lists
    100101};
    101102
Note: See TracChangeset for help on using the changeset viewer.