コード例 #1
0
ファイル: Log_Backend.cpp プロジェクト: DOCGroup/DAnCE
  int
  NDDS_Log_Backend::init (int argc, ACE_TCHAR **argv)
  {
    ACE_Get_Opt opts (argc, argv, ACE_TEXT ("t:d:q:n:"), 0, 0,
                      ACE_Get_Opt::RETURN_IN_ORDER);
    opts.long_option (ACE_TEXT ("topic"), 't', ACE_Get_Opt::ARG_REQUIRED);
    opts.long_option (ACE_TEXT ("domain"), 'd', ACE_Get_Opt::ARG_REQUIRED);
    opts.long_option (ACE_TEXT ("qos-file"), 'q', ACE_Get_Opt::ARG_REQUIRED);
    opts.long_option (ACE_TEXT ("node-name"), 'n', ACE_Get_Opt::ARG_REQUIRED);

    int c = 0;

    while ((c = opts ()) != -1)
      {
        switch (c)
          {
          case 't':
            this->topic_name_ = opts.opt_arg ();
            break;

          case 'd':
            this->domain_ = ACE_OS::atoi (opts.opt_arg ());
            break;

          case 'q':
            this->qos_file_ = opts.opt_arg ();
            break;

          case 'n':
            this->node_ = opts.opt_arg ();
            break;

          default:
            ACE_ERROR ((LM_ERROR, ACE_TEXT ("Unknown option for NDDS_Log_Backend: %s\n"),
                        opts.last_option ()));
          }

      }

    return this->open (ACE_TEXT (""));
  }
