当前位置: 首页>>代码示例>>C++>>正文


C++ ConfigElementPtr::getNum方法代码示例

本文整理汇总了C++中jccl::ConfigElementPtr::getNum方法的典型用法代码示例。如果您正苦于以下问题:C++ ConfigElementPtr::getNum方法的具体用法?C++ ConfigElementPtr::getNum怎么用?C++ ConfigElementPtr::getNum使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在jccl::ConfigElementPtr的用法示例。


在下文中一共展示了ConfigElementPtr::getNum方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: config

bool SimAnalog::config(jccl::ConfigElementPtr element)
{
   //vprDEBUG(vprDBG_ALL, vprDBG_VERB_LVL)<<"*** SimAnalog::config()\n"<< vprDEBUG_FLUSH;
   if (! (Input::config(element) && Analog::config(element) &&
          SimInput::config(element)) )
   {
      return false;
   }

   std::vector<jccl::ConfigElementPtr> key_inc_list, key_dec_list;

   int key_count = element->getNum("increment_keypress");

   for ( int i = 0; i < key_count; ++i )
   {
      key_inc_list.push_back(element->getProperty<jccl::ConfigElementPtr>("increment_keypress", i));
   }

   key_count = element->getNum("decrement_keypress");

   for ( int i = 0; i < key_count; ++i )
   {
      key_dec_list.push_back(element->getProperty<jccl::ConfigElementPtr>("decrement_keypress", i));
   }

   mSimKeysUp = readKeyList(key_inc_list);
   mSimKeysDown = readKeyList(key_dec_list);

   mAnaStep = element->getProperty<float>("delta");
   mInitialValue = element->getProperty<float>("initial_value");

   // Initialize all the data to the inital_value
   size_t num_pairs = mSimKeysUp.size();
   mAnaData = std::vector<AnalogData>(num_pairs);
   for (size_t i=0; i<num_pairs; ++i)
   {
      mAnaData[i].setValue(mInitialValue);
   }

   mAutoReturn = element->getProperty<bool>("auto_return");

   return true;
}
开发者ID:Michael-Lfx,项目名称:vrjuggler,代码行数:43,代码来源:SimAnalog.cpp

示例2: configRemove

   /**
    * Removes the element from the current configuration.
    * @pre configCanHandle(element) == true
    */
   bool SoundManagerSonix::configRemove(jccl::ConfigElementPtr element)
   {
      // remove any specified sounds...
      int size = element->getNum("sound");
      for (int x = 0; x < size; ++x)
      {
         jccl::ConfigElementPtr sound_element =
            element->getProperty<jccl::ConfigElementPtr>("sound", x);
         std::string alias(sound_element->getName());
         snx::sonix::instance()->remove(alias);
      }

      return true;
   }
开发者ID:rpavlik,项目名称:vrjuggler-2.2-debs,代码行数:18,代码来源:SoundManagerSonix.cpp

示例3: config

bool IntersenseAPI::config(jccl::ConfigElementPtr e)
{
   vprDEBUG(gadgetDBG_INPUT_MGR, vprDBG_STATE_LVL)
      << "*** IntersenseAPI::config() ***" << std::endl << vprDEBUG_FLUSH;

   // Configure the subclasses
   if (!(Input::config(e) && Position::config(e) &&
         Digital::config(e) && Analog::config(e)))
   {
      return false;
   }

   // Set various attributes of the Intersense driver
   mTracker.setPort( e->getProperty<std::string>("port") );
   mTracker.setVerbose(e->getProperty<bool>("verbose"));

   // Get the location of the Intersense DSO
   mISenseDriverLocation = e->getProperty<std::string>("driver");

   // Create a new array of StationConfigs
   mStations.resize(e->getNum("stations"));

   // Configure each station
   for( unsigned int i = 0; i < mStations.size(); ++i )
   {
      jccl::ConfigElementPtr station_config =
         e->getProperty<jccl::ConfigElementPtr>("stations", i);

      mStations[i].enabled = station_config->getProperty<bool>("enabled");
      mStations[i].stationIndex =
         station_config->getProperty<int>("station_index");
      mStations[i].useDigital =
         station_config->getProperty<bool>("use_digital");
      mStations[i].useAnalog = station_config->getProperty<bool>("use_analog");

      mStations[i].dig_num = station_config->getProperty<int>("digital_count");
      mStations[i].ana_num = station_config->getProperty<int>("analog_count");
   }

   return true;
}
开发者ID:baibaiwei,项目名称:vrjuggler,代码行数:41,代码来源:IntersenseAPI.cpp

