Revision: 8255
          http://playerstage.svn.sourceforge.net/playerstage/?rev=8255&view=rev
Author:   rtv
Date:     2009-09-08 06:48:32 +0000 (Tue, 08 Sep 2009)

Log Message:
-----------
STLized the worldfile parser, and reinstated unused property checking in GUI 
worlds

Modified Paths:
--------------
    code/stage/trunk/libstage/model.cc
    code/stage/trunk/libstage/model_load.cc
    code/stage/trunk/libstage/world.cc
    code/stage/trunk/libstage/worldfile.cc
    code/stage/trunk/libstage/worldfile.hh
    code/stage/trunk/libstage/worldgui.cc
    code/stage/trunk/worlds/benchmark/cave.world
    code/stage/trunk/worlds/fasr.world
    code/stage/trunk/worlds/pioneer.inc
    code/stage/trunk/worlds/sick.inc
    code/stage/trunk/worlds/simple.world

Modified: code/stage/trunk/libstage/model.cc
===================================================================
--- code/stage/trunk/libstage/model.cc  2009-09-08 02:03:53 UTC (rev 8254)
+++ code/stage/trunk/libstage/model.cc  2009-09-08 06:48:32 UTC (rev 8255)
@@ -114,15 +114,15 @@
 
 void Size::Load( Worldfile* wf, int section, const char* keyword )
 {
-       CProperty* prop = wf->GetProperty( section, keyword );  
+       if( CProperty* prop = wf->GetProperty( section, keyword ) )     
        
-       if( prop )
+       //if( prop )
                {
-                       if( prop->value_count != 3 )
+                       if( prop->values.size() != 3 )
                                {
                                        puts( "" ); // newline
                                        PRINT_ERR1( "Loading size. Need a 
vector of length 3: found %d.\n", 
-                                                                               
        prop->value_count ); 
+                                                                               
        (int)prop->values.size() ); 
                                        exit(-1);
                                }
                        
@@ -145,11 +145,11 @@
        
        if( prop )
                {
-                       if( prop->value_count != 4 )
+                       if( prop->values.size() != 4 )
                                {
                                        puts( "" ); // newline
                                        PRINT_ERR1( "Loading pose. Need a 
vector of length 4: found %d.\n", 
-                                                                               
        prop->value_count ); 
+                                                                               
        (int)prop->values.size() ); 
                                        exit(-1);
                                }
                        

Modified: code/stage/trunk/libstage/model_load.cc
===================================================================
--- code/stage/trunk/libstage/model_load.cc     2009-09-08 02:03:53 UTC (rev 
8254)
+++ code/stage/trunk/libstage/model_load.cc     2009-09-08 06:48:32 UTC (rev 
8255)
@@ -118,7 +118,7 @@
 
   if( wf->PropertyExists( wf_entity, "color_rgba" ))
     {      
-      if (wf->GetProperty(wf_entity,"color_rgba")->value_count < 4)
+      if (wf->GetProperty(wf_entity,"color_rgba")->values.size() < 4)
       {
         PRINT_ERR1( "model %s color_rgba requires 4 values\n", this->token );
       }
@@ -187,8 +187,7 @@
 
   if( wf->PropertyExists( wf_entity, "map_resolution" ))
     this->SetMapResolution( wf->ReadFloat(wf_entity, "map_resolution", 
this->map_resolution ));
-  
-  
+    
   // populate the key-value database
   if( wf->PropertyExists( wf_entity, "db_count" ) )
                LoadDataBaseEntries( wf, wf_entity );

Modified: code/stage/trunk/libstage/world.cc
===================================================================
--- code/stage/trunk/libstage/world.cc  2009-09-08 02:03:53 UTC (rev 8254)
+++ code/stage/trunk/libstage/world.cc  2009-09-08 06:48:32 UTC (rev 8255)
@@ -38,7 +38,7 @@
     - quit_time <float>\n
         Stop the simulation after this many simulated seconds have
         elapsed. In libstage, World::Update() returns true. In Stage with
-        a GUI, the simulation is paused. In Stage without a GUI, Stage
+        a GUI, the simulation is paused.wo In Stage without a GUI, Stage
         quits.
  
     - resolution <float>\n
@@ -369,9 +369,6 @@
        LoadModel( wf, entity );
     }
   
-  // warn about unused WF lines
-  wf->WarnUnused();
-  
   FOR_EACH( it, children )
     (*it)->InitRecursive();
   

Modified: code/stage/trunk/libstage/worldfile.cc
===================================================================
--- code/stage/trunk/libstage/worldfile.cc      2009-09-08 02:03:53 UTC (rev 
8254)
+++ code/stage/trunk/libstage/worldfile.cc      2009-09-08 06:48:32 UTC (rev 
8255)
@@ -61,21 +61,13 @@
 ///////////////////////////////////////////////////////////////////////////
 // Default constructor
 Worldfile::Worldfile() :
-  token_size( 0),
-  token_count( 0),
-  tokens( NULL),
-  macro_size( 0),
-  macro_count( 0),
-  macros( NULL),
-  entity_size( 0),
-  entity_count( 0),
-  entities( NULL),
-       properties(NULL),
-  property_count( 0),
+  tokens(),
+  macros(),
+  entities(),
+       properties(),
   filename( NULL),
-  unit_length( 1.0),
-  unit_angle( M_PI / 180),
-       nametable()
+  unit_length( 1.0 ),
+  unit_angle( M_PI / 180.0 )
 {
 }
 
@@ -241,19 +233,19 @@
 // Check for unused properties and print warnings
 bool Worldfile::WarnUnused()
 {
-       // bool unused = false;
-       // for (int i = 0; i < this->property_count; i++)
-  //   {
-  //     CProperty *property = this->properties + i;
-  //     if (!property->used)
-       //                      {
-       //                              unused = true;
-       //                              PRINT_WARN3("worldfile %s:%d : property 
[%s] is defined but not used",
-       //                                                                      
        this->filename, property->line, property->name);
-       //                      }
-  //   }
-  //   return unused;
-  return false;
+       bool unused = false;
+
+       FOR_EACH( it, properties )
+               {
+                       if( ! it->second->used )
+                               {
+                                       PRINT_WARN3("worldfile %s:%d : property 
[%s] is defined but not used",
+                                                                               
        this->filename, it->second->line, it->second->name.c_str());
+                                       unused = true;
+                               }
+               }
+       
+       return unused;
 }
 
 