コード例 #2
0
ファイル: Locality_Manager_Task.cpp プロジェクト: Yijtx/ACE
  void
  LocalityManager_Task::parse_args (int argc, ACE_TCHAR **argv)
  {
    DANCE_TRACE ("LocalityManager_Task::parse_args");

    DANCE_DEBUG (DANCE_LOG_TRACE,
                 (LM_TRACE, DLINFO
                  ACE_TEXT ("LocalityManager_Task::parse_args - ")
                  ACE_TEXT ("parsing arguments...\n")));

    ACE_Get_Opt opts (argc, argv, ACE_TEXT("hu:c:p:"), 1, 0,
                      ACE_Get_Opt::RETURN_IN_ORDER);
    opts.long_option (ACE_TEXT("uuid"), 'u', ACE_Get_Opt::ARG_REQUIRED);
    opts.long_option (ACE_TEXT("callback-ior"), 'c', ACE_Get_Opt::ARG_REQUIRED);
    opts.long_option (ACE_TEXT("help"), 'h');
    opts.long_option (ACE_TEXT("log-level"),'l', ACE_Get_Opt::ARG_REQUIRED);
    opts.long_option (ACE_TEXT("trace"),'t', ACE_Get_Opt::NO_ARG);
    opts.long_option (ACE_TEXT("output-ior"),'o', ACE_Get_Opt::ARG_REQUIRED);
    opts.long_option (ACE_TEXT("plugin-config"),'p', ACE_Get_Opt::ARG_REQUIRED);

    int c = 0;
    while ((c = opts ()) != -1)
      {
        DANCE_DEBUG (DANCE_LOG_DETAILED_TRACE,
                     (LM_TRACE, DLINFO
                      ACE_TEXT ("LocalityManager_Task::parse_args - ")
                      ACE_TEXT ("Found option: \"%s\" with argument \"%s\"\n"),
                      opts.last_option (), opts.opt_arg ()));

        switch (c)
          {
          case 'u':
            DANCE_DEBUG (DANCE_LOG_MAJOR_DEBUG_INFO,
                         (LM_DEBUG, DLINFO
                          ACE_TEXT ("LocalityManager_Task::parse_args - ")
                          ACE_TEXT ("uuid is %s\n"),
                          opts.opt_arg ()));
            this->uuid_ = opts.opt_arg ();
            break;

          case 'c':
            DANCE_DEBUG (DANCE_LOG_MAJOR_DEBUG_INFO,
                         (LM_DEBUG, DLINFO
                          ACE_TEXT ("LocalityManager_Task::parse_args - ")
                          ACE_TEXT ("callback ior is %s\n"),
                          opts.opt_arg ()));
            this->callback_ior_str_ = opts.opt_arg ();
            break;

          case 'l':
            {
              continue; // no-op, already taken care of
            }

          case 't':
            continue; // already taken care of

          case 'o':
            DANCE_DEBUG (DANCE_LOG_MAJOR_DEBUG_INFO,
                         (LM_DEBUG, DLINFO
                          ACE_TEXT ("LocalityManager_Task::parse_args - ")
                          ACE_TEXT ("IOR Output file: %s\n"),
                          opts.opt_arg ()));
            this->output_file_ = opts.opt_arg ();
            break;

          case 'p':
            DANCE_DEBUG (DANCE_LOG_MAJOR_DEBUG_INFO,
                         (LM_DEBUG, DLINFO
                          ACE_TEXT ("LocalityManager_Task::parse_args - ")
                          ACE_TEXT ("Adding <%s> to plugin config list\n"),
                          opts.opt_arg ()));
            this->plugin_config_.push_back (ACE_TEXT_ALWAYS_CHAR (opts.opt_arg ()));
            break;

          case 'h':
            this->usage ();
            throw Error ("Command line help requested, bailing out....");

          default:
            DANCE_ERROR (DANCE_LOG_ERROR, (LM_ERROR, DLINFO
                                           ACE_TEXT (" Unknown option: %s\n"),
                                           opts.last_option ()));
            this->usage ();
            ACE_CString err ("Unknown option ");
            err += ACE_TEXT_ALWAYS_CHAR (opts.last_option ());
            throw Error (err);
          }
      }

    // check required options.
    if (this->uuid_ == ACE_TEXT (""))
      throw Error ("Option required: -u|--uuid");
    if (this->callback_ior_str_ == ACE_TEXT(""))
      {
        DANCE_ERROR (DANCE_LOG_WARNING,
                     (LM_WARNING, DLINFO
                      ACE_TEXT ("LocalityManager_Task::parse_args - ")
                      ACE_TEXT ("Starting ComponentServer without a callback IOR\n")));
      }

    if (this->plugin_config_.size () == 0)
      {
        DANCE_DEBUG (DANCE_LOG_MAJOR_DEBUG_INFO,
                     (LM_DEBUG, DLINFO
                      ACE_TEXT ("LocalityManager_Task::parse_args - ")
                      ACE_TEXT ("No plugin config specified, adding default at ")
                      ACE_TEXT ("DANCE_ROOT/bin/ciao.localityconfig\n")));

        ACE_Env_Value<const ACE_TCHAR *> dance_env (ACE_TEXT ("DANCE_ROOT"),
                                                    ACE_TEXT (""));
        std::string filename (ACE_TEXT_ALWAYS_CHAR (dance_env));
        filename += "/bin/ciao.localityconfig";
        this->plugin_config_.push_back (filename.c_str ());
      }
  }