示例4: config

bool DirectXJoystick::config(jccl::ConfigElementPtr e)
{
   if(! (Input::config(e) && Digital::config(e) && Analog::config(e)))
   {
      return false;
   }

   mJsLabel = e->getName();

   unsigned int num_axis_buttons = e->getNum("axis_buttons");
   for ( unsigned int i = 0; i < num_axis_buttons; ++i )
   {
      unsigned idx = e->getProperty<int>("axis_buttons", i);
      mAxisButtonIndices.push_back(idx);
   }

   // Override whatever the user configured with the minimum and maximum values
   // used by the standalone Direct Input device.  User configuration input is
   // useless in this case.
   setMin((float) DirectXJoystickStandalone::getAxisMin());
   setMax((float) DirectXJoystickStandalone::getAxisMax());

   return true;
}
开发者ID:baibaiwei,项目名称:vrjuggler,代码行数:24,代码来源:DirectXJoystick.cpp

示例5: configAdd

   bool AbstractNetworkManager::configAdd(jccl::ConfigElementPtr element)
   {
      if (recognizeClusterMachineConfig(element))
      {
         // -If local machine element
         //   -Add machine specific ConfigElements to the pending list.
         //   -Start Listening thread
         // -Else
         //   -Add Node to AbstractNetworkManager

         if (isLocalHost( element->getProperty<std::string>( "host_name" ) ))
         {
            // XXX: Hack to ensure that we don't start listening for connections until
            //      we have fully configured all other nodes.
            ElementPred pred(getClusterNodeElementType());

            jccl::ConfigManager* cfg_mgr = jccl::ConfigManager::instance();
            unsigned int num_pending_nodes =
               std::count_if(cfg_mgr->getPendingBegin(), cfg_mgr->getPendingEnd(), pred);

            if (num_pending_nodes > 1)
            {
               vprDEBUG( gadgetDBG_NET_MGR, vprDBG_CONFIG_LVL ) << clrSetBOLD(clrRED)
                  << clrOutBOLD( clrMAGENTA,"[AbstractNetworkManager]" )
                  << " Some nodes not configured yet: " << num_pending_nodes
                  << clrRESET << std::endl << vprDEBUG_FLUSH;
               return false;
            }

            // NOTE: Add all machine dependent ConfigElementPtr's here
            vprASSERT( element->getNum("display_system") == 1 
               && "A Cluster System element must have exactly 1 display_system element" );

            std::vector<jccl::ConfigElementPtr> cluster_node_elements =
               element->getChildElements();

            for (std::vector<jccl::ConfigElementPtr>::iterator i = cluster_node_elements.begin();
                 i != cluster_node_elements.end();
                 ++i)
            {
               jccl::ConfigManager::instance()->addConfigElement(*i, jccl::ConfigManager::PendingElement::ADD);

               vprDEBUG( gadgetDBG_NET_MGR, vprDBG_CONFIG_LVL ) << clrSetBOLD(clrCYAN)
                  << clrOutBOLD( clrMAGENTA,"[AbstractNetworkManager]" )
                  << " Adding Machine specific ConfigElement: "
                  << (*i)->getName() << clrRESET << std::endl << vprDEBUG_FLUSH;
            }

            const int listen_port = element->getProperty<int>( "listen_port" );
            startListening( listen_port, false );
         }
         else
         {
            vprDEBUG( gadgetDBG_NET_MGR, vprDBG_CONFIG_LVL )
               << clrOutBOLD( clrMAGENTA, "[AbstractNetworkManager]" )
               << " Adding Node: " << element->getName()
               << " to the Cluster Network\n" << vprDEBUG_FLUSH;

            std::string    name        = element->getName();
            std::string    host_name   = element->getProperty<std::string>( "host_name" );
            vpr::Uint16    listen_port = element->getProperty<int>( "listen_port" );

            addNode(name, host_name, listen_port);
         }
         return true;
      }
      return false;
   }
