[openrtm-commit:03189] r3229 - branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm

openrtm @ openrtm.org openrtm @ openrtm.org
2018年 2月 27日 (火) 10:10:30 JST


Author: n-ando
Date: 2018-02-27 10:10:30 +0900 (Tue, 27 Feb 2018)
New Revision: 3229

Modified:
   branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/ManagerConfig.cpp
   branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/ManagerConfig.h
Log:
[compat,bugfix] Command line options and its documentation have been modified.

Modified: branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/ManagerConfig.cpp
===================================================================
--- branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/ManagerConfig.cpp	2018-02-26 14:00:25 UTC (rev 3228)
+++ branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/ManagerConfig.cpp	2018-02-27 01:10:30 UTC (rev 3229)
@@ -24,6 +24,7 @@
 #include <coil/OS.h>
 #include <coil/stringutil.h>
 #include <rtm/DefaultConfiguration.h>
+#include <stdlib.h>
 
 #ifdef __QNX__
 using std::sprintf;
@@ -34,12 +35,12 @@
   
   // The list of default configuration file path.
 #ifdef RTM_OS_WIN32
-	const char* ManagerConfig::config_file_path[] = 
-	{
-		"./rtc.conf",
-		"${RTM_ROOT}bin/${RTM_VC_VERSION}/rtc.conf",
-		NULL
-	};
+  const char* ManagerConfig::config_file_path[] = 
+    {
+      "./rtc.conf",
+      "${RTM_ROOT}bin/${RTM_VC_VERSION}/rtc.conf",
+      NULL
+    };
 #else
   const char* ManagerConfig::config_file_path[] = 
     {
@@ -115,16 +116,16 @@
     prop.setDefaults(default_config);
     if (findConfigFile())
       {
-	std::ifstream f(m_configFile.c_str());
-	if (f.is_open())
-	  {
-	    prop.load(f);
-	    f.close();
-	  }
+        std::ifstream f(m_configFile.c_str());
+        if (f.is_open())
+          {
+            prop.load(f);
+            f.close();
+          }
       }
     setSystemInformation(prop);
     if (m_isMaster) { prop["manager.is_master"] = "YES"; }
-
+    
     // Properties from arguments are marged finally
     prop << m_argprop;
     prop["config_file"] = m_configFile;
@@ -146,21 +147,24 @@
     
     while ((opt = get_opts()) > 0)
       {
-	switch (opt)
-	  {
+        switch (opt)
+          {
           case 'a':
             {
               m_argprop["manager.corba_servant"] = "NO";
             }
             break;
-	    // Specify configuration file not default
-	  case 'f':
-	    m_configFile = get_opts.optarg;
-	    break;
-	  case 'l':
-	    //	    m_configFile = get_opts.optarg;
-	    break;
-	  case 'o':
+            // Specify configuration file not default
+          case 'f':
+            if (!fileExist(get_opts.optarg))
+              {
+                std::cerr << "Configuration file: " << m_configFile;
+                std::cerr << " not found." << std::endl;
+                abort();
+              }
+            m_configFile = get_opts.optarg;
+            break;
+          case 'o':
             {
               std::string optarg(get_opts.optarg);
               std::string::size_type pos(optarg.find(":"));
@@ -180,7 +184,7 @@
                   m_argprop[key] = value;
                 }
             }
-	    break;
+            break;
           case 'p': // ORB's port number
             {
               int portnum;
@@ -191,12 +195,12 @@
                 }
             }
             break;
-	  case 'd':
+          case 'd':
             m_isMaster = true;
-	    break;
-	  default:
-	    break;
-	  }
+            break;
+          default:
+            break;
+          }
       }
     return;
   }
@@ -213,34 +217,37 @@
     // Check existance of configuration file given command arg
     if (m_configFile != "") 
       {
-	if (fileExist(m_configFile))
-	  {
-	    return true;
-	  }
+        if (fileExist(m_configFile))
+          {
+            return true;
+          }
+        std::cerr << "Configuration file: " << m_configFile;
+        std::cerr << " not found." << std::endl;
       }