コード例 #3
0
ファイル: MonitorManager.cpp プロジェクト: asdlei00/ACE
int
TAO_MonitorManager::init (int argc, ACE_TCHAR* argv[])
{
  ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, guard, this->task_.mutex_, -1);

  this->task_.argv_.add (ACE_TEXT("fake_process_name"));

  ACE_Get_Opt opts (argc,
                    argv,
                    ACE_TEXT ("o:"),
                    0,
                    0,
                    ACE_Get_Opt::PERMUTE_ARGS,
                    1);

  static const ACE_TCHAR* orbarg = ACE_TEXT ("ORBArg");
  static const ACE_TCHAR* nonamesvc = ACE_TEXT ("NoNameSvc");
  opts.long_option (orbarg, ACE_Get_Opt::ARG_REQUIRED);
  opts.long_option (nonamesvc, ACE_Get_Opt::NO_ARG);

  int c;
  while ((c = opts ()) != -1)
    switch (c)
      {
        case 'o':
          this->task_.ior_output_ = opts.opt_arg ();
          if (TAO_debug_level > 7)
            {
              ORBSVCS_DEBUG((LM_INFO,
                ACE_TEXT("(%P|%t) TAO_MonitorManager: Setting IOR output file to: %s"),
                  this->task_.ior_output_.c_str ()));
            }
          break;
        case 0:
          if (ACE_OS::strcmp (opts.long_option (), orbarg) == 0)
            {
              ACE_TCHAR * orbArgs = opts.opt_arg ();
              if (TAO_debug_level > 7)
                {
                  ORBSVCS_DEBUG((LM_INFO,
                    ACE_TEXT("(%P|%t) TAO_MonitorManager: Setting Orb arguments to: %s"),
                      orbArgs));
                }
              this->task_.argv_.add (orbArgs);
            }
          else if (ACE_OS::strcmp (opts.long_option (), nonamesvc) == 0)
            {
              if (TAO_debug_level > 7)
                {
                  ORBSVCS_DEBUG((LM_INFO,
                    ACE_TEXT("(%P|%t) TAO_MonitorManager: Not using naming service")));
                }
              this->task_.use_name_svc_ = false;
            }
          break;
        case ':':
          ORBSVCS_ERROR_RETURN ((LM_ERROR,
                             ACE_TEXT ("(%P|%t) TAO_MonitorManager: %s requires an argument\n"),
                             opts.last_option ()),
                             -1);
      }

  // Force the ARGV_T to copy the elements added by the add() method
  this->task_.argv_.argv ();

  // Rember that Monitor has been configured
  this->initialized_ = true;
  return 0;
}
コード例 #4
0
ファイル: map_parser.cpp プロジェクト: bhutnath/yarp
bool
do_processArguments (const int argc_in,
                     ACE_TCHAR** argv_in, // cannot be const...
                     bool& debugScanner_out,
                     bool& debugParser_out,
                     std::string& mapFile_out,
                     bool& traceInformation_out,
                     bool& printVersionAndExit_out)
{
  RPG_TRACE (ACE_TEXT ("::do_processArguments"));

  std::string data_path =
    RPG_Common_File_Tools::getConfigurationDataDirectory (ACE_TEXT_ALWAYS_CHAR (BASEDIR),
                                                          false);
#if defined (DEBUG_DEBUGGER)
  data_path = Common_File_Tools::getWorkingDirectory ();
#endif

  // init results
  debugScanner_out = MAP_PARSER_DEF_DEBUG_SCANNER;
  debugParser_out = MAP_PARSER_DEF_DEBUG_PARSER;

  mapFile_out = data_path;
  mapFile_out += ACE_DIRECTORY_SEPARATOR_CHAR_A;
#if defined (DEBUG_DEBUGGER)
  mapFile_out += (MAP_GENERATOR_DEF_LEVEL ? ACE_TEXT_ALWAYS_CHAR ("engine")
                                          : ACE_TEXT_ALWAYS_CHAR ("map"));
  mapFile_out += ACE_DIRECTORY_SEPARATOR_CHAR_A;
  mapFile_out += ACE_TEXT_ALWAYS_CHAR("data");
  mapFile_out += ACE_DIRECTORY_SEPARATOR_CHAR_A;
#else
  mapFile_out += ACE_TEXT_ALWAYS_CHAR(RPG_MAP_MAPS_SUB);
  mapFile_out += ACE_DIRECTORY_SEPARATOR_CHAR_A;
#endif
  mapFile_out += (MAP_GENERATOR_DEF_LEVEL ? RPG_Common_Tools::sanitize (ACE_TEXT_ALWAYS_CHAR (RPG_ENGINE_LEVEL_DEF_NAME))
                                          : ACE_TEXT_ALWAYS_CHAR (RPG_MAP_DEF_MAP_FILE));
  mapFile_out += (MAP_GENERATOR_DEF_LEVEL ? ACE_TEXT_ALWAYS_CHAR(RPG_ENGINE_LEVEL_FILE_EXT)
                                          : ACE_TEXT_ALWAYS_CHAR(RPG_MAP_FILE_EXT));

  traceInformation_out = false;
  printVersionAndExit_out = false;

  ACE_Get_Opt argumentParser (argc_in,
                              argv_in,
                              ACE_TEXT ("m:pstv"));

  int option = 0;
  while ((option = argumentParser ()) != EOF)
  {
    switch (option)
    {
      case 'm':
      {
        mapFile_out = argumentParser.opt_arg ();

        break;
      }
      case 'p':
      {
        debugParser_out = true;

        break;
      }
      case 's':
      {
        debugScanner_out = true;

        break;
      }
      case 't':
      {
        traceInformation_out = true;

        break;
      }
      case 'v':
      {
        printVersionAndExit_out = true;

        break;
      }
      // error handling
      case '?':
      {
        ACE_DEBUG((LM_ERROR,
                   ACE_TEXT("unrecognized option \"%s\", aborting\n"),
                   argumentParser.last_option()));

        return false;
      }
      default:
      {
        ACE_DEBUG((LM_ERROR,
                   ACE_TEXT("unrecognized option \"%c\", aborting\n"),
                   option));

        return false;
      }
    } // end SWITCH
  } // end WHILE

  return true;
}
コード例 #5
0
ファイル: sound_parser.cpp プロジェクト: bhutnath/yarp
bool
do_processArguments (const int argc_in,
                     ACE_TCHAR* argv_in[], // cannot be const...
                     bool& dumpDictionary_out,
                     std::string& directory_out,
                     bool& playRandomSounds_out,
                     std::string& filename_out,
                     bool& traceInformation_out,
                     bool& printVersionAndExit_out,
                     bool& validateXML_out)
{
    RPG_TRACE (ACE_TEXT ("::do_processArguments"));

    // initialize results
    std::string configuration_path =
        RPG_Common_File_Tools::getConfigurationDataDirectory (ACE_TEXT_ALWAYS_CHAR (BASEDIR),
                true);
    std::string data_path =
        RPG_Common_File_Tools::getConfigurationDataDirectory (ACE_TEXT_ALWAYS_CHAR (BASEDIR),
                false);
#if defined (DEBUG_DEBUGGER)
    configuration_path = Common_File_Tools::getWorkingDirectory ();
    data_path = Common_File_Tools::getWorkingDirectory ();
#endif // DEBUG_DEBUGGER

    dumpDictionary_out = false;

    directory_out = data_path;
    directory_out += ACE_DIRECTORY_SEPARATOR_CHAR_A;
#if defined (DEBUG_DEBUGGER)
    directory_out += ACE_TEXT_ALWAYS_CHAR ("sound");
    directory_out += ACE_DIRECTORY_SEPARATOR_CHAR_A;
    directory_out += ACE_TEXT_ALWAYS_CHAR(RPG_COMMON_DATA_SUB);
#else
    directory_out += ACE_TEXT_ALWAYS_CHAR (RPG_SOUND_DATA_SUB);
#endif // DEBUG_DEBUGGER

    playRandomSounds_out = SOUNDPARSER_DEF_PLAY_RANDOM_SOUNDS;

    filename_out = configuration_path;
    filename_out += ACE_DIRECTORY_SEPARATOR_CHAR_A;
#if defined (DEBUG_DEBUGGER)
    filename_out += ACE_TEXT_ALWAYS_CHAR ("sound");
    filename_out += ACE_DIRECTORY_SEPARATOR_CHAR_A;
#endif // DEBUG_DEBUGGER
    filename_out += ACE_TEXT_ALWAYS_CHAR (RPG_SOUND_DICTIONARY_FILE);

    traceInformation_out = false;
    printVersionAndExit_out = false;
    validateXML_out = true;

    ACE_Get_Opt argumentParser (argc_in,
                                argv_in,
                                ACE_TEXT ("df:rs:tvx"));

    int option = 0;
    while ((option = argumentParser ()) != EOF)
    {
        switch (option)
        {
        case 'd':
        {
            dumpDictionary_out = true;

            break;
        }
        case 'f':
        {
            directory_out = argumentParser.opt_arg ();

            break;
        }
        case 'r':
        {
            playRandomSounds_out = true;

            break;
        }
        case 's':
        {
            filename_out = argumentParser.opt_arg ();

            break;
        }
        case 't':
        {
            traceInformation_out = true;

            break;
        }
        case 'v':
        {
            printVersionAndExit_out = true;

            break;
        }
        case 'x':
        {
            validateXML_out = false;

            break;
        }
        // error handling
        case '?':
        {
            ACE_DEBUG ((LM_ERROR,
                        ACE_TEXT ("unrecognized option \"%s\", aborting\n"),
                        ACE_TEXT (argumentParser.last_option ())));
            return false;
        }
        default:
        {
            ACE_DEBUG ((LM_ERROR,
                        ACE_TEXT ("unrecognized option \"%c\", aborting\n"),
                        option));
            return false;
        }
        } // end SWITCH
    } // end WHILE

    return true;
}
コード例 #6
0
ファイル: IRC_client.cpp プロジェクト: bhutnath/yarp
bool
do_processArguments (const int argc_in,
                     ACE_TCHAR* argv_in[], // cannot be const...
                     std::string& configFile_out,
                     bool& debugParser_out,
                     bool& logToFile_out,
                     bool& traceInformation_out,
                     bool& printVersionAndExit_out,
                     unsigned int& numThreadPoolThreads_out)
{
  RPG_TRACE (ACE_TEXT ("::do_processArguments"));

  std::string configuration_path =
    RPG_Common_File_Tools::getConfigurationDataDirectory (ACE_TEXT_ALWAYS_CHAR (BASEDIR),
                                                          true);
#if defined (DEBUG_DEBUGGER)
  configuration_path = Common_File_Tools::getWorkingDirectory ();
#endif // #ifdef DEBUG_DEBUGGER

  // init configuration
  configFile_out = configuration_path;
  configFile_out += ACE_DIRECTORY_SEPARATOR_CHAR_A;
#if defined (DEBUG_DEBUGGER)
  configFile_out += ACE_TEXT_ALWAYS_CHAR ("protocol");
  configFile_out += ACE_DIRECTORY_SEPARATOR_CHAR_A;
#endif
  configFile_out += ACE_TEXT_ALWAYS_CHAR (IRC_CLIENT_CNF_DEF_INI_FILE);

  debugParser_out          = false;
  logToFile_out            = false;
  traceInformation_out     = false;
  printVersionAndExit_out  = false;
  numThreadPoolThreads_out = IRC_CLIENT_DEF_NUM_TP_THREADS;

  ACE_Get_Opt argumentParser (argc_in,
                              argv_in,
                              ACE_TEXT("c:dltvx:"),
                              1, // skip command name
                              1, // report parsing errors
                              ACE_Get_Opt::PERMUTE_ARGS, // ordering
                              0); // for now, don't use long options

  int option = 0;
  std::stringstream converter;
  while ((option = argumentParser ()) != EOF)
  {
    switch (option)
    {
      case 'c':
      {
        configFile_out = argumentParser.opt_arg ();

        break;
      }
      case 'd':
      {
        debugParser_out = true;

        break;
      }
      case 'l':
      {
        logToFile_out = true;

        break;
      }
      case 't':
      {
        traceInformation_out = true;

        break;
      }
      case 'v':
      {
        printVersionAndExit_out = true;

        break;
      }
      case 'x':
      {
        converter.clear ();
        converter.str (ACE_TEXT_ALWAYS_CHAR (""));
        converter << argumentParser.opt_arg ();
        converter >> numThreadPoolThreads_out;

        break;
      }
      // error handling
      case ':':
      {
        ACE_DEBUG ((LM_ERROR,
                    ACE_TEXT ("option \"%c\" requires an argument, aborting\n"),
                    argumentParser.opt_opt ()));
        return false;
      }
      case '?':
      {
        ACE_DEBUG ((LM_ERROR,
                    ACE_TEXT ("unrecognized option \"%s\", aborting\n"),
                    argumentParser.last_option ()));
        return false;
      }
      case 0:
      {
        ACE_DEBUG ((LM_ERROR,
                    ACE_TEXT ("found long option \"%s\", aborting\n"),
                    argumentParser.long_option ()));
        return false;
      }
      default:
      {
        ACE_DEBUG ((LM_ERROR,
                    ACE_TEXT ("parse error, aborting\n")));
        return false;
      }
    } // end SWITCH
  } // end WHILE

  return true;
}