@@ -476,7 +468,7 @@
     return false;
 
   // This is the basic filename
-  filename = GetTokenValue(this->token_count - 1);
+  filename = GetTokenValue(this->tokens.size() - 1);
 
   // Now do some manipulation.  If its a relative path,
   // we append the path of the world file.
@@ -674,19 +666,19 @@
 // Save tokens to a file.
 bool Worldfile::SaveTokens(FILE *file)
 {
-  int i;
+  unsigned int i;
   CToken *token;
 
-  for (i = 0; i < this->token_count; i++)
+  for (i = 0; i < this->tokens.size(); i++)
     {
-      token = this->tokens + i;
+      token = &this->tokens[i];
 
       if (token->include > 0)
        continue;
       if (token->type == TokenString)
-       fprintf(file, "\"%s\"", token->value);
+                               fprintf(file, "\"%s\"", token->value.c_str());
       else
-       fprintf(file, "%s", token->value);
+                               fprintf(file, "%s", token->value.c_str());
     }
   return true;
 }
@@ -696,18 +688,7 @@
 // Clear the token list
 void Worldfile::ClearTokens()
 {
-  int i;
-  CToken *token;
-
-  for (i = 0; i < this->token_count; i++)
-    {
-      token = this->tokens + i;
-      free(token->value);
-    }
-  free(this->tokens);
-  this->tokens = 0;
-  this->token_size = 0;
-  this->token_count = 0;
+       tokens.clear();
 }
 
 
@@ -715,17 +696,7 @@
 // Add a token to the token list
 bool Worldfile::AddToken(int type, const char *value, int include)
 {
-  if (this->token_count >= this->token_size)
-    {
-      this->token_size += 1000;
-      this->tokens = (CToken*) realloc(this->tokens, this->token_size * 
sizeof(this->tokens[0]));
-    }
-
-  this->tokens[this->token_count].include = include;
-  this->tokens[this->token_count].type = type;
-  this->tokens[this->token_count].value = strdup(value);
-  this->token_count++;
-
+       tokens.push_back( CToken( include, type, value ));
   return true;
 }
 