-    
     // Search rtc configuration file from environment variable
     char* env = getenv(config_file_env);
     if (env != NULL)
       {
-	if (fileExist(env))
-	  {
-	    m_configFile = env;
-	    return true;
-	  }
+        if (fileExist(env))
+          {
+            m_configFile = env;
+            return true;
+          }
+        std::cerr << "Configuration file: " << m_configFile;
+        std::cerr << " not found." << std::endl;
       }
     // Search rtc configuration file from default search path
     int i = 0;
     while (config_file_path[i] != NULL)
       {
-		  std::string cpath = coil::replaceEnv(config_file_path[i]);
+        std::string cpath = coil::replaceEnv(config_file_path[i]);
 
-		  if (fileExist(cpath))
-		  {
-			  m_configFile = cpath;
-			  return true;
-		  }
-		++i;
+        if (fileExist(cpath))
+          {
+            m_configFile = cpath;
+            return true;
+          }
+        ++i;
       }
     return false;
   }
@@ -260,7 +267,7 @@
     coil::utsname  sysinfo;
     if (coil::uname(&sysinfo) != 0)
       {
-	return;
+        return;
       }
     
     //
@@ -294,13 +301,13 @@
     // fial() 0: ok, !0: fail
     if (infile.fail() != 0) 
       {
-	infile.close();
-	return false;
+        infile.close();
+        return false;
       }
     else
       {
-	infile.close();
-	return true;
+        infile.close();
+        return true;
       }
     return false;
   }

Modified: branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/ManagerConfig.h
===================================================================
--- branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/ManagerConfig.h	2018-02-26 14:00:25 UTC (rev 3228)
+++ branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/ManagerConfig.h	2018-02-27 01:10:30 UTC (rev 3229)
@@ -37,6 +37,7 @@
    * ¥×¥í¥Ñ¥Æ¥£¾ðÊó¤òÀßÄꤹ¤ë¡£
    *
    * ³ÆÀßÄê¤ÎÍ¥ÀèÅ٤ϰʲ¼¤Î¤È¤ª¤ê¤Ç¤¢¤ë¡£
+   * - UNIX/Linux
    * <OL>
    * <LI>¥³¥Þ¥ó¥É¥é¥¤¥ó¥ª¥×¥·¥ç¥ó "-f"
    * <LI>´Ä¶­ÊÑ¿ô "RTC_MANAGER_CONFIG"
@@ -47,9 +48,13 @@
    * <LI>¥Ç¥Õ¥©¥ë¥ÈÀßÄê¥Õ¥¡¥¤¥ë "/usr/local/etc/rtc/rtc.conf"
    * <LI>Ëä¤á¹þ¤ß¥³¥ó¥Õ¥£¥®¥å¥ì¡¼¥·¥ç¥óÃÍ
    *</OL>
-   * ¤¿¤À¤·¡¢¥³¥Þ¥ó¥É¥é¥¤¥ó¥ª¥×¥·¥ç¥ó "-d" ¤¬»ØÄꤵ¤ì¤¿¾ì¹ç¤Ï¡¢
-   * (¤¿¤È¤¨ -f ¤ÇÀßÄê¥Õ¥¡¥¤¥ë¤ò»ØÄꤷ¤Æ¤â)Ëä¤á¹þ¤ß¥³¥ó¥Õ¥£¥®¥å¥ì¡¼¥·¥ç¥óÃÍ
-   * ¤¬»ÈÍѤµ¤ì¤ë¡£
+   * - Windows
+   * <OL>
+   * <LI>¥³¥Þ¥ó¥É¥é¥¤¥ó¥ª¥×¥·¥ç¥ó "-f"
+   * <LI>´Ä¶­ÊÑ¿ô "RTC_MANAGER_CONFIG"
+   * <LI>¥Ç¥Õ¥©¥ë¥ÈÀßÄê¥Õ¥¡¥¤¥ë "./rtc.conf"
+   * <LI>¥Ç¥Õ¥©¥ë¥ÈÀßÄê¥Õ¥¡¥¤¥ë "%RTM_ROOT%/%RTM_VC_VERSION%/rtc.conf"
+   * </OL>
    *
    * @since 0.4.0
    *
