Revision: 8256
          http://playerstage.svn.sourceforge.net/playerstage/?rev=8256&view=rev
Author:   rtv
Date:     2009-09-09 22:25:27 +0000 (Wed, 09 Sep 2009)

Log Message:
-----------
controllers now get their worldfile argument string

Modified Paths:
--------------
    code/stage/trunk/examples/ctrl/fasr.cc
    code/stage/trunk/examples/ctrl/wander.cc
    code/stage/trunk/libstage/blockgroup.cc
    code/stage/trunk/libstage/model_load.cc
    code/stage/trunk/libstage/stage.hh
    code/stage/trunk/libstage/worldfile.cc
    code/stage/trunk/libstage/worldfile.hh
    code/stage/trunk/libstage/worldgui.cc

Modified: code/stage/trunk/examples/ctrl/fasr.cc
===================================================================
--- code/stage/trunk/examples/ctrl/fasr.cc      2009-09-08 06:48:32 UTC (rev 
8255)
+++ code/stage/trunk/examples/ctrl/fasr.cc      2009-09-09 22:25:27 UTC (rev 
8256)
@@ -493,7 +493,7 @@
 };
 
 // Stage calls this when the model starts up
-extern "C" int Init( Model* mod )
+extern "C" int Init( Model* mod, char* str )
 {  
 #if 1          
   // example using the model rasterizer

Modified: code/stage/trunk/examples/ctrl/wander.cc
===================================================================
--- code/stage/trunk/examples/ctrl/wander.cc    2009-09-08 06:48:32 UTC (rev 
8255)
+++ code/stage/trunk/examples/ctrl/wander.cc    2009-09-09 22:25:27 UTC (rev 
8256)
@@ -20,8 +20,14 @@
 int PositionUpdate( Model* mod, robot_t* robot );
 
 // Stage calls this when the model starts up
-extern "C" int Init( Model* mod )
+extern "C" int Init( Model* mod, char* argstr )
 {
+  // local arguments
+  printf( "\nWander controller initialised with argument string \"%s\"", 
argstr );
+  // global arguments
+  for( unsigned int i=0; i< World::args.size(); i++ )
+        printf( "\nWorld argument %d is %s", i, World::args[i].c_str() );
+
   robot_t* robot = new robot_t;
  
   robot->avoidcount = 0;
@@ -34,8 +40,6 @@
   robot->laser->Subscribe(); // starts the laser updates
   robot->pos->Subscribe(); // starts the position updates
   
-  for( unsigned int i=0; i< World::args.size(); i++ )
-        printf( "\nargument %d is %s", i, World::args[i].c_str() );
   
   return 0; //ok
 }

Modified: code/stage/trunk/libstage/blockgroup.cc
===================================================================
--- code/stage/trunk/libstage/blockgroup.cc     2009-09-08 06:48:32 UTC (rev 
8255)
+++ code/stage/trunk/libstage/blockgroup.cc     2009-09-09 22:25:27 UTC (rev 
8256)
@@ -258,7 +258,7 @@
        strcpy( full, bitmapfile );
   else
        {
-         char *tmp = strdup(wf->filename);
+         char *tmp = strdup(wf->filename.c_str());
          snprintf( full, _POSIX_PATH_MAX,
                                "%s/%s",  dirname(tmp), bitmapfile );
          free(tmp);

Modified: code/stage/trunk/libstage/model_load.cc
===================================================================
--- code/stage/trunk/libstage/model_load.cc     2009-09-08 06:48:32 UTC (rev 
8255)
+++ code/stage/trunk/libstage/model_load.cc     2009-09-09 22:25:27 UTC (rev 
8256)
@@ -73,39 +73,39 @@
   
   //PRINT_WARN1( "%s::Load", token );
   
-  //if( wf->PropertyExists( wf_entity, "origin" ) )
+  if( wf->PropertyExists( wf_entity, "origin" ) )
+        {
+               Geom geom = GetGeom();
+               geom.pose.Load( wf, wf_entity, "origin" );
+               SetGeom( geom );
+        }
+
+  if( wf->PropertyExists( wf_entity, "size" ) )
     {
       Geom geom = GetGeom();
-                       geom.pose.Load( wf, wf_entity, "origin" );
-      SetGeom( geom );
-    }
-               
-               //if( wf->PropertyExists( wf_entity, "size" ) )
-    {
-      Geom geom = GetGeom();
                        geom.size.Load( wf, wf_entity, "size" );
       SetGeom( geom );
     }
                
-               //if( wf->PropertyExists( wf_entity, "pose" ))
+  if( wf->PropertyExists( wf_entity, "pose" ))
     {
       Pose pose = GetPose();
-                       pose.Load( wf, wf_entity, "pose" );
+               pose.Load( wf, wf_entity, "pose" );
       SetPose( pose );
     }
-               
-               //if( wf->PropertyExists( wf_entity, "velocity" ))
+  
+  if( wf->PropertyExists( wf_entity, "velocity" ))
     {
       Velocity vel = GetVelocity();
-                       vel.Load( wf, wf_entity, "velocity" );
+               vel.Load( wf, wf_entity, "velocity" );
       SetVelocity( vel );
     }
-               
-               if( wf->PropertyExists( wf_entity, "color" ))
-                       {      
-                               Color col( 1,0,0 ); // red;
-                               const char* colorstr = wf->ReadString( 
wf_entity, "color", NULL );
-                               if( colorstr )
+  
+  if( wf->PropertyExists( wf_entity, "color" ))
+        {      
+               Color col( 1,0,0 ); // red;
+               const char* colorstr = wf->ReadString( wf_entity, "color", NULL 
);
+               if( colorstr )
                                        {
                                                if( strcmp( colorstr, "random" 
) == 0 )
                                                        col = Color( drand48(), 
drand48(), drand48() );
@@ -207,9 +207,6 @@
   if( wf->PropertyExists( wf_entity, "ctrl" ))
     {
       char* lib = (char*)wf->ReadString(wf_entity, "ctrl", NULL );
-
-      //char* argstr = (char*)wf->ReadString(wf_entity, "ctrl_argstr", NULL );
-
                
       if( !lib )
                  printf( "Error - NULL library name specified for model %s\n", 
token );
@@ -305,8 +302,12 @@
   lt_dlsetsearchpath( FileManager::stagePath().c_str() );
 
   lt_dlhandle handle = NULL;
-
-  if(( handle = lt_dlopenext( lib ) ))
+  
+  // the library name is the first word in the string
+  char libname[256];
+  sscanf( lib, "%s %*s", libname );
+  
+  if(( handle = lt_dlopenext( libname ) ))
     {
       //printf( "]" );
                
@@ -320,7 +321,7 @@
                         exit(-1);
                  }
                //else
-               AddCallback( &hooks.init, initfunc, NULL );
+               AddCallback( &hooks.init, initfunc, lib ); // pass complete 
string into initfunc
     }
   else
     {

Modified: code/stage/trunk/libstage/stage.hh
===================================================================
--- code/stage/trunk/libstage/stage.hh  2009-09-08 06:48:32 UTC (rev 8255)
+++ code/stage/trunk/libstage/stage.hh  2009-09-09 22:25:27 UTC (rev 8256)
@@ -1713,7 +1713,6 @@
   
         /** unique process-wide identifier for this model */
         uint32_t id;   
-        //      ctrlinit_t* initfunc;
         stg_usec_t interval; ///< time between updates in usec  
         stg_usec_t interval_energy; ///< time between updates of powerpack in 
usec
         stg_usec_t interval_pose; ///< time between updates of pose due to 
velocity in usec

Modified: code/stage/trunk/libstage/worldfile.cc
===================================================================
--- code/stage/trunk/libstage/worldfile.cc      2009-09-08 06:48:32 UTC (rev 
8255)
+++ code/stage/trunk/libstage/worldfile.cc      2009-09-09 22:25:27 UTC (rev 
8256)
@@ -1,6 +1,6 @@
 /*
  *  Stage : a multi-robot simulator.
- *  Copyright (C) 2001, 2002 Richard Vaughan, Andrew Howard and Brian Gerkey.
+ *  Copyright (C) 2001-2009 Richard Vaughan, Andrew Howard and Brian Gerkey.
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -53,9 +53,9 @@
 ///////////////////////////////////////////////////////////////////////////
 // Useful macros for dumping parser errors
 #define TOKEN_ERR(z, l)                                \
-  PRINT_ERR2("%s:%d : " z, this->filename, l)
+  PRINT_ERR2("%s:%d : " z, this->filename.c_str(), l)
 #define PARSE_ERR(z, l)                                \
-  PRINT_ERR2("%s:%d : " z, this->filename, l)
+  PRINT_ERR2("%s:%d : " z, this->filename.c_str(), l)
 
 
 ///////////////////////////////////////////////////////////////////////////
@@ -65,7 +65,7 @@
   macros(),
   entities(),
        properties(),
-  filename( NULL),
+  filename(),
   unit_length( 1.0 ),
   unit_angle( M_PI / 180.0 )
 {
@@ -80,9 +80,6 @@
   ClearMacros();
   ClearEntities();
   ClearTokens();
-
-  if (this->filename)
-    free(this->filename);
 }
 
 FILE *Worldfile::FileOpen(const char *filename, const char* method)
@@ -125,22 +122,15 @@
 // Load world from file
 bool Worldfile::Load(const char *filename)
 {
-  // Shouldnt call load more than once,
-  // so this should be null.
+  this->filename = filename;
 
-  if(this->filename == NULL)
-    {
-      this->filename = strdup(filename);
-    }
-
-
   // Open the file
   //FILE *file = fopen(this->filename, "r");
-  FILE *file = FileOpen(this->filename, "r");
+  FILE *file = FileOpen(this->filename.c_str(), "r");
   if (!file)
     {
       PRINT_ERR2("unable to open world file %s : %s",
-                this->filename, strerror(errno));
+                                         this->filename.c_str(), 
strerror(errno));
       return false;
     }
 
@@ -203,7 +193,7 @@
 
   // If no filename is supplied, use default
   if (!filename)
-    filename = this->filename;
+    filename = this->filename.c_str();
 
   // Open file
   FILE *file = fopen(filename, "w+");
@@ -240,7 +230,7 @@
                        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());
+                                                                       
this->filename.c_str(), it->second->line, it->second->name.c_str());
                                        unused = true;
                                }
                }
@@ -481,7 +471,7 @@
       // Note that dirname() modifies the contents, so
       // we need to make a copy of the filename.
       // There's no bounds-checking, but what the heck.
-      char *tmp = strdup(this->filename);
+      char *tmp = strdup(this->filename.c_str());
       fullpath = new char[PATH_MAX];
       memset(fullpath, 0, PATH_MAX);
       strcat( fullpath, dirname(tmp));
@@ -495,7 +485,7 @@
       // Note that dirname() modifies the contents, so
       // we need to make a copy of the filename.
       // There's no bounds-checking, but what the heck.
-      char *tmp = strdup(this->filename);
+      char *tmp = strdup(this->filename.c_str());
       fullpath = new char[PATH_MAX];
       char* dummy = getcwd(fullpath, PATH_MAX);
       if (!dummy)
@@ -1312,21 +1302,31 @@
 {
   char key[128];
   snprintf( key, 127, "%d%s", entity, name );
-       
+  
   //printf( "looking up key %s for entity %d name %s\n", key, entity, name );
+  
+  static char cache_key[128] = { 0 }; 
+  static CProperty* cache_property = NULL;
+  
+  if( strncmp( key, cache_key, 128 ) != 0 ) // different to last time
+        {              
+               strncpy( cache_key, key, 128 ); // remember for next time       
        
+               
+               std::map<std::string,CProperty*>::iterator it = 
properties.find( key ); 
+               if( it == properties.end() ) // not found
+                 cache_property = NULL;
+               else
+                 cache_property = it->second;          
+        }
+  //else
+  // printf( "cache hit with %s\n", cache_key );
        
-       std::map<std::string,CProperty*>::iterator it = properties.find( key );
-       
-       if( it == properties.end() ) // not found
-               return NULL;
-       else
-               return it->second;
-       }
+  return cache_property;
+}
 
-
 bool Worldfile::PropertyExists( int section, const char* token )
 {
-  return( this->GetProperty( section, token ) ? true : false );
+  return (bool)GetProperty( section, token );
 }
 
 
@@ -1343,7 +1343,6 @@
   SetTokenValue( property->values[index], value);
 }
 
-
 ///////////////////////////////////////////////////////////////////////////
 // Get the value of an property
 const char *Worldfile::GetPropertyValue(CProperty* property, int index)
@@ -1482,46 +1481,7 @@
   return atof(GetPropertyValue(property, 0)) * this->unit_angle;
 }
 
-/* REMOVE?
 ///////////////////////////////////////////////////////////////////////////
-// Read a boolean
-bool Worldfile::ReadBool(int entity, const char *name, bool value)
-{
-//return (bool) ReadInt(entity, name, value);
-CProperty* property = GetProperty(entity, name);
-if (property < 0)
-return value;
-const char *v = GetPropertyValue(property, 0);
-if (strcmp(v, "true") == 0 || strcmp(v, "yes") == 0)
-return true;
-else if (strcmp(v, "false") == 0 || strcmp(v, "no") == 0)
-return false;
-CProperty *pproperty = this->properties + property;
-PRINT_WARN3("worldfile %s:%d : '%s' is not a valid boolean value; assuming 
'false'",
-this->filename, pproperty->line, v);
-return false;
-}
-*/
-
- ///////////////////////////////////////////////////////////////////////////
- // Read a color (included text -> RGB conversion).
- // We look up the color in one of the common color databases.
-// uint32_t Worldfile::ReadColor(int entity, const char *name, uint32_t value)
-// {
-//   CProperty* property;
-//   const char *color;
-
-//   property = GetProperty(entity, name);
-//   if (property == NULL )
-//     return value;
-//   color = GetPropertyValue(property, 0);
-
-//   // TODO: Hmmm, should do something with the default color here.
-//   return stg_lookup_color(color);
-// }
-
-
-///////////////////////////////////////////////////////////////////////////
 // Read a file name
 // Always returns an absolute path.
 // If the filename is entered as a relative path, we prepend
@@ -1543,7 +1503,7 @@
       // Note that dirname() modifies the contents, so
       // we need to make a copy of the filename.
       // There's no bounds-checking, but what the heck.
-      char *tmp = strdup(this->filename);
+      char *tmp = strdup(this->filename.c_str());
                char* fullpath = new char[PATH_MAX];
       memset(fullpath, 0, PATH_MAX);
       strcat( fullpath, dirname(tmp));
@@ -1559,7 +1519,7 @@
       // Note that dirname() modifies the contents, so
       // we need to make a copy of the filename.
       // There's no bounds-checking, but what the heck.
-      char *tmp = strdup(this->filename);
+      char *tmp = strdup(this->filename.c_str());
                char* fullpath = new char[PATH_MAX];
       char* dummy = getcwd(fullpath, PATH_MAX);
       if (!dummy)

Modified: code/stage/trunk/libstage/worldfile.hh
===================================================================
--- code/stage/trunk/libstage/worldfile.hh      2009-09-08 06:48:32 UTC (rev 
8255)
+++ code/stage/trunk/libstage/worldfile.hh      2009-09-09 22:25:27 UTC (rev 
8256)
@@ -33,18 +33,18 @@
 
 namespace Stg {
 
-  /// Private property class
-class CProperty
+  /// Property class
+  class CProperty
   {
-       public:
+  public:
     /// Index of entity this property belongs to
     int entity;
 
     /// Name of property
-               std::string name;
+        std::string name;
     
     /// A list of token indexes
-               std::vector<int> values;
+        std::vector<int> values;
 
     /// Line this property came from
     int line;
@@ -52,325 +52,328 @@
     /// 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) {}
+        CProperty( int entity, const char* name, int line ) :
+               entity(entity), 
+               name(name),
+               values(),
+               line(line),
+               used(false) {}
   };
 
 
-// Class for loading/saving world file.  This class hides the syntax
-// of the world file and provides an 'entity.property = value' style
-// interface.  Global settings go in entity 0; every other entity
-// refers to a specific entity.  Parent/child relationships are
-// encoded in the form of entity/subentity relationships.
-class Worldfile
-{
-  // Standard constructors/destructors
-public: Worldfile();
-public: ~Worldfile();
+  // Class for loading/saving world file.  This class hides the syntax
+  // of the world file and provides an 'entity.property = value' style
+  // interface.  Global settings go in entity 0; every other entity
+  // refers to a specific entity.  Parent/child relationships are
+  // encoded in the form of entity/subentity relationships.
+  class Worldfile
+  {
+        // Standard constructors/destructors
+  public: Worldfile();
+  public: ~Worldfile();
 
-  // replacement for fopen() that checks STAGEPATH dirs for the named file
-  // (thanks to  Douglas S. Blank <dbl...@brynmawr.edu>)
-protected: FILE* FileOpen(const char *filename, const char* method);
+        // replacement for fopen() that checks STAGEPATH dirs for the named 
file
+        // (thanks to  Douglas S. Blank <dbl...@brynmawr.edu>)
+  protected: FILE* FileOpen(const char *filename, const char* method);
 
-  // Load world from file
+        // Load world from file
   public: bool Load(const char *filename);
 
-  // Save world back into file
-  // Set filename to NULL to save back into the original file
+        // Save world back into file
+        // Set filename to NULL to save back into the original file
   public: bool Save(const char *filename);
 
-  // Check for unused properties and print warnings
+        // Check for unused properties and print warnings
   public: bool WarnUnused();
 
-  // Read a string
+        // Read a string
   public: const char *ReadString(int entity, const char *name, const char 
*value);
 
-  // Write a string
+        // Write a string
   public: void WriteString(int entity, const char *name, const char *value);
 
-  // Read an integer 
+        // Read an integer 
   public: int ReadInt(int entity, const char *name, int value);
 
-  // Write an integer
+        // Write an integer
   public: void WriteInt(int entity, const char *name, int value);
 
-  // Read a float 
+        // Read a float 
   public: double ReadFloat(int entity, const char *name, double value);
 
-  // Write a float
+        // Write a float
   public: void WriteFloat(int entity, const char *name, double value);
 
-  // Read a length (includes unit conversion)
+        // Read a length (includes unit conversion)
   public: double ReadLength(int entity, const char *name, double value);
 
-  // Write a length (includes units conversion)
+        // Write a length (includes units conversion)
   public: void WriteLength(int entity, const char *name, double value);
   
-  // Read an angle (includes unit conversion)
+        // Read an angle (includes unit conversion)
   public: double ReadAngle(int entity, const char *name, double value);
 
-  // Read a boolean
-  // REMOVE? public: bool ReadBool(int entity, const char *name, bool value);
+        // Read a boolean
+        // REMOVE? public: bool ReadBool(int entity, const char *name, bool 
value);
 
-  // Read a color (includes text to RGB conversion)
+        // Read a color (includes text to RGB conversion)
   public: uint32_t ReadColor(int entity, const char *name, uint32_t value);
 
-  // Read a file name.  Always returns an absolute path.  If the
-  // filename is entered as a relative path, we prepend the world
-  // files path to it.
+        // Read a file name.  Always returns an absolute path.  If the
+        // filename is entered as a relative path, we prepend the world
+        // files path to it.
   public: const char *ReadFilename(int entity, const char *name, const char 
*value);
   
-  // Read a string from a tuple
+        // Read a string from a tuple
   public: const char *ReadTupleString(int entity, const char *name,
                                       int index, const char *value);
   
-  // Write a string to a tuple
+        // Write a string to a tuple
   public: void WriteTupleString(int entity, const char *name,
                                 int index, const char *value);
   
-  // Read a float from a tuple
+        // Read a float from a tuple
   public: double ReadTupleFloat(int entity, const char *name,
                                 int index, double value);
 
-  // Write a float to a tuple
+        // Write a float to a tuple
   public: void WriteTupleFloat(int entity, const char *name,
                                int index, double value);
 
-  // Read a length from a tuple (includes units conversion)
+        // Read a length from a tuple (includes units conversion)
   public: double ReadTupleLength(int entity, const char *name,
                                  int index, double value);
 
-  // Write a to a tuple length (includes units conversion)
+        // Write a to a tuple length (includes units conversion)
   public: void WriteTupleLength(int entity, const char *name,
                                 int index, double value);
 
-  // Read an angle form a tuple (includes units conversion)
+        // Read an angle form a tuple (includes units conversion)
   public: double ReadTupleAngle(int entity, const char *name,
                                 int index, double value);
 
-  // Write an angle to a tuple (includes units conversion)
+        // Write an angle to a tuple (includes units conversion)
   public: void WriteTupleAngle(int entity, const char *name,
                                int index, double value);
 
 
-  ////////////////////////////////////////////////////////////////////////////
-  // Private methods used to load stuff from the world file
+        
////////////////////////////////////////////////////////////////////////////
+        // Private methods used to load stuff from the world file
   
-  // Load tokens from a file.
+        // Load tokens from a file.
   private: bool LoadTokens(FILE *file, int include);
 
-  // Read in a comment token
+        // Read in a comment token
   private: bool LoadTokenComment(FILE *file, int *line, int include);
 
-  // Read in a word token
+        // Read in a word token
   private: bool LoadTokenWord(FILE *file, int *line, int include);
 
-  // Load an include token; this will load the include file.
+        // Load an include token; this will load the include file.
   private: bool LoadTokenInclude(FILE *file, int *line, int include);
 
-  // Read in a number token
+        // Read in a number token
   private: bool LoadTokenNum(FILE *file, int *line, int include);
 
-  // Read in a string token
+        // Read in a string token
   private: bool LoadTokenString(FILE *file, int *line, int include);
 
-  // Read in a whitespace token
+        // Read in a whitespace token
   private: bool LoadTokenSpace(FILE *file, int *line, int include);
 
-  // Save tokens to a file.
+        // Save tokens to a file.
   private: bool SaveTokens(FILE *file);
 
-  // Clear the token list
+        // Clear the token list
   private: void ClearTokens();
 
-  // Add a token to the token list
+        // Add a token to the token list
   private: bool AddToken(int type, const char *value, int include);
 
-  // Set a token in the token list
+        // Set a token in the token list
   private: bool SetTokenValue(int index, const char *value);
 
-  // Get the value of a token
+        // Get the value of a token
   private: const char *GetTokenValue(int index);
 
-  // Dump the token list (for debugging).
+        // Dump the token list (for debugging).
   private: void DumpTokens();
 
-  // Parse a line
+        // Parse a line
   private: bool ParseTokens();
 
-  // Parse an include statement
+        // Parse an include statement
   private: bool ParseTokenInclude(int *index, int *line);
 
-  // Parse a macro definition
+        // Parse a macro definition
   private: bool ParseTokenDefine(int *index, int *line);
 
-  // Parse an word (could be a entity or an property) from the token list.
+        // Parse an word (could be a entity or an property) from the token 
list.
   private: bool ParseTokenWord(int entity, int *index, int *line);
 
-  // Parse a entity from the token list.
+        // Parse a entity from the token list.
   private: bool ParseTokenEntity(int entity, int *index, int *line);
 
-  // Parse an property from the token list.
+        // Parse an property from the token list.
   private: bool ParseTokenProperty(int entity, int *index, int *line);
 
-  // Parse a tuple.
+        // Parse a tuple.
   private: bool ParseTokenTuple( CProperty*  property, int *index, int *line);
 
-  // Clear the macro list
+        // Clear the macro list
   private: void ClearMacros();
 
-  // Add a macro
+        // Add a macro
   private: void AddMacro(const char *macroname, const char *entityname,
-                        int line, int starttoken, int endtoken);
+                                                                int line, int 
starttoken, int endtoken);
 
-  // Lookup a macro by name
+        // Lookup a macro by name
 
-  // Returns a pointer to a macro with this name, or NULL if there is none..
-       class CMacro;
+        // 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
+        // Dump the macro list for debugging
   private: void DumpMacros();
 
-  // Clear the entity list
+        // Clear the entity list
   private: void ClearEntities();
 
-  // Add a entity
+        // Add a entity
   private: int AddEntity(int parent, const char *type);
 
     // Get the number of entities.
   public: int GetEntityCount();
 
-  // Get a entity (returns the entity type value)
+        // Get a entity (returns the entity type value)
   public: const char *GetEntityType(int entity);
 
-  // Lookup a entity number by type name
-  // Returns -1 if there is entity with this type
+        // Lookup a entity number by type name
+        // Returns -1 if there is entity with this type
   public: int LookupEntity(const char *type);
   
-  // Get a entity's parent entity.
-  // Returns -1 if there is no parent.
+        // Get a entity's parent entity.
+        // Returns -1 if there is no parent.
   public: int GetEntityParent(int entity);
 
-  // Dump the entity list for debugging
+        // Dump the entity list for debugging
   private: void DumpEntities();
 
-  // Clear the property list
+        // Clear the property list
   private: void ClearProperties();
 
-  // Add an property
+        // Add an property
   private: CProperty* AddProperty(int entity, const char *name, int line);
-  // Add an property value.
+        // Add an property value.
   private: void AddPropertyValue( CProperty* property, int index, int 
value_token);
   
-  // Get an property
+        // Get an property
   public: CProperty* GetProperty(int entity, const char *name);
 
-  // returns true iff the property exists in the file, so that you can
-  // be sure that GetProperty() will work
-  bool PropertyExists( int section, const char* token );
+        // returns true iff the property exists in the file, so that you can
+        // be sure that GetProperty() will work
+        bool PropertyExists( int section, const char* token );
 
-  // Set the value of an property.
+        // Set the value of an property.
   private: void SetPropertyValue( CProperty* property, int index, const char 
*value);
 
-  // Get the value of an property.
+        // Get the value of an property.
   public: const char *GetPropertyValue( CProperty* property, int index);
 
-  // Dump the property list for debugging
+        // Dump the property list for debugging
   private: void DumpProperties();
 
-  // Token types.
+        // Token types.
   private: enum
-  {
-    TokenComment,
-    TokenWord, TokenNum, TokenString,
-    TokenOpenEntity, TokenCloseEntity,
-    TokenOpenTuple, TokenCloseTuple,
-    TokenSpace, TokenEOL
-  };
+        {
+               TokenComment,
+               TokenWord, TokenNum, TokenString,
+               TokenOpenEntity, TokenCloseEntity,
+               TokenOpenTuple, TokenCloseTuple,
+               TokenSpace, TokenEOL
+        };
        
-  // Token structure.
-private: class CToken
-  {
-       public:
-    // Non-zero if token is from an include file.
-    int include;
-    
-    // Token type (enumerated value).
-    int type;
-
-    // Token value
+        // Token structure.
+  private: 
+        class CToken
+        {
+        public:
+               // Non-zero if token is from an include file.
+               int include;
+               
+               // Token type (enumerated value).
+               int type;
+               
+               // Token value
                std::string value;
-
+               
                CToken( int include, int type, const char* value ) :
-                       include(include), type(type), value(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:  std::vector<CToken> tokens;
 
-  // A list of tokens loaded from the file.
-  // Modified values are written back into the token list.
-       //private: int token_size, token_count;
-private: std::vector<CToken> tokens;
-
-  // Private macro class
-private: class CMacro
-  {
-       public:
-    // Name of macro
+        // Private macro class
+  private: 
+        class CMacro
+        {
+        public:
+               // Name of macro
                std::string macroname;
-
-    // Name of entity
+               
+               // Name of entity
                std::string entityname;
-
-    // Line the macro definition starts on.
-    int line;
-    
-    // Range of tokens in the body of the macro definition.
-    int starttoken, endtoken;
-
+               
+               // 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 table
+                                int line, int starttoken, int endtoken) :
+                 macroname(macroname),
+                 entityname(entityname),
+                 line(line),
+                 starttoken(starttoken),
+                 endtoken(endtoken) {}
+        };
+        
+        // Macro table
   private: std::map<std::string,CMacro> macros;
-  
-  // Private entity class
-  private: class CEntity
-  {
-       public:
-    // Parent entity
-    int parent;
-
-    // Type of entity (i.e. position, laser, etc).
+        
+        // Private entity class
+  private: 
+        class CEntity
+        {
+        public:
+               // Parent entity
+               int parent;
+               
+               // Type of entity (i.e. position, laser, etc).
                std::string type;
-
+               
                CEntity( int parent, const char* type ) : parent(parent), 
type(type) {} 
+        };
+        
+        // Entity list
+  private: std::vector<CEntity> entities;
+        
+        // Property list
+  private: std::map<std::string,CProperty*> properties;        
+        
+        // Name of the file we loaded
+  public: std::string filename;
+        
+        // Conversion units
+  public: double unit_length;
+  public: double unit_angle;
+        
   };
        
-  // Entity list
-private: std::vector<CEntity> entities;
-       
-  // Property list
-private: std::map<std::string,CProperty*> properties;  
-       
-  // Name of the file we loaded
-public: char *filename;
-       
-  // Conversion units
-public: double unit_length;
-public: double unit_angle;
-       
 };
-       
-};
 
 #endif

Modified: code/stage/trunk/libstage/worldgui.cc
===================================================================
--- code/stage/trunk/libstage/worldgui.cc       2009-09-08 06:48:32 UTC (rev 
8255)
+++ code/stage/trunk/libstage/worldgui.cc       2009-09-09 22:25:27 UTC (rev 
8256)
@@ -288,7 +288,7 @@
                wf->WarnUnused();
   
                std::string title = PROJECT;
-               if ( wf->filename ) {
+               if ( wf->filename.size() ) {
                  // improve the title bar to say "Stage: <worldfile name>"
                  title += ": ";                
                  title += wf->filename;
@@ -763,7 +763,7 @@
   bool success = false;
   const char* pattern = "World Files (*.world)";
 
-  Fl_File_Chooser fc( wf->filename, pattern, Fl_File_Chooser::CREATE, "Save 
File As..." );
+  Fl_File_Chooser fc( wf->filename.c_str(), pattern, Fl_File_Chooser::CREATE, 
"Save File As..." );
   fc.ok_label( "Save" );
 
   fc.show();


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
Playerstage-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/playerstage-commit

Reply via email to