@@ -734,11 +705,8 @@
 // Set a token value in the token list
 bool Worldfile::SetTokenValue(int index, const char *value)
 {
-  assert(index >= 0 && index < this->token_count);
-
-  free(this->tokens[index].value);
-  this->tokens[index].value = strdup(value);
-
+  assert(index >= 0 && index < (int)this->tokens.size() );
+       tokens[index].value = value;
   return true;
 }
 
@@ -747,9 +715,8 @@
 // Get the value of a token
 const char *Worldfile::GetTokenValue(int index)
 {
-  assert(index >= 0 && index < this->token_count);
-
-  return this->tokens[index].value;
+  assert(index >= 0 && index < (int)this->tokens.size());
+  return this->tokens[index].value.c_str();
 }
 
 
@@ -762,12 +729,14 @@
   line = 1;
   printf("\n## begin tokens\n");
   printf("## %4d : ", line);
-  for (int i = 0; i < this->token_count; i++)
+
+       FOR_EACH( it, tokens )
+  //for (int i = 0; i < this->token_count; i++)
     {
-      if (this->tokens[i].value[0] == '\n')
-       printf("[\\n]\n## %4d : %02d ", ++line, this->tokens[i].include);
+      if ( it->value[0] == '\n')
+                               printf("[\\n]\n## %4d : %02d ", ++line, 
it->include);
       else
-       printf("[%s] ", this->tokens[i].value);
+                               printf("[%s] ", it->value.c_str());
     }
   printf("\n");
   printf("## end tokens\n");
@@ -790,40 +759,40 @@
   entity = AddEntity(-1, "");
   line = 1;
 
-  for (i = 0; i < this->token_count; i++)
+  for (i = 0; i < (int)this->tokens.size(); i++)
     {
-      token = this->tokens + i;
-
+      token = &this->tokens[0] + i;
+                       
       switch (token->type)
-       {
-       case TokenWord:
-         if (strcmp(token->value, "include") == 0)
-           {
-             if (!ParseTokenInclude(&i, &line))
-               return false;
-           }
-         else if (strcmp(token->value, "define") == 0)
-           {
-             if (!ParseTokenDefine(&i, &line))
-               return false;
-           }
-         else
-           {
-             if (!ParseTokenWord(entity, &i, &line))
-               return false;
-           }
-         break;
-       case TokenComment:
-         break;
-       case TokenSpace:
-         break;
-       case TokenEOL:
-         line++;
-         break;
-       default:
-         PARSE_ERR("syntax error 1", line);
-         return false;
-       }
+                               {
+                               case TokenWord:
+                                       if ( token->value == "include") 
+                                               {
+                                                       if 
(!ParseTokenInclude(&i, &line))
+                                                               return false;
+                                               }
+                                       else if ( token->value == "define" )
+                                               {
+                                                       if 
(!ParseTokenDefine(&i, &line))
+                                                               return false;
+                                               }
+                                       else
+                                               {
+                                                       if 
(!ParseTokenWord(entity, &i, &line))
+                                                               return false;
+                                               }
+                                       break;
+                               case TokenComment:
+                                       break;
+                               case TokenSpace:
+                                       break;
+                               case TokenEOL:
+                                       line++;
+                                       break;
+                               default:
+                                       PARSE_ERR("syntax error 1", line);
+                                       return false;
+                               }
     }
   return true;
 }
