Revision: 8023
          http://playerstage.svn.sourceforge.net/playerstage/?rev=8023&view=rev
Author:   rtv
Date:     2009-07-15 04:11:49 +0000 (Wed, 15 Jul 2009)

Log Message:
-----------
added simple cmdline arg database. need to clean up startup to cope

Modified Paths:
--------------
    code/stage/trunk/examples/ctrl/wander.cc
    code/stage/trunk/libstage/main.cc
    code/stage/trunk/libstage/stage.cc
    code/stage/trunk/libstage/stage.hh

Modified: code/stage/trunk/examples/ctrl/wander.cc
===================================================================
--- code/stage/trunk/examples/ctrl/wander.cc    2009-07-15 03:59:24 UTC (rev 
8022)
+++ code/stage/trunk/examples/ctrl/wander.cc    2009-07-15 04:11:49 UTC (rev 
8023)
@@ -31,7 +31,10 @@
   robot->laser = (ModelLaser*)mod->GetModel( "laser:0" );
   robot->laser->AddUpdateCallback( (stg_model_callback_t)LaserUpdate, robot );
   robot->laser->Subscribe(); // starts the laser 
-
+  
+  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/main.cc
===================================================================
--- code/stage/trunk/libstage/main.cc   2009-07-15 03:59:24 UTC (rev 8022)
+++ code/stage/trunk/libstage/main.cc   2009-07-15 04:11:49 UTC (rev 8023)
@@ -27,6 +27,7 @@
        { "gui",  optional_argument,   NULL,  'g' },
        { "clock",  optional_argument,   NULL,  'c' },
        { "help",  optional_argument,   NULL,  'h' },
+       //   { "args", optional_argument, NULL, 'a' },
        { NULL, 0, NULL, 0 }
 };
 
@@ -56,15 +57,18 @@
                         usegui = false;
                         printf( "[GUI disabled]" );
                         break;
+//         case 'a':
+//                      printf( "[ignoring unrecognized arguments]" );
+//                      break;
                  case 'h':  
                  case '?':  
                         puts( USAGE );
-                        exit(0);
+                        //                      exit(0);
                         break;
                  default:
                         printf("unhandled option %c\n", ch );
                         puts( USAGE );
-                        exit(0);
+                        //exit(0);
                  }
         }
   

Modified: code/stage/trunk/libstage/stage.cc
===================================================================
--- code/stage/trunk/libstage/stage.cc  2009-07-15 03:59:24 UTC (rev 8022)
+++ code/stage/trunk/libstage/stage.cc  2009-07-15 04:11:49 UTC (rev 8023)
@@ -7,6 +7,9 @@
 #include "file_manager.hh"
 using namespace Stg;
 
+// static member - a vector command line arguments
+std::vector<std::string> World::args;
+
 static bool init_called = false;
 
 
@@ -18,6 +21,11 @@
 void Stg::Init( int* argc, char** argv[] )
 {
   PRINT_DEBUG( "Stg::Init()" );
+  
+  // copy the command line args for controllers to inspect
+  World::args.clear();
+  for( int i=0; i<*argc; i++ )
+        World::args.push_back( (*argv)[i] ); 
 
   // seed the RNG 
   srand48( time(NULL) );

Modified: code/stage/trunk/libstage/stage.hh
===================================================================
--- code/stage/trunk/libstage/stage.hh  2009-07-15 03:59:24 UTC (rev 8022)
+++ code/stage/trunk/libstage/stage.hh  2009-07-15 04:11:49 UTC (rev 8023)
@@ -829,6 +829,11 @@
     friend class ModelFiducial;
     friend class Canvas;
 
+  public: 
+        /** contains the command line arguments passed to Stg::Init(), so
+                 that controllers can read them. */
+        static std::vector<std::string> args;
+
   private:
        
     static std::set<World*> world_set; ///< all the worlds that exist


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

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit

Reply via email to