开发者ID:rpavlik,项目名称:vrjuggler-2.2-debs,代码行数:68,代码来源:AbstractNetworkManager.cpp

示例6: configure

void ModeHarnessPlugin::configure(jccl::ConfigElementPtr elt)
{
   vprASSERT(elt->getID() == getElementType());

   const unsigned int req_cfg_version(2);

   // Check for correct version of plugin configuration.
   if ( elt->getVersion() < req_cfg_version )
   {
      std::stringstream msg;
      msg << "Configuration of ModeHarnessPlugin failed.  Required config "
          << "element version is " << req_cfg_version << ", but element '"
          << elt->getName() << "' is version " << elt->getVersion();
      throw PluginException(msg.str(), VRKIT_LOCATION);
   }

   const std::string component_path_prop("component_path");
   const std::string default_component_prop("default_component");
   const std::string component_prop("component");
   const std::string plugin_prop("plugin");
   const std::string signal_prop("signal");
   const std::string active_component_prop("active_component");

   // Set up two default search paths:
   //    1. Relative path to './plugins/mode'
   //    2. VRKIT_BASE_DIR/lib/vrkit/plugins/mode
   //
   // In all of the above cases, the 'debug' subdirectory is searched first if
   // this is a debug build (i.e., when VRKIT_DEBUG is defined and _DEBUG is
   // not).
   std::vector<std::string> component_path =
      plugin::getDefaultSearchPath("mode");

   const unsigned int num_plugin_paths(elt->getNum(component_path_prop));
   for ( unsigned int i = 0; i < num_plugin_paths; ++i )
   {
      std::string dir = elt->getProperty<std::string>(component_path_prop, i);
      component_path.push_back(vpr::replaceEnvVars(dir));
   }

   mDefaultComponentName =
      elt->getProperty<std::string>(default_component_prop);

   const unsigned int num_comps(elt->getNum(component_prop));
   for ( unsigned int i = 0; i < num_comps; ++i )
   {
      jccl::ConfigElementPtr comp_elt =
         elt->getProperty<jccl::ConfigElementPtr>(component_prop, i);
      mComponentInfo.push_back(
         ComponentInfo(comp_elt->getName(),
                       comp_elt->getProperty<std::string>(plugin_prop))
      );
   }

   const unsigned int num_signals(elt->getNum(signal_prop));
   for ( unsigned int i = 0; i < num_signals; ++i )
   {
      jccl::ConfigElementPtr signal_elt =
         elt->getProperty<jccl::ConfigElementPtr>(signal_prop, i);
      mSignalDefs.push_back(
         SignalDef(signal_elt->getName(),
                   signal_elt->getProperty<std::string>(active_component_prop))
      );
   }

   std::vector<vpr::LibraryPtr> modules = plugin::findModules(component_path);
   std::for_each(modules.begin(), modules.end(),
                 boost::bind(&ModeHarnessPlugin::registerModule, this, _1));
}
开发者ID:patrickhartling,项目名称:vrkit,代码行数:69,代码来源:ModeHarnessPlugin.cpp

示例7: config