@@ -835,25 +804,25 @@
 {
   int i;
   CToken *token;
-
-  for (i = *index + 1; i < this->token_count; i++)
+       
+  for (i = *index + 1; i < (int)this->tokens.size(); i++)
     {
-      token = this->tokens + i;
-
+      token = &this->tokens[i];
+                       
       switch (token->type)
-       {
-       case TokenString:
-         break;
-       case TokenSpace:
-         break;
-       case TokenEOL:
-         *index = i;
-         (*line)++;
-         return true;
-       default:
-         PARSE_ERR("syntax error in include statement", *line);
-         return false;
-       }
+                               {
+                               case TokenString:
+                                       break;
+                               case TokenSpace:
+                                       break;
+                               case TokenEOL:
+                                       *index = i;
+                                       (*line)++;
+                                       return true;
+                               default:
+                                       PARSE_ERR("syntax error in include 
statement", *line);
+                                       return false;
+                               }
     }
   PARSE_ERR("incomplete include statement", *line);
   return false;
@@ -875,9 +844,9 @@
   entityname = NULL;
   starttoken = -1;
 
-  for (i = *index + 1; i < this->token_count; i++)
+  for (i = *index + 1; i < (int)this->tokens.size(); i++)
     {
-      token = this->tokens + i;
+      token = &this->tokens[i];
 
       switch (token->type)
        {
@@ -944,9 +913,9 @@
   int i;
   CToken *token;
 
-  for (i = *index + 1; i < this->token_count; i++)
+  for (i = *index + 1; i < (int)this->tokens.size(); i++)
     {
-      token = this->tokens + i;
+      token = &this->tokens[i];
 
       switch (token->type)
        {
@@ -978,27 +947,26 @@
 bool Worldfile::ParseTokenEntity(int entity, int *index, int *line)
 {
   int i;
-  int macro;
+  //int macro;
   int name;
   CToken *token;
 
   name = *index;
-  macro = LookupMacro(GetTokenValue(name));
+  CMacro* macro = LookupMacro(GetTokenValue(name));
 
   // If the entity name is a macro...
-  if (macro >= 0)
+  if (macro )
     {
-      // This is a bit of a hack
-      int nentity = this->entity_count;
-      int mindex = this->macros[macro].starttoken;
-      int mline = this->macros[macro].line;
+      int nentity = this->entities.size();
+      int mindex = macro->starttoken;
+      int mline = macro->line;
       if (!ParseTokenEntity(entity, &mindex, &mline))
-       return false;
+                               return false;
       entity = nentity;
 
-      for (i = *index + 1; i < this->token_count; i++)
-       {
-         token = this->tokens + i;
+      for (i = *index + 1; i < (int)this->tokens.size(); i++)
+                               {
+                                       token = &this->tokens[i];
 
          switch (token->type)
            {
@@ -1029,9 +997,9 @@
   // If the entity name is not a macro...
   else
     {
-      for (i = *index + 1; i < this->token_count; i++)
+      for (i = *index + 1; i < (int)this->tokens.size(); i++)
        {
-         token = this->tokens + i;
+         token = &this->tokens[i];
 
          switch (token->type)
            {
@@ -1076,9 +1044,9 @@
   value = -1;
   count = 0;
 
-  for (i = *index + 1; i < this->token_count; i++)
+  for (i = *index + 1; i < (int)this->tokens.size(); i++)
     {
-      token = this->tokens + i;
+      token = &this->tokens[i];
 
       switch (token->type)
        {
@@ -1113,14 +1081,14 @@
 // Parse a tuple.
 bool Worldfile::ParseTokenTuple( CProperty* property, int *index, int *line)
 {
-  int i, count;
+  unsigned int i, count;
   CToken *token;
 
   count = 0;
 
-  for (i = *index + 1; i < this->token_count; i++)
+  for (i = *index + 1; i < this->tokens.size(); i++)
     {
-      token = this->tokens + i;
+      token = &this->tokens[i];
 
       switch (token->type)
        {
@@ -1150,52 +1118,30 @@
 // Clear the macro list
 void Worldfile::ClearMacros()
 {
-  free(this->macros);
-  this->macros = NULL;
-  this->macro_size = 0;
-  this->macro_count = 0;
+       macros.clear();
 }
 
 
 ///////////////////////////////////////////////////////////////////////////
 // Add a macro
-int Worldfile::AddMacro(const char *macroname, const char *entityname,
-                       int line, int starttoken, int endtoken)
+void Worldfile::AddMacro(const char *macroname, const char *entityname,
+                                                                               
                 int line, int starttoken, int endtoken)
 {
-  if (this->macro_count >= this->macro_size)
-    {
-      this->macro_size += 100;
-      this->macros = (CMacro*)
-       realloc(this->macros, this->macro_size * sizeof(this->macros[0]));
-    }
-
-  int macro = this->macro_count;
-  this->macros[macro].macroname = macroname;
-  this->macros[macro].entityname = entityname;
-  this->macros[macro].line = line;
-  this->macros[macro].starttoken = starttoken;
-  this->macros[macro].endtoken = endtoken;
-  this->macro_count++;
-
-  return macro;
+       macros.insert( std::pair<std::string,CMacro>( macroname, CMacro( 
macroname, entityname, line, starttoken, endtoken )));
 }
 
 
 ///////////////////////////////////////////////////////////////////////////
 // Lookup a macro by name
 // Returns -1 if there is no macro with this name.
-int Worldfile::LookupMacro(const char *macroname)
+Worldfile::CMacro* Worldfile::LookupMacro(const char *macroname)
 {
-  int i;
-  CMacro *macro;
-
-  for (i = 0; i < this->macro_count; i++)
-    {
-      macro = this->macros + i;
-      if (strcmp(macro->macroname, macroname) == 0)
-       return i;
-    }
-  return -1;
+       std::map<std::string,CMacro>::iterator it = macros.find( macroname );
+       
+       if( it == macros.end() )
+               return NULL;
+       else
+               return &it->second;
 }
 
 
@@ -1204,11 +1150,13 @@
 void Worldfile::DumpMacros()
 {
   printf("\n## begin macros\n");
-  for (int i = 0; i < this->macro_count; i++)
+
+       FOR_EACH( it, macros )
+               //for (int i = 0; i < this->macro_count; i++)
     {
-      CMacro *macro = this->macros + i;
+      CMacro *macro = &(it->second);//this->macros + i;
 
-      printf("## [%s][%s]", macro->macroname, macro->entityname);
+                               printf("## [%s][%s]", macro->macroname.c_str(), 
macro->entityname.c_str());
       for (int j = macro->starttoken; j <= macro->endtoken; j++)
        {
          if (this->tokens[j].type == TokenEOL)
@@ -1226,10 +1174,12 @@
 // Clear the entity list
 void Worldfile::ClearEntities()
 {
-  free(this->entities);
-  this->entities = NULL;
-  this->entity_size = 0;
-  this->entity_count = 0;
+  // free(this->entities);
+  // this->entities = NULL;
+  // this->entity_size = 0;
+  // this->entity_count = 0;
+
+       this->entities.clear();
 }
 
 
@@ -1237,19 +1187,20 @@
 // Add a entity
 int Worldfile::AddEntity(int parent, const char *type)
 {
-  if (this->entity_count >= this->entity_size)
-    {
-      this->entity_size += 100;
-      this->entities = (CEntity*)
-       realloc(this->entities, this->entity_size * sizeof(this->entities[0]));
-    }
+  // if (this->entity_count >= this->entity_size)
+  //   {
+  //     this->entity_size += 100;
+  //     this->entities = (CEntity*)
+       // realloc(this->entities, this->entity_size * 
sizeof(this->entities[0]));
+  //   }
 
-  int entity = this->entity_count;
-  this->entities[entity].parent = parent;
-  this->entities[entity].type = type;
-  this->entity_count++;
+  // int entity = this->entity_count;
+  // this->entities[entity].parent = parent;
+  // this->entities[entity].type = type;
+  // this->entity_count++;
 
-  return entity;
+       this->entities.push_back( CEntity( parent, type ));
+  return( entities.size()-1); // index of the new entity
 }
 
 
@@ -1257,7 +1208,7 @@
 // Get the number of entities
 int Worldfile::GetEntityCount()
 {
-  return this->entity_count;
+  return this->entities.size();
 }
 
 
@@ -1265,7 +1216,7 @@
 // Get a entity's parent entity
 int Worldfile::GetEntityParent(int entity)
 {
-  if (entity < 0 || entity >= this->entity_count)
+  if (entity < 0 || entity >= (int)this->entities.size())
     return -1;
   return this->entities[entity].parent;
 }
@@ -1275,9 +1226,9 @@
 // Get a entity (returns the entity type value)
 const char *Worldfile::GetEntityType(int entity)
 {
-  if (entity < 0 || entity >= this->entity_count)
+  if (entity < 0 || entity >= (int)this->entities.size())
     return NULL;
-  return this->entities[entity].type;
+  return this->entities[entity].type.c_str();
 }
 
 
@@ -1298,7 +1249,7 @@
 void PrintProp( const char* key, CProperty* prop )
 {
   if( prop )
-    printf( "Print key %s prop ent %d name %s\n", key, prop->entity, 
prop->name );
+    printf( "Print key %s prop ent %d name %s\n", key, prop->entity, 
prop->name.c_str() );
 }
 
 ///////////////////////////////////////////////////////////////////////////
@@ -1307,7 +1258,7 @@
 {
   printf("\n## begin entities\n");
 
-       FOR_EACH( it, nametable )
+       FOR_EACH( it, properties )
                PrintProp( it->first.c_str(), it->second );
 
   printf("## end entities\n");
@@ -1318,9 +1269,9 @@
 // Clear the property list
 void Worldfile::ClearProperties()
 {
-  this->property_count = 0;
-
-       nametable.clear();
+       FOR_EACH( it, properties )
+               delete it->second;      
+       properties.clear();
 }
 
 
@@ -1328,27 +1279,14 @@
 // Add an property
 CProperty* Worldfile::AddProperty(int entity, const char *name, int line)
 {
-  //int i;
-  CProperty *property = new CProperty();
-
-  property->entity = entity;
-  property->name = name;
-  property->value_count = 0;
-  property->values = NULL;
-  property->line = line;
-  property->used = false;
-
   char key[128];
   snprintf( key, 127, "%d%s", entity, name );
-  property->key = strdup( key );
 
-       nametable[ property->key ] = property;
+  CProperty *property = new CProperty( entity, name, line );
 
-  //printf( "added key %s for prop %p entity %d name %s\n", property->key, 
property, property->entity, property->name );
+       properties[ key ] = property;
 
-  this->property_count++;
-
-  return property;
+       return property;
 }
 
 
@@ -1358,14 +1296,11 @@
 {
   assert(property);
 
-  // Expand the array if it's too small
-  if (index >= property->value_count)
-    {
-      property->value_count = index + 1;
-      property->values = (int*) realloc(property->values, 
property->value_count * sizeof(int));
-    }
-
   // Set the relevant value
+       
+       if( index >= (int)property->values.size() )
+               property->values.resize( index+1 );
+
   property->values[index] = value_token;
 }
 
@@ -1380,9 +1315,9 @@
        
   //printf( "looking up key %s for entity %d name %s\n", key, entity, name );
        
-       std::map<std::string,CProperty*>::iterator it = nametable.find( key );
+       std::map<std::string,CProperty*>::iterator it = properties.find( key );
        
-       if( it == nametable.end() ) // not found
+       if( it == properties.end() ) // not found
                return NULL;
        else
                return it->second;
@@ -1403,8 +1338,7 @@
   //  printf( "property %s index %d value_count %d \n",
   //  property->key, index, property->value_count );
 
-  assert(index >= 0 && index < property->value_count);
-
+  assert(index >= 0 && index < (int)property->values.size() );
   // Set the relevant value
   SetTokenValue( property->values[index], value);
 }

Modified: code/stage/trunk/libstage/worldfile.hh
===================================================================
--- code/stage/trunk/libstage/worldfile.hh      2009-09-08 02:03:53 UTC (rev 
8254)
+++ code/stage/trunk/libstage/worldfile.hh      2009-09-08 06:48:32 UTC (rev 
8255)
@@ -19,7 +19,7 @@
  */
 /*
  * Desc: A class for reading in the world file.
- * Author: Andrew Howard
+ * Author: Andrew Howard, Richard Vaughan
  * Date: 15 Nov 2001
  * CVS info: $Id$
  */
@@ -33,26 +33,31 @@
 
 namespace Stg {
 
-  // Private property class
-struct CProperty
+  /// Private property class
+class CProperty
   {
-    // Index of entity this property belongs to
+       public:
+    /// Index of entity this property belongs to
     int entity;
 
-    // Name of property
-    const char *name;
-
-    char* key; // this property's map key
+    /// Name of property
+               std::string name;
     
-    // A list of token indexes
-    int value_count;
-    int *values;
+    /// A list of token indexes
+               std::vector<int> values;
 
-    // Line this property came from
+    /// Line this property came from
     int line;
 
-    // Flag set if property has been used
+    /// Flag set if property has been used
     bool used;
+               
+               CProperty( int entity, const char* name, int line ) :
+                       entity(entity), 
+                       name(name),
+                       values(),
+                       line(line),
+                       used(false) {}
   };
 
 
@@ -219,13 +224,15 @@
   private: void ClearMacros();
 
   // Add a macro
-  private: int AddMacro(const char *macroname, const char *entityname,
+  private: void AddMacro(const char *macroname, const char *entityname,
                         int line, int starttoken, int endtoken);
 
   // Lookup a macro by name
-  // Returns -1 if there is no macro with this name.
-  private: int LookupMacro(const char *macroname);
 
+  // Returns a pointer to a macro with this name, or NULL if there is none..
+       class CMacro;
+  private: CMacro* LookupMacro(const char *macroname);
+
   // Dump the macro list for debugging
   private: void DumpMacros();
 
@@ -285,10 +292,11 @@
     TokenOpenTuple, TokenCloseTuple,
     TokenSpace, TokenEOL
   };
-
+       
   // Token structure.
-  private: struct CToken
+private: class CToken
   {
+       public:
     // Non-zero if token is from an include file.
     int include;
     
@@ -296,65 +304,73 @@
     int type;
 
     // Token value
-    char *value;
+               std::string value;
+
+               CToken( int include, int type, const char* value ) :
+                       include(include), type(type), value(value) {}
   };
 
   // A list of tokens loaded from the file.
   // Modified values are written back into the token list.
-  private: int token_size, token_count;
-  private: CToken *tokens;
+       //private: int token_size, token_count;
+private: std::vector<CToken> tokens;
 
   // Private macro class
-  private: struct CMacro
+private: class CMacro
   {
+       public:
     // Name of macro
-    const char *macroname;
+               std::string macroname;
 
     // Name of entity
-    const char *entityname;
+               std::string entityname;
 
     // Line the macro definition starts on.
     int line;
     
     // Range of tokens in the body of the macro definition.
     int starttoken, endtoken;
+
+               CMacro(const char *macroname, const char *entityname,
+                                        int line, int starttoken, int 
endtoken) :
+                       macroname(macroname),
+                       entityname(entityname),
+                       line(line),
+                       starttoken(starttoken),
+                       endtoken(endtoken) {}
   };
-
-  // Macro list
-  private: int macro_size;
-  private: int macro_count;
-  private: CMacro *macros;
+       
+  // Macro table
+  private: std::map<std::string,CMacro> macros;
   
   // Private entity class
-  private: struct CEntity
+  private: class CEntity
   {
+       public:
     // Parent entity
     int parent;
 
     // Type of entity (i.e. position, laser, etc).
-    const char *type;
+               std::string type;
+
+               CEntity( int parent, const char* type ) : parent(parent), 
type(type) {} 
   };
-
+       
   // Entity list
-  private: int entity_size;
-  private: int entity_count;
-  private: CEntity *entities;
-
+private: std::vector<CEntity> entities;
+       
   // Property list
-  private: int property_count;
-  
-  private: CProperty *properties;
-  
+private: std::map<std::string,CProperty*> properties;  
+       
   // Name of the file we loaded
-  public: char *filename;
-
+public: char *filename;
+       
   // Conversion units
-  public: double unit_length;
-  public: double unit_angle;
+public: double unit_length;
+public: double unit_angle;
        
-private: std::map<std::string,CProperty*> nametable;   
 };
-
+       
 };
 
 #endif

Modified: code/stage/trunk/libstage/worldgui.cc
===================================================================
--- code/stage/trunk/libstage/worldgui.cc       2009-09-08 02:03:53 UTC (rev 
8254)
+++ code/stage/trunk/libstage/worldgui.cc       2009-09-08 06:48:32 UTC (rev 
8255)
@@ -284,7 +284,9 @@
                
                // configure the canvas
                canvas->Load(  wf, window_section );
-               
+               // warn about unused WF lines
+               wf->WarnUnused();
+  
                std::string title = PROJECT;
                if ( wf->filename ) {
                  // improve the title bar to say "Stage: <worldfile name>"

Modified: code/stage/trunk/worlds/benchmark/cave.world
===================================================================
--- code/stage/trunk/worlds/benchmark/cave.world        2009-09-08 02:03:53 UTC 
(rev 8254)
+++ code/stage/trunk/worlds/benchmark/cave.world        2009-09-08 06:48:32 UTC 
(rev 8255)
@@ -126,7 +126,7 @@
 darkredrob( pose [-7.571 1.112 0 1.397] )
 darkredrob( pose [-6.028 1.220 0 32.866] )
 darkredrob( pose [-4.509 0.635 0 4.689] )
-darkredrob( pose [-7.549 -0.240 0 1.000 1.423] )
+darkredrob( pose [-7.549 -0.240 0 1.423] )
 darkredrob( pose [-6.728 0.180 0 -22.542] )
 darkredrob( pose [-6.824 0.826 0 -11.285] )
 darkredrob( pose [-5.963 0.335 0 -42.474] )

Modified: code/stage/trunk/worlds/fasr.world
===================================================================
--- code/stage/trunk/worlds/fasr.world  2009-09-08 02:03:53 UTC (rev 8254)
+++ code/stage/trunk/worlds/fasr.world  2009-09-08 06:48:32 UTC (rev 8255)
@@ -101,7 +101,7 @@
  joules 100000 
  joules_capacity 400000 
  fiducial_return 0
- charging_bump( fiducial( range 3 pose [ 0 0 -0.100 0 ] ) )
+ charging_bump( fiducial( range_max 3 pose [ 0 0 -0.100 0 ] ) )
 )
 
 autorob( pose [7.062 -1.563 0 152.684] joules 300000 name "r0" )

Modified: code/stage/trunk/worlds/pioneer.inc
===================================================================
--- code/stage/trunk/worlds/pioneer.inc 2009-09-08 02:03:53 UTC (rev 8254)
+++ code/stage/trunk/worlds/pioneer.inc 2009-09-08 06:48:32 UTC (rev 8255)
@@ -124,7 +124,7 @@
   obstacle_return 1            # Can hit things.
   laser_return 1                 # reflects laser beams
   ranger_return 1              # reflects sonar beams
-  blobfinder_return 1          # Seen by blobfinders  
+  blob_return 1                # Seen by blobfinders  
   fiducial_return 1            # Seen as "1" fiducial finders
 
   localization "gps"             

Modified: code/stage/trunk/worlds/sick.inc
===================================================================
--- code/stage/trunk/worlds/sick.inc    2009-09-08 02:03:53 UTC (rev 8254)
+++ code/stage/trunk/worlds/sick.inc    2009-09-08 06:48:32 UTC (rev 8255)
@@ -3,7 +3,6 @@
 (
   # laser-specific properties
   # factory settings for LMS200        
-  range_min 0.0
   range_max 8.0
   fov 180.0
   samples 361

Modified: code/stage/trunk/worlds/simple.world
===================================================================
--- code/stage/trunk/worlds/simple.world        2009-09-08 02:03:53 UTC (rev 
8254)
+++ code/stage/trunk/worlds/simple.world        2009-09-08 06:48:32 UTC (rev 
8255)
@@ -6,13 +6,10 @@
 include "map.inc"
 include "sick.inc"
 
-interval_sim 100  # simulation timestep in milliseconds
-interval_real 20  # real-time interval between simulation updates in 
milliseconds 
-
 # time to pause (in GUI mode) or quit (in headless mode (-g)) the simulation
 quit_time 3600 # 1 hour of simulated time
 
-paused 0
+paused 1
 
 resolution 0.02
 
@@ -21,7 +18,7 @@
 (
   size [ 635.000 666.000 ] # in pixels
   scale 37.481            
-     # pixels per meter
+     # pixels per meteri
   center [ -0.019  -0.282 ]
   rotate [ 0  0 ]
                        


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit

Reply via email to