/**
 * Check if the device factory or proxy factory can handle the element.
 */
bool InputManager::configureProxy(jccl::ConfigElementPtr element)
{
   std::string proxy_name = element->getFullName();

vpr::DebugOutputGuard dbg_output(gadgetDBG_INPUT_MGR, vprDBG_STATE_LVL,
                                 std::string("gadget::InputManager::configureProxy: Named: ") + proxy_name + std::string("\n"),
                                 std::string("done configuring proxy\n"));

   Proxy* new_proxy;

   // Tell the factory to load the proxy
   // NOTE: The config for the proxy registers it with the input manager
   new_proxy = ProxyFactory::instance()->loadProxy(element);

   // Check for success
   if(NULL == new_proxy)
   {
      vprDEBUG(vprDBG_ERROR,vprDBG_CRITICAL_LVL)
         << clrOutNORM(clrRED,"ERROR:")
         << " gadget::InputManager::configureProxy: Proxy construction failed:"
         << proxy_name << std::endl << vprDEBUG_FLUSH;
      return false;
   }
   vprASSERT(proxy_name == new_proxy->getName());

   // -- Add to proxy table
   if(false == addProxy(new_proxy))
   {
      return false;
   }

   return true;
}
/**
 * Check if the device factory or proxy factory can handle the element.
 */
bool InputManager::configureDevice(jccl::ConfigElementPtr element)
{
   bool ret_val;
   std::string dev_name = element->getFullName();

   vpr::DebugOutputGuard dbg_output(gadgetDBG_INPUT_MGR, vprDBG_STATE_LVL,
                                 std::string("InputManager::configureDevice: device[") + dev_name + std::string("]\n"),
                                 std::string("done configuring device\n"));

   Input* new_device;
   new_device = DeviceFactory::instance()->loadDevice(element);

   if ((new_device != NULL) && (new_device->startSampling()))
   {
      addDevice(new_device);
      ret_val = true;
      vprDEBUG(gadgetDBG_INPUT_MGR,vprDBG_STATE_LVL)
         << "   Successfully added device: " << dev_name << std::endl
         << vprDEBUG_FLUSH;
   }
   else
   {
      vprDEBUG(vprDBG_ERROR,vprDBG_CRITICAL_LVL) << clrOutNORM(clrRED,"ERROR:")
         << "New device " << clrSetBOLD(clrCYAN) << dev_name << clrRESET
         << " failed to start.  Deleting instance" << std::endl
         << vprDEBUG_FLUSH;
      if ( NULL != new_device )
      {
         delete new_device;
      }

      ret_val = false;
   }

   return ret_val;
}
示例#3
0
bool Proxy::config(jccl::ConfigElementPtr element)
{
   mName = element->getFullName();
   return true;
}
/**
 * Removes the device associated with the given element.
 */
bool InputManager::removeDevice(jccl::ConfigElementPtr element)
{
   return removeDevice(element->getFullName());
}
bool InputManager::removeProxy(jccl::ConfigElementPtr element)
{
   std::string proxy_name;
   proxy_name = element->getFullName();
   return removeProxy(proxy_name);
}