// Configure the MotionStar with the given config element.
bool MotionStar::config(jccl::ConfigElementPtr e)
{
   bool retval(false);

   if ( Input::config(e) &&  Position::config(e) )
   {
      vprDEBUG(gadgetDBG_INPUT_MGR, vprDBG_STATE_LVL)
         << "MotionStar::config(jccl::ConfigElementPtr)\n"
         << vprDEBUG_FLUSH;

      const unsigned int cur_version(2);

      if ( e->getVersion() < cur_version )
      {
         vprDEBUG(gadgetDBG_INPUT_MGR, vprDBG_CRITICAL_LVL)
            << clrOutBOLD(clrRED, "ERROR")
            << " [gadget::MotionStar::config()] Element named '"
            << e->getName() << "'" << std::endl << vprDEBUG_FLUSH;
         vprDEBUG_NEXT(gadgetDBG_INPUT_MGR, vprDBG_CRITICAL_LVL)
            << "is version " << e->getVersion()
            << ", but we require at least version " << cur_version
            << std::endl << vprDEBUG_FLUSH;
         vprDEBUG_NEXT(gadgetDBG_INPUT_MGR, vprDBG_CRITICAL_LVL)
            << "Ignoring this element and moving on." << std::endl
            << vprDEBUG_FLUSH;
         retval = false;
      }
      else
      {
         // Configure mMotionStar with the config info.
         const unsigned num_filters = e->getNum("position_filters");

         // Sanity check.  There has to be at least one position filter
         // configured.
         if ( num_filters == 0 )
         {
            vprDEBUG(gadgetDBG_INPUT_MGR, vprDBG_CRITICAL_LVL)
               << clrOutBOLD(clrRED, "ERROR")
               << ": [MotionStar::config(jccl::ConfigElementPtr)] No position "
               << "filters configured in " << e->getName() << std::endl
               << vprDEBUG_FLUSH;
            retval = false;
         }
         else
         {
            BIRDNET::units expected_units;

            // Find the first position_transform_filter instance and get its
            // device_units property value.  This will tell us what units we're
            // expecting from the hardware.
            const std::string filter_type("position_transform_filter");
            for ( unsigned i = 0; i < num_filters; ++i )
            {
               jccl::ConfigElementPtr pos_elt =
                  e->getProperty<jccl::ConfigElementPtr>("position_filters", i);

               if ( pos_elt->getID() == filter_type )
               {
                  const float unit_conv =
                     pos_elt->getProperty<float>("device_units");

                  vprDEBUG(gadgetDBG_INPUT_MGR, vprDBG_VERB_LVL)
                     << "[gadget::MotionStar::config()] Read " << unit_conv
                     << " as the conversion from device units to meters.\n"
                     << vprDEBUG_FLUSH;

                  // Inches.  This is the most likely configuration as of this
                  // writing.
                  if ( unit_conv == 0.0254f )
                  {
                     expected_units = BIRDNET::INCHES;
                  }
                  // Feet.
                  else if ( unit_conv == 0.3048f )
                  {
                     expected_units = BIRDNET::FEET;
                  }
                  // Meters.
                  else if ( unit_conv == 1.0f )
                  {
                     expected_units = BIRDNET::METERS;
                  }
                  // Unexpected value.
                  else
                  {
                     vprDEBUG(gadgetDBG_INPUT_MGR, vprDBG_CRITICAL_LVL)
                        << "[MotionStar::config(jccl::ConfigElementPtr)] "
                        << clrOutBOLD(clrRED, "ERROR")
                        << ": Unsupported device unit value " << unit_conv
                        << " in " << pos_elt->getFullName() << std::endl
                        << vprDEBUG_FLUSH;
                     vprDEBUG_NEXT(gadgetDBG_INPUT_MGR, vprDBG_CRITICAL_LVL)
                        << "Check your configuration for errors.\n"
                        << vprDEBUG_FLUSH;

                     // Break out of this method early because the
                     // configuration element we were given is bad.
                     return false;
                  }
//.........这里部分代码省略.........
开发者ID:rpavlik,项目名称:vrjuggler-2.2-debs,代码行数:101,代码来源:MotionStar.cpp

示例8: configAdd

   /**
    * Adds the element to the configuration.
    * @pre configCanHandle(element) == true
    */
   bool SoundManagerSonix::configAdd(jccl::ConfigElementPtr element)
   {
      vprDEBUG(vprDBG_ALL, vprDBG_CONFIG_LVL)
         << "======================================\n" << vprDEBUG_FLUSH;
      vprDEBUG(vprDBG_ALL, vprDBG_CONFIG_LVL)
         << "SoundManagerSonix is being configured...\n" << vprDEBUG_FLUSH;

      if (!configCanHandle( element ))
      {
         std::cerr << "ERROR: Wrong element type in SoundManagerSonix\n"
                   << std::flush;
         return false;
      }

      std::string manager_name = element->getName();
      vprDEBUG(vprDBG_ALL, vprDBG_CONFIG_LVL) << "My Name: " << manager_name
                                              << "\n" << vprDEBUG_FLUSH;
      std::string api_to_use = element->getProperty<std::string>( "api" );
      vprDEBUG(vprDBG_ALL, vprDBG_CONFIG_LVL) << "Use API: " << api_to_use
                                              << "\n" << vprDEBUG_FLUSH;

      float listener_position[3];
      listener_position[0] = element->getProperty<float>("listener_position", 0);
      listener_position[1] = element->getProperty<float>("listener_position", 1);
      listener_position[2] = element->getProperty<float>("listener_position", 2);
      vprDEBUG(vprDBG_ALL, vprDBG_CONFIG_LVL)
         << "Listener Position: " << listener_position[0] << ","
         << listener_position[1] << "," << listener_position[2] << std::endl
         << vprDEBUG_FLUSH;

      std::vector<std::string> file_search_path(element->getNum("file_search_path"));

      for ( unsigned int i = 0; i < file_search_path.size(); ++i )
      {
         file_search_path[i] =
            vpr::replaceEnvVars(element->getProperty<std::string>("file_search_path", i));
      }

//      vprDEBUG(vprDBG_ALL, vprDBG_CONFIG_LVL)
//         << "Search path: " << file_search_path << "\n" << vprDEBUG_FLUSH;

      // configure sonix
      snx::sonix::instance()->changeAPI(api_to_use);
      gmtl::Matrix44f mat;
      gmtl::setTrans( mat, gmtl::Vec3f( listener_position[0], listener_position[1], listener_position[2] ) );
      snx::sonix::instance()->setListenerPosition(mat);

      // read the list of sounds
      int size = element->getNum( "sound" );
      vprDEBUG(vprDBG_ALL, vprDBG_CONFIG_LVL) << "Configuring " << size
                                              << " sounds.\n" << vprDEBUG_FLUSH;
      for (int x = 0; x < size; ++x)
      {
         jccl::ConfigElementPtr sound_element =
            element->getProperty<jccl::ConfigElementPtr>("sound", x);
         std::string alias = sound_element->getName();
         std::string filename = sound_element->getProperty<std::string>("filename");
         filename = vpr::replaceEnvVars( filename );
         bool ambient = sound_element->getProperty<bool>("ambient");
         bool retriggerable = sound_element->getProperty<bool>("retriggerable");
         bool streaming = sound_element->getProperty<bool>("streaming");
         int loop = sound_element->getProperty<int>("loop");
         float cutoff = sound_element->getProperty<float>("cutoff");
         float volume = sound_element->getProperty<float>("volume");
         float pitchbend = sound_element->getProperty<float>("pitch_bend");
         float position[3];
         position[0] = sound_element->getProperty<float>("position", 0);
         position[1] = sound_element->getProperty<float>("position", 1);
         position[2] = sound_element->getProperty<float>("position", 2);

         // configure the sound...
         snx::SoundInfo si;
         si.datasource = snx::SoundInfo::FILESYSTEM;
         si.filename = filename;
         si.cutoff = cutoff;
         si.volume = volume;
         si.pitchbend = pitchbend;
         si.repeat = loop;
         si.ambient = ambient;
         si.retriggerable = retriggerable;
         si.streaming = streaming;
         si.position[0] = position[0];
         si.position[1] = position[1];
         si.position[2] = position[2];
         vprDEBUG(vprDBG_ALL, vprDBG_CONFIG_LVL)
            << "- Configuring " << alias << " (" << filename << ")\n"
            << vprDEBUG_FLUSH;
         vprDEBUG(vprDBG_ALL, vprDBG_STATE_LVL)
            << "  + pos(" << position[0] << "," << position[1] << ","
            << position[2] << ")," << "loop(" << loop << "),\n"
            << vprDEBUG_FLUSH;
         vprDEBUG(vprDBG_ALL, vprDBG_STATE_LVL)
            << "  + amb(" << ambient << ")," << "ct(" << cutoff << "),"
            << "vl(" << volume << "),\n" << vprDEBUG_FLUSH;
         vprDEBUG(vprDBG_ALL, vprDBG_STATE_LVL)
            << "  + freq(" << pitchbend << ")," << "retrig(" << retriggerable
//.........这里部分代码省略.........
开发者ID:rpavlik,项目名称:vrjuggler-2.2-debs,代码行数:101,代码来源:SoundManagerSonix.cpp

示例9: configureInputManager

bool InputManager::configureInputManager(jccl::ConfigElementPtr element)
{
   bool have_bad_elt = (element->getID() != std::string("input_manager"));
   vprASSERT(!have_bad_elt);
   if(have_bad_elt)
   {
      return false;
   }

   bool ret_val = false;

   vpr::DebugOutputGuard dbg_output(gadgetDBG_INPUT_MGR, vprDBG_STATE_LVL,
                                    std::string("Handling input_manager element:\n"),
                                    std::string("-- end state -- \n"));

   // Keep this up to date with the version of the element definition we're
   // expecting to handle.
   const unsigned int cur_version(2);

   // If the element version is less than cur_version, we will not try to
   // proceed.  Instead, we'll print an error message and return false so
   // that the Config Manager knows this element wasn't consumed.
   if ( element->getVersion() < cur_version )
   {
      vprDEBUG(gadgetDBG_INPUT_MGR, vprDBG_CRITICAL_LVL)
         << clrOutBOLD(clrRED, "ERROR")
         << ": [gadget::InputManager::configureInputManager()] Element named '"
         << element->getName() << "'" << std::endl << vprDEBUG_FLUSH;
      vprDEBUG_NEXT(gadgetDBG_INPUT_MGR, vprDBG_CRITICAL_LVL)
         << "is version " << element->getVersion()
         << ", but we require at least version " << cur_version
         << std::endl << vprDEBUG_FLUSH;
      vprDEBUG_NEXT(gadgetDBG_INPUT_MGR, vprDBG_CRITICAL_LVL)
         << "Ignoring this element and moving on." << std::endl
         << vprDEBUG_FLUSH;
      ret_val = false;
   }
   // We got the right version of the config element and can proceed.
   else
   {
      const std::string driver_path_prop_name("driver_path");
      const int path_count(element->getNum(driver_path_prop_name));
      std::vector<fs::path> search_path(path_count);

      for ( unsigned int i = 0; i < search_path.size(); ++i )
      {
         std::string temp_str =
            vpr::replaceEnvVars(element->getProperty<std::string>(driver_path_prop_name, i));

         try
         {
            search_path[i] = fs::path(temp_str, fs::native);
         }
         catch(fs::filesystem_error& fsEx)
         {
            vprDEBUG(vprDBG_ERROR, vprDBG_CRITICAL_LVL)
               << clrOutNORM(clrRED, "ERROR")
               << ": [gadget::InputManager::configureInputManager()] File "
               << "system exception caught while converting\n"
               << vprDEBUG_FLUSH;
            vprDEBUG_NEXT(vprDBG_ERROR, vprDBG_CRITICAL_LVL)
               << "'" << temp_str << "'\n" << vprDEBUG_FLUSH;
            vprDEBUG_NEXT(vprDBG_ERROR, vprDBG_CRITICAL_LVL)
               << "to a Boost.Filesystem path.\n" << vprDEBUG_FLUSH;
            vprDEBUG_NEXT(vprDBG_ERROR, vprDBG_CRITICAL_LVL)
               << fsEx.what() << std::endl << vprDEBUG_FLUSH;
         }
      }

      // Append a default driver search path to search_path.
      const fs::path default_search_dir =
         gadget::getDefaultPluginRoot() / std::string("drivers");

      vprDEBUG(gadgetDBG_INPUT_MGR, vprDBG_VERB_LVL)
         << "[gadget::InputManager::configureInputManager()] Appending "
         << "default search path '"
         << default_search_dir.native_directory_string() << "'\n"
         << vprDEBUG_FLUSH;

#if defined(GADGET_DEBUG)
      // For a debug build, search in the debug subdirectory of
      // default_search_dir before looking in default_search_dir.
      search_path.push_back(default_search_dir / std::string("debug"));
#endif

      search_path.push_back(default_search_dir);

      // --- Load device driver dsos -- //
      // - Load individual drivers
      const std::string driver_prop_name("driver");
      const std::string get_version_func("getGadgeteerVersion");
      const std::string driver_init_func("initDevice");

      int driver_count = element->getNum(driver_prop_name);
      std::string driver_dso_name;

      for ( int i = 0; i < driver_count; ++i )
      {
         driver_dso_name =
            element->getProperty<std::string>(driver_prop_name, i);
//.........这里部分代码省略.........
开发者ID:rpavlik,项目名称:vrjuggler-2.2-debs,代码行数:101,代码来源:InputManager.cpp

示例10: configure

void WandInterface::configure(jccl::ConfigElementPtr elt)
{
   vprASSERT(elt->getID() == getElementType());

   const unsigned int req_cfg_version(1);

   if ( elt->getVersion() < req_cfg_version )
   {
      std::ostringstream msg;
      msg << "Configuration of WandInterface failed.  Required config "
          << "element version is " << req_cfg_version << ", but element '"
          << elt->getName() << "' is version " << elt->getVersion();
      throw Exception(msg.str(), VRKIT_LOCATION);
   }

   const std::string pos_name_prop("position_name");
   const std::string digital_name_prop("digital_name");
   const std::string analog_name_prop("analog_name");

   const std::string wand_name = elt->getProperty<std::string>(pos_name_prop);

   if ( wand_name.empty() )
   {
      throw Exception("Empty wand name is not allowed", VRKIT_LOCATION);
   }

   mWandInterface.init(wand_name);

   const unsigned int num_digitals(elt->getNum(digital_name_prop));

   if ( num_digitals > 0 )
   {
      mButtonInterfaces.resize(num_digitals);

      for ( unsigned int d = 0; d < num_digitals; ++d )
      {
         const std::string digital_name =
            elt->getProperty<std::string>(digital_name_prop, d);

         if ( digital_name.empty() )
         {
            mButtonInterfaces.clear();

            std::ostringstream msg_stream;
            msg_stream << "Empty digital name (index " << d
                       << ") is not allowed";
            throw Exception(msg_stream.str(), VRKIT_LOCATION);
         }

         mButtonInterfaces[d].init(digital_name);
      }
   }

   const unsigned int num_analogs(elt->getNum(analog_name_prop));

   if ( num_analogs > 0 )
   {
      mAnalogInterfaces.resize(num_analogs);

      for ( unsigned int a = 0; a < num_analogs; ++a )
      {
         const std::string analog_name =
            elt->getProperty<std::string>(analog_name_prop, a);

         if ( analog_name.empty() )
         {
            mAnalogInterfaces.clear();

            std::ostringstream msg_stream;
            msg_stream << "Empty analog name (index " << a
                       << ") is not allowed";
            throw Exception(msg_stream.str(), VRKIT_LOCATION);
         }

         mAnalogInterfaces[a].init(analog_name);
      }
   }
}
开发者ID:patrickhartling,项目名称:vrkit,代码行数:78,代码来源:WandInterface.cpp


注:本文中的jccl::ConfigElementPtr::getNum方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。