@@ -58,12 +63,13 @@
    * @class ManagerConfig
    * @brief Manager configuration class
    *
-   * Modify Manager's configuration. 
+   * Modify Manager's configuration.
    * This class receives the command line arguments and will be instantiated.
    * Set property information of Manager with the configuration file specified
    * by the command line argument or the environment variable etc.
    *
    * The priorities of each configuration are as follows:
+   * - UNIX/Linux
    * <OL>
    * <LI>Command option "-f"
    * <LI>Environment variable "RTC_MANAGER_CONFIG"
@@ -74,8 +80,13 @@
    * <LI>Default configuration file "/usr/local/etc/rtc/rtc.conf"
    * <LI>Embedded configuration value
    *</OL>
-   * If the command option "-d" is specified (even if specify configuration file
-   * by "-f" option), the embedded configuration values will be used.
+   * - Windows
+   * <OL>
+   * <LI>Command option "-f"
+   * <LI>Environment variable "RTC_MANAGER_CONFIG"
+   * <LI>Default configuration file "./rtc.conf"
+   * <LI>Default configuration file "%RTM_ROOT%/%RTM_VC_VERSION%/rtc.conf"
+   * </OL>
    *
    * @since 0.4.0
    *
@@ -167,10 +178,11 @@
      * ¥³¥Þ¥ó¥É¥é¥¤¥ó°ú¿ô¤Ë±þ¤¸¤Æ½é´ü²½¤ò¼Â¹Ô¤¹¤ë¡£¥³¥Þ¥ó¥É¥é¥¤¥ó¥ª¥×¥·¥ç¥ó¤Ï
      * °Ê²¼¤Î¤â¤Î¤¬»ÈÍѲÄǽ¤Ç¤¢¤ë¡£
      *
-     *  - -f file   : ¥³¥ó¥Õ¥£¥®¥å¥ì¡¼¥·¥ç¥ó¥Õ¥¡¥¤¥ë¤ò»ØÄꤹ¤ë¡£
-     *  - -l module : ¥í¡¼¥É¤¹¤ë¥â¥¸¥å¡¼¥ë¤ò»ØÄꤹ¤ë¡£(̤¼ÂÁõ)
-     *  - -o options: ¤½¤Î¾¥ª¥×¥·¥ç¥ó¤ò»ØÄꤹ¤ë¡£(̤¼ÂÁõ)
-     *  - -d        : ¥Ç¥Õ¥©¥ë¥È¤Î¥³¥ó¥Õ¥£¥®¥å¥ì¡¼¥·¥ç¥ó¤ò»È¤¦¡£(̤¼ÂÁõ)
+     * - -a              : ¥Þ¥Í¡¼¥¸¥ã¥µ¡¼¥Ó¥¹OFF
+     * - -f <file name>  : ÀßÄê¥Õ¥¡¥¤¥ë¤Î»ØÄê
+     * - -o <option>     ; ¥ª¥×¥·¥ç¥ó»ØÄê
+     * - -p <port number>: ¥Ý¡¼¥ÈÈÖ¹æ»ØÄê
+     * - -d              : ¥Þ¥¹¥¿¡¼¥Þ¥Í¡¼¥¸¥ã»ØÄê
      *
      * @param argc ¥³¥Þ¥ó¥É¥é¥¤¥ó°ú¿ô¤Î¿ô
      * @param argv ¥³¥Þ¥ó¥É¥é¥¤¥ó°ú¿ô
@@ -182,10 +194,11 @@
      * Initialize with command line options. The following command options
      * are available.
      *
-     * - -f file   : Specify the configuration file.
-     * - -l module : Specify modules to be loaded. (Not implemented)
-     * - -o options: Specify other options. (Not implemented)
-     * - -d        : Use default static configuration. (Not implemented)
+     * - -a              : Disable manager service
+     * - -f <file name>  : Specify a configuration file
+     * - -o <option>     ; Specify options
+     * - -p <port number>: Specify a port number
+     * - -d              : Run as the master manager
      *
      * @param argc Number of command line arguments
      * @param argv The command line arguments



More information about the openrtm-commit mailing list