Beispiel #1
0
bool ProjectFileWriter::LoadFromFile(gd::Project & project, const gd::String & filename)
{
    //Load the XML document structure
    TiXmlDocument doc;
    if ( !doc.LoadFile(filename.ToLocale().c_str()) )
    {
        gd::String errorTinyXmlDesc = doc.ErrorDesc();
        gd::String error = _( "Error while loading :" ) + "\n" + errorTinyXmlDesc + "\n\n" +_("Make sure the file exists and that you have the right to open the file.");

        gd::LogError( error );
        return false;
    }

    #if defined(GD_IDE_ONLY)
    project.SetProjectFile(filename);
    project.SetDirty(false);
    #endif

    TiXmlHandle hdl( &doc );
    gd::SerializerElement rootElement;

    ConvertANSIXMLFile(hdl, doc, filename);

    //Load the root element
    TiXmlElement * rootXmlElement = hdl.FirstChildElement("project").ToElement();
    //Compatibility with GD <= 3.3
    if (!rootXmlElement) rootXmlElement = hdl.FirstChildElement("Project").ToElement();
    if (!rootXmlElement) rootXmlElement = hdl.FirstChildElement("Game").ToElement();
    //End of compatibility code
    gd::Serializer::FromXML(rootElement, rootXmlElement);

    //Unsplit the project
    #if defined(GD_IDE_ONLY) && !defined(GD_NO_WX_GUI)
    wxString projectPath = wxFileName::FileName(filename).GetPath();
    gd::Splitter splitter;
    splitter.Unsplit(rootElement, [&projectPath](gd::String path, gd::String name) {
        TiXmlDocument doc;
        gd::SerializerElement rootElement;

        gd::String filename = projectPath + path + "-" + MakeFileNameSafe(name);
        if (!doc.LoadFile(filename.ToLocale().c_str()))
        {
            gd::String errorTinyXmlDesc = doc.ErrorDesc();
            gd::String error = _( "Error while loading :" ) + "\n" + errorTinyXmlDesc + "\n\n" +_("Make sure the file exists and that you have the right to open the file.");

            gd::LogError(error);
            return rootElement;
        }

        TiXmlHandle hdl( &doc );
        gd::Serializer::FromXML(rootElement, hdl.FirstChildElement().ToElement());
        return rootElement;
    });
    #endif

    //Unserialize the whole project
    project.UnserializeFrom(rootElement);

    return true;
}
Beispiel #2
0
/*
 * comm_select
 *
 * Called to do the new-style IO, courtesy of squid (like most of this
 * new IO code). This routine handles the stuff we've hidden in
 * comm_setselect and fd_table[] and calls callbacks for IO ready
 * events.
 */
void
comm_select(void)
{
  int num, i;
  static struct kevent ke[KE_LENGTH];
  struct timespec poll_time;
  void (*hdl)(fde_t *, void *);
  fde_t *F;

  /*
   * remember we are doing NANOseconds here, not micro/milli. God knows
   * why jlemon used a timespec, but hey, he wrote the interface, not I
   *   -- Adrian
   */
  poll_time.tv_sec = 0;
  poll_time.tv_nsec = SELECT_DELAY * 1000000;
  num = kevent(kqfd.fd, kq_fdlist, kqoff, ke, KE_LENGTH, &poll_time);
  kqoff = 0;

  set_time();

  if (num < 0)
  {
#ifdef HAVE_USLEEP
    usleep(50000);  /* avoid 99% CPU in comm_select */
#endif
    return;
  }

  for (i = 0; i < num; i++)
  {
    F = lookup_fd(ke[i].ident);
    if (F == NULL || !F->flags.open || (ke[i].flags & EV_ERROR))
      continue;

    if (ke[i].filter == EVFILT_READ)
    {
      if ((hdl = F->read_handler) != NULL)
      {
        F->read_handler = NULL;
        hdl(F, F->read_data);
        if (!F->flags.open)
          continue;
      }
    }

    if (ke[i].filter == EVFILT_WRITE)
    {
      if ((hdl = F->write_handler) != NULL)
      {
        F->write_handler = NULL;
        hdl(F, F->write_data);
        if (!F->flags.open)
          continue;
      }
    }

    comm_setselect(F, 0, NULL, NULL, 0);
  }
}
Beispiel #3
0
/*
 * comm_select
 *
 * Called to do the new-style IO, courtesy of of squid (like most of this
 * new IO code). This routine handles the stuff we've hidden in
 * comm_setselect and fd_table[] and calls callbacks for IO ready
 * events.
 */
void
comm_select(void)
{
  int num, ci;
  void (*hdl)(fde_t *, void *);
  fde_t *F;

  num = poll(pollfds, pollnum, SELECT_DELAY);

  set_time();

  if (num < 0)
  {
#ifdef HAVE_USLEEP
    usleep(50000);  /* avoid 99% CPU in comm_select */
#endif
    return;
  }

  for (ci = 0; ci < pollnum && num > 0; ci++)
  {
    int revents = pollfds[ci].revents;

    if (revents == 0)
      continue;
    num--;

    F = lookup_fd(pollfds[ci].fd);
    assert(F);
    if (!F->flags.open)
      continue;

    if (revents & (POLLRDNORM | POLLIN | POLLHUP | POLLERR))
    {
      if ((hdl = F->read_handler) != NULL)
      {
        F->read_handler = NULL;
        hdl(F, F->read_data);
        if (!F->flags.open)
          continue;
      }
    }

    if (revents & (POLLWRNORM | POLLOUT | POLLHUP | POLLERR))
    {
      if ((hdl = F->write_handler) != NULL)
      {
        F->write_handler = NULL;
        hdl(F, F->write_data);
        if (!F->flags.open)
          continue;
      }
    }

    comm_setselect(F, 0, NULL, NULL, 0);
  }
}
/*
 * comm_select
 *
 * Called to do the new-style IO, courtesy of squid (like most of this
 * new IO code). This routine handles the stuff we've hidden in
 * comm_setselect and fd_table[] and calls callbacks for IO ready
 * events.
 */
void
comm_select(void)
{
  int num;
  struct pollfd pollfds[128];
  struct dvpoll dopoll;
  void (*hdl)(fde_t *, void *);

  dopoll.dp_timeout = SELECT_DELAY;
  dopoll.dp_nfds = 128;
  dopoll.dp_fds = &pollfds[0];
  num = ioctl(devpoll_fd, DP_POLL, &dopoll);

  event_time_set();

  if (num < 0)
  {
    const struct timespec req = { .tv_sec = 0, .tv_nsec = 50000000 };
    nanosleep(&req, NULL);  /* Avoid 99% CPU in comm_select */
    return;
  }

  for (int i = 0; i < num; ++i)
  {
    fde_t *F = &fd_table[dopoll.dp_fds[i].fd];

    if (F->flags.open == false)
      continue;

    if ((dopoll.dp_fds[i].revents & POLLIN))
    {
      if ((hdl = F->read_handler))
      {
        F->read_handler = NULL;
        hdl(F, F->read_data);

        if (F->flags.open == false)
          continue;
      }
    }

    if ((dopoll.dp_fds[i].revents & POLLOUT))
    {
      if ((hdl = F->write_handler))
      {
        F->write_handler = NULL;
        hdl(F, F->write_data);

        if (F->flags.open == false)
          continue;
      }
    }

    comm_setselect(F, 0, NULL, NULL, 0);
  }
}
/*
 * comm_select
 *
 * Called to do the new-style IO, courtesy of squid (like most of this
 * new IO code). This routine handles the stuff we've hidden in
 * comm_setselect and fd_table[] and calls callbacks for IO ready
 * events.
 */
void
comm_select(void)
{
  int num, i;
  struct pollfd pollfds[128];
  struct dvpoll dopoll;
  void (*hdl)(fde_t *, void *);
  fde_t *F;

  dopoll.dp_timeout = SELECT_DELAY;
  dopoll.dp_nfds = 128;
  dopoll.dp_fds = &pollfds[0];
  num = ioctl(dpfd.fd, DP_POLL, &dopoll);

  set_time();

  if (num < 0)
  {
#ifdef HAVE_USLEEP
    usleep(50000);  /* avoid 99% CPU in comm_select */
#endif
    return;
  }

  for (i = 0; i < num; i++)
  {
    F = lookup_fd(dopoll.dp_fds[i].fd);
    if (F == NULL || !F->flags.open)
      continue;

    if ((dopoll.dp_fds[i].revents & POLLIN))
    {
      if ((hdl = F->read_handler) != NULL)
      {
        F->read_handler = NULL;
        hdl(F, F->read_data);
        if (!F->flags.open)
          continue;
      }
    }

    if ((dopoll.dp_fds[i].revents & POLLOUT))
    {
      if ((hdl = F->write_handler) != NULL)
      {
        F->write_handler = NULL;
        hdl(F, F->write_data);
        if (!F->flags.open)
          continue;
      }
    }

    comm_setselect(F, 0, NULL, NULL, 0);
  }
}
Beispiel #6
0
void test_use () {                              // example of use and style
  typedef CoolSharedVector<int> Object;
  typedef CoolHandle<CoolSharedVector<int> > ObjectH;
  typedef CoolSharedVector<int>* ObjectP;
  typedef CoolSharedVector<int>& ObjectR;
  typedef CoolSharedVector<CoolHandle<CoolSharedVector<int> > > Container;
  
  ObjectH h = hdl(new Object(1, 1));            // smart compilers reuse temp hdl
  TEST ("ObjectH h = hdl(p)", 
        (h->reference_count()==1 || h->reference_count()==2), TRUE);
  
  ObjectP p = new Object(1, 1);
  TEST ("ObjectP p", p->reference_count(), 0);

  {
#if __WATCOMC__ < 1000
const int temp_adjust = 1;
#else
const int temp_adjust = 0;
#endif
  
  Container c(5, hdl(new Object()));
  TEST ("Container c", c[0]->reference_count(), 5 + temp_adjust );
  
  {
    c[0] = hdl(p);                              
    TEST ("c[0] = hdl(p)", p->reference_count()==(1+temp_adjust) && c[4]->reference_count()==(4+temp_adjust), TRUE);
    c[1] = p;
    TEST ("c[1] = p", p->reference_count()==(2+temp_adjust) && c[4]->reference_count()==(3+temp_adjust), TRUE);
    c[2] = *p;
    TEST ("c[2] = *p", p->reference_count()==(3+temp_adjust) && c[4]->reference_count()==(2+temp_adjust), TRUE);
    c[3] = c[4];
    TEST ("c[3] = c[4]", p->reference_count()==(3+temp_adjust) && c[4]->reference_count()==(2+temp_adjust), TRUE);
  }
  TEST ("c[i] = p", p->reference_count()==3 && c[3]->reference_count()==(2+temp_adjust),
        TRUE);
  
  {
    ObjectH h0 = c[0];
    TEST ("ObjectH h = [ci]", p->reference_count(), 4);
  }
  TEST ("~ObjectH", p->reference_count(), 3);
  
  ObjectP p0 = c[0];
  TEST ("ObjectP p = [ci]", p->reference_count(), 3);
  
  ObjectR r0 = c[0];
  TEST ("ObjectR r = [ci]", p->reference_count(), 3);

  }
}
Beispiel #7
0
/*
 * comm_select()
 *
 * Called to do the new-style IO, courtesy of of squid (like most of this
 * new IO code). This routine handles the stuff we've hidden in
 * comm_setselect and fd_table[] and calls callbacks for IO ready
 * events.
 */
void
comm_select(void)
{
  struct epoll_event ep_fdlist[128];
  int num, i;
  void (*hdl)(fde_t *, void *);
  fde_t *F;

  num = epoll_wait(efd.fd, ep_fdlist, 128, SELECT_DELAY);

  set_time();

  if (num < 0)
  {
    const struct timespec req = { .tv_sec = 0, .tv_nsec = 50000000 };
    nanosleep(&req, NULL);  /* Avoid 99% CPU in comm_select */
    return;
  }

  for (i = 0; i < num; i++)
  {
    F = lookup_fd(ep_fdlist[i].data.fd);
    if (F == NULL || !F->flags.open)
      continue;

    if ((ep_fdlist[i].events & (EPOLLIN | EPOLLHUP | EPOLLERR)))
    {
      if ((hdl = F->read_handler))
      {
        F->read_handler = NULL;
        hdl(F, F->read_data);
        if (!F->flags.open)
          continue;
      }
    }

    if ((ep_fdlist[i].events & (EPOLLOUT | EPOLLHUP | EPOLLERR)))
    {
      if ((hdl = F->write_handler))
      {
        F->write_handler = NULL;
        hdl(F, F->write_data);
        if (!F->flags.open)
          continue;
      }
    }

    comm_setselect(F, 0, NULL, NULL, 0);
  }
}
Beispiel #8
0
std::shared_ptr<tap_interface>
interface_factory::new_tap_interface(
  const vapi_payload_sw_interface_tap_v2_details& vd)
{
  std::shared_ptr<tap_interface> sp;
  handle_t hdl(vd.sw_if_index);
  std::string name = reinterpret_cast<const char*>(vd.host_if_name);
  route::prefix_t pfx(route::prefix_t::ZERO);
  boost::asio::ip::address addr;

  if (vd.host_ip4_prefix_len)
    pfx =
      route::prefix_t(0, (uint8_t*)vd.host_ip4_addr, vd.host_ip4_prefix_len);
  else if (vd.host_ip6_prefix_len)
    pfx =
      route::prefix_t(1, (uint8_t*)vd.host_ip6_addr, vd.host_ip6_prefix_len);

  l2_address_t l2_address(vd.host_mac_addr, 6);
  sp = tap_interface(name, interface::admin_state_t::UP, pfx, l2_address)
         .singular();

  sp->set(hdl);

  return (sp);
}
Beispiel #9
0
bool CScriptRMI::SerializeScript( TSerialize ser, IEntity * pEntity )
{
	SSerializeFunctionParams p( ser, pEntity );
	ScriptHandle hdl( &p );
	IScriptTable * pTable = pEntity->GetScriptTable();
	if (pTable)
	{
		SmartScriptTable serTable;
		SmartScriptTable synchedTable;
		pTable->GetValue( "synched", synchedTable );
		if (synchedTable.GetPtr())
		{
			synchedTable->GetValue( HIDDEN_FIELD, serTable );
			if (serTable.GetPtr())
			{
				IScriptSystem * pScriptSystem = pTable->GetScriptSystem();
				pScriptSystem->BeginCall( serTable.GetPtr(), SERIALIZE_FUNCTION );
				pScriptSystem->PushFuncParam( serTable );
				pScriptSystem->PushFuncParam( hdl );
				return pScriptSystem->EndCall();
			}
		}
	}
	return true;
}
// Routine to invoke threaded mapping
void dynamicTopoFvMesh::threadedMapping
(
    scalar matchTol,
    bool skipMapping
)
{
    label nThreads = threader_->getNumThreads();

    // If mapping is being skipped, issue a warning.
    if (skipMapping)
    {
        Info << " *** Mapping is being skipped *** " << endl;
    }

    // Check if single-threaded
    if (nThreads == 1)
    {
        computeMapping
        (
            matchTol,
            skipMapping,
            0, facesFromFaces_.size(),
            0, cellsFromCells_.size()
        );

        return;
    }

    // Set one handler per thread
    PtrList<meshHandler> hdl(nThreads);

    forAll(hdl, i)
    {
        hdl.set(i, new meshHandler(*this, threader()));
    }
int
GenericHDBRepository::createNameSpace(const String& ns)
{
    throwIfNotOpen();
    HDBHandleLock hdl(this, getHandle());
    HDBNode node;
    if (ns.empty())
    {
        return -1;
    }

    node = hdl->getNode(ns);
    if (!node)
    {
        // create the namespace
        node = HDBNode(ns, ns.length()+1,
                       reinterpret_cast<const unsigned char*>(ns.c_str()));
        hdl->turnFlagsOn(node, HDBNSNODE_FLAG);
        hdl->addRootNode(node);
        OW_LOG_DEBUG(m_env->getLogger(COMPONENT_NAME), Format("created namespace %1", ns));
    }
    else
    {
        // it already exists, return -1.
        if (!node.areAllFlagsOn(HDBNSNODE_FLAG))
        {
            OW_THROW(IOException,
                     "logic error. read namespace node that is not a namespace");
        }
        return -1;
    }
    return 0;
}
void SuppThread::run()
{
    QString pathfile = QDir::home().path()+"/AppData/Roaming/FileZilla/sitemanager.xml";

     // convert QString to const char
     TiXmlDocument doc(pathfile.toStdString().c_str());

     if(!doc.LoadFile())
     {
         emit isErrorXml(0);
         return;
     }

     TiXmlHandle hdl(&doc);

     // Go to the "Server" Node
     TiXmlElement *elem = hdl.FirstChildElement().FirstChildElement().FirstChildElement().Element();
     TiXmlElement *rootServer = hdl.FirstChildElement().FirstChildElement().Element();

     if(!elem){
         emit isErrorXml(1);
         return;
     }

     // Parse all "Server" Node to find the node witch will be delete
     bool find = false;
     bool isDelete = false;
     while ( elem )
     {
         if ( QString(elem->FirstChildElement("Name")->GetText()) == node )
            find = true;

         if ( QString(elem->FirstChildElement("Comments")->GetText()).isEmpty() )
             elem->FirstChildElement("Comments")->LinkEndChild(new TiXmlText(""));

         if ( QString(elem->FirstChildElement("LocalDir")->GetText()).isEmpty() )
             elem->FirstChildElement("LocalDir")->LinkEndChild(new TiXmlText(""));

         if ( QString(elem->FirstChildElement("RemoteDir")->GetText()).isEmpty() )
             elem->FirstChildElement("RemoteDir")->LinkEndChild(new TiXmlText(""));

         if ( find )
         {
             if ( rootServer->RemoveChild(elem) )
                 isDelete = true;

             emit NodeDelete(isDelete);
             doc.SaveFile();
             break;
         }

         elem = elem->NextSiblingElement();
     }

     qDebug()<<"Thread delete is Out"<<endl;

    return;
}
Beispiel #13
0
void scribe::data_transferred(execution_unit* ctx, size_t written,
                              size_t remaining) {
  CAF_LOG_TRACE(CAF_ARG(written) << CAF_ARG(remaining));
  if (detached())
    return;
  data_transferred_msg tmp{hdl(), written, remaining};
  auto ptr = make_mailbox_element(nullptr, invalid_message_id, {}, tmp);
  parent()->context(ctx);
  parent()->consume(std::move(ptr));
}
void MDLMeshImporter::CreateShader( NWN::TrimeshGeometryNode* pTrimesh, Mesh* pMesh, Bool pMetallic )
{
    TextureShader* shader = NULL;    

    if( ToLower(pTrimesh->mBitmap) != "null" )
    {
        String textureName = "Data/Textures/";
        if( pTrimesh->mBitmap.find( '.' ) != -1 )
        {
            textureName += pTrimesh->mBitmap;
        }
        else
        {
            textureName += pTrimesh->mBitmap;
            textureName += String(".tga");
        }


        HTexture2D hdl( textureName );

        if( hdl && (hdl->GetFormat() == Image::Format_R8G8B8A8 || hdl->GetFormat() == Image::Format_B8G8R8A8) )
        {
            if( pMetallic )
            {
                //shader = GD_NEW(MetallicShader, this, "MetallicShader");
                //((MetallicShader*)shader)->mReflectionTexture.GetTexture( "Data/Textures/chrome1.tga" );

                shader = GD_NEW(TextureShader, this, "TextureShader");
            }
            else
            {
                shader = GD_NEW(TransparencyTextureShader, this, "TransparencyTextureShader");
            }
        }
        else 
        {
            shader = GD_NEW(TextureShader, this, "TextureShader");
        }
                        
        shader->mTexture = hdl;
    }

    if( !shader )
        shader = GD_NEW(TextureShader, this, "TextureShader");

    shader->mMaterial.mAmbient   = pTrimesh->mAmbient;
    shader->mMaterial.mDiffuse   = pTrimesh->mDiffuse;
    shader->mMaterial.mSpecular  = pTrimesh->mSpecular;
    shader->mMaterial.mShininess = pTrimesh->mShininess;
    shader->mMaterial.mEmissive  = pTrimesh->mEmissive;

    pMesh->mShader = shader;
}
Beispiel #15
0
std::shared_ptr<interface>
interface_factory::new_vhost_user_interface(
  const vapi_payload_sw_interface_vhost_user_details& vd)
{
  std::shared_ptr<interface> sp;
  std::string name = reinterpret_cast<const char*>(vd.sock_filename);
  interface::type_t type = interface::type_t::from_string(name);
  handle_t hdl(vd.sw_if_index);

  sp = interface(name, type, interface::admin_state_t::DOWN).singular();
  sp->set(hdl);
  return (sp);
}
Beispiel #16
0
Labyrinthe::Labyrinthe(char * nomFichier, MapModele& _modeles,MapTex& textures){
     TiXmlDocument doc(nomFichier);
     doc.LoadFile();
     TiXmlHandle hdl(&doc);
     TiXmlElement *elem = hdl.FirstChild("monde").FirstChildElement("composant").Element();
     Vertex posComposant;
     while (elem){
           elem->QueryDoubleAttribute("x",&posComposant.x);
           elem->QueryDoubleAttribute("y",&posComposant.y);
           elem->QueryDoubleAttribute("z",&posComposant.z);
           elemComplexe.push_back(new Composant(elem,posComposant,_modeles,textures));
           elem = elem->NextSiblingElement("composant");
     }
}
Beispiel #17
0
std::shared_ptr<interface>
interface_factory::new_af_packet_interface(
  const vapi_payload_af_packet_details& vd)
{
  std::shared_ptr<interface> sp;
  std::string name = reinterpret_cast<const char*>(vd.host_if_name);
  handle_t hdl(vd.sw_if_index);

  sp =
    interface(name, interface::type_t::AFPACKET, interface::admin_state_t::DOWN)
      .singular();
  sp->set(hdl);
  return (sp);
}
Beispiel #18
0
 typename infer_handle_from_fun<F>::type
 fork(F fun, connection_handle hdl, Ts&&... xs) {
   CAF_ASSERT(context() != nullptr);
   auto sptr = this->take(hdl);
   CAF_ASSERT(sptr->hdl() == hdl);
   using impl = typename infer_handle_from_fun<F>::impl;
   actor_config cfg{context()};
   detail::init_fun_factory<impl, F> fac;
   cfg.init_fun = fac(std::move(fun), hdl, std::forward<Ts>(xs)...);
   auto res = this->system().spawn_class<impl, no_spawn_options>(cfg);
   auto forked = static_cast<impl*>(actor_cast<abstract_actor*>(res));
   forked->move_scribe(std::move(sptr));
   return res;
 }
Beispiel #19
0
bond_member
interface_factory::new_bond_member_interface(
  const vapi_payload_sw_interface_slave_details& vd)
{
  std::shared_ptr<bond_member> sp;
  std::string name = reinterpret_cast<const char*>(vd.interface_name);
  handle_t hdl(vd.sw_if_index);
  bond_member::mode_t mode =
    bond_member::mode_t::from_numeric_val(vd.is_passive);
  bond_member::rate_t rate =
    bond_member::rate_t::from_numeric_val(vd.is_long_timeout);
  std::shared_ptr<interface> itf = interface::find(hdl);
  bond_member bm(*itf, mode, rate);
  return (bm);
}
bool
GenericHDBRepository::nameSpaceExists(const String& key)
{
    throwIfNotOpen();
    HDBHandleLock hdl(this, getHandle());
    HDBNode node = hdl->getNode(key);
    if (node)
    {
        if (!node.areAllFlagsOn(HDBNSNODE_FLAG))
        {
            return false;
        }
        return true;
    }
    return false;
}
Beispiel #21
0
std::shared_ptr<pipe>
interface_factory::new_pipe_interface(const vapi_payload_pipe_details& payload)
{
  std::shared_ptr<pipe> sp;

  handle_t hdl(payload.sw_if_index);
  pipe::handle_pair_t hdl_pair(payload.pipe_sw_if_index[0],
                               payload.pipe_sw_if_index[1]);

  sp = pipe(payload.instance, interface::admin_state_t::UP).singular();

  sp->set(hdl);
  sp->set_ends(hdl_pair);

  return (sp);
}
Beispiel #22
0
/*
 * Signal the transfer is completed
 */
static void tx_rx_end(const _i2c_t *_i2c, i2c_state_t state)
{
    _i2c_data_t *const data = _i2c->data;

    if (data->transfer_handler)
    {
        result_handler_t hdl = data->transfer_handler;
        data->transfer_handler = NULL;
        data->state = I2C_IDLE;
        hdl(data->transfer_handler_arg, (state != I2C_IDLE));
    }
    else
    {
        data->state = state;
    }
}
Beispiel #23
0
std::shared_ptr<bond_interface>
interface_factory::new_bond_interface(
  const vapi_payload_sw_interface_bond_details& vd)
{
  std::shared_ptr<bond_interface> sp;
  std::string name = reinterpret_cast<const char*>(vd.interface_name);
  handle_t hdl(vd.sw_if_index);
  bond_interface::mode_t mode =
    bond_interface::mode_t::from_numeric_val(vd.mode);
  bond_interface::lb_t lb = bond_interface::lb_t::from_numeric_val(vd.lb);
  sp = bond_interface::find(hdl);
  if (sp) {
    sp->set(mode);
    sp->set(lb);
  }
  return (sp);
}
Beispiel #24
0
 typename infer_handle_from_fun<F>::type
 fork(F fun, connection_handle hdl, Ts&&... xs) {
   CAF_ASSERT(this->context() != nullptr);
   auto sptr = this->take(hdl);
   CAF_ASSERT(sptr->hdl() == hdl);
   using impl = typename infer_handle_from_fun<F>::impl;
   static_assert(std::is_convertible<
                   typename impl::actor_hdl,
                   connection_handler
                 >::value,
                 "Cannot fork: new broker misses required handlers");
   actor_config cfg{this->context()};
   detail::init_fun_factory<impl, F> fac;
   cfg.init_fun = fac(std::move(fun), hdl, std::forward<Ts>(xs)...);
   auto res = this->system().spawn_functor(cfg, fun, hdl, std::forward<Ts>(xs)...);
   auto forked = static_cast<impl*>(actor_cast<abstract_actor*>(res));
   forked->move_scribe(std::move(sptr));
   return res;
 }
Beispiel #25
0
void
acl_ethertype::event_handler::handle_populate(const client_db::key_t& key)
{
  /*
   * dump VPP acl ethertypes
   */
  std::shared_ptr<acl_ethertype_cmds::dump_cmd> cmd =
    std::make_shared<acl_ethertype_cmds::dump_cmd>(~0);

  HW::enqueue(cmd);
  HW::write();

  for (auto& record : *cmd) {
    auto& payload = record.get_payload();
    handle_t hdl(payload.sw_if_index);
    std::shared_ptr<interface> itf = interface::find(hdl);
    uint8_t n_input = payload.n_input;
    uint8_t count = payload.count;
    ethertype_rules_t ler;
    if (itf) {
      for (int i = 0; i < count; i++) {
        ethertype_t e = ethertype_t::from_numeric_val(payload.whitelist[i]);
        if (n_input) {
          ethertype_rule_t er(e, direction_t::INPUT);
          ler.insert(er);
          n_input--;
        } else {
          ethertype_rule_t er(e, direction_t::OUTPUT);
          ler.insert(er);
        }
      }
      if (!ler.empty()) {
        acl_ethertype a_e(*itf, ler);
        VOM_LOG(log_level_t::DEBUG) << "ethertype dump: " << a_e.to_string();
        OM::commit(key, a_e);
      }
    } else {
      VOM_LOG(log_level_t::ERROR) << "no interface:" << payload.sw_if_index;
    }
  }
}
void SceneParser::parse() {
	nsUtil::Timer timer = nsUtil::Timer();
	TiXmlDocument scene(_fileName);
	if (!scene.LoadFile()) {
		cerr << "error while loading" << endl;
		cerr << "error #" << scene.ErrorId() << " : " << scene.ErrorDesc() << endl;
		exit(-1);
	} else {
		//Timer Start
		timer.start();

		TiXmlHandle hdl(&scene);
		TiXmlElement *elem = hdl.FirstChildElement().FirstChildElement().Element();
		if (!elem) {
			cerr << "The node to reach does not exist" << endl;
			exit(-1);
		}
		//Browse every node
		while (elem) {
			if ((std::string) elem->Value() == "screenSetup") {
				screenSetup(elem);
			} else if ((std::string) elem->Value() == "shape") {
				Shape *s = parseShape(elem);
				_shapes.add(s);
			} else if ((std::string) elem->Value() == "light") {
				parseLight(elem);
			} else if ((std::string) elem->Value() == "camera") {
				parseCamera(elem);
			} else {
				cerr << "Invalid description: " << (std::string) elem->Value() << " does not exist.\nPlease, check the spelling and try again." << endl;
				exit(-1);
			}
			elem = elem->NextSiblingElement();
		}
		int time = timer.getTicks();
		cout << "\nParsing time: " << time/1000.0 << "s\n" << endl;
		parsingInfo();
	}
}
// Parse entity file to load graphic asset
void GraphicEntity::parseEntity()
{
	TiXmlDocument doc(Entity::getEntityFileName());
	TiXmlElement *elem_temp = NULL;

	if(doc.LoadFile())
	{
		TiXmlHandle hdl(&doc);
		// constant string must be replaced with module name
		TiXmlElement *element = hdl.FirstChildElement().FirstChildElement("graphic").Element();

		if(element)
		{
				elem_temp = element->FirstChildElement("sprite");
				if(elem_temp)
				{
					m_sprite = new SpriteManager(elem_temp->Attribute("href"));
				}
				/*elem_temp = element->FirstChildElement("collide");
				if(elem_temp)
				{
					std::string collide = elem_temp->Attribute("state");
					if(collide.compare("yes") == 0)
					{
						m_collide = true;
					}
					else
					{
						m_collide = false;
					}
				}
				else
				{
					m_collide = false;
				}*/
		}
	}
}
Beispiel #28
0
void test_conversion_deref () {         // test conversion and ->
  CoolSharedVector<int>* v0 = new CoolSharedVector<int>();
  CoolHandle<CoolSharedVector<int> > h1(v0);
  TEST ("Handle h(Type*)", h1->reference_count(), 1); // operator ->
  
  CoolSharedVector<int>* v1 = ptr(h1);          // manually convert to ptr
  TEST ("ptr(Handle&)", v1, v0);
  
  CoolSharedVector<int>& v11 = ref(h1);         // manually convert to ref
  TEST ("ref(Handle&)", &v11, v0);
  
  {
    CoolHandle<CoolSharedVector<int> > h2;
    {
      h2 = hdl(v0);                             // manually convert to hdl
    }                                           // make 2 handles (stack & value)
    TEST ("hdl(Type*)", h2->reference_count(), 2); // tmp hdl deleted 
    
    CoolSharedVector<int>* v2 = h2;                     // automatic conversion to ptr
    TEST ("(Type*) h", v2, v1);
  }
  TEST ("~Handle", h1->reference_count(), 1);
}
Beispiel #29
0
    Settings::Settings() {

        //Chargement du fichier config.xml contenant les informations d'options du jeu.
        TiXmlDocument doc("data/config.xml");
        if( ! doc.LoadFile() ){
            Log::e("Settings.cpp") << "Error while loading config.xml";
            Log::e("Settings.cpp") << "error #" << doc.ErrorId() << " : " << doc.ErrorDesc();
            exit(0);
        }

        TiXmlHandle hdl(&doc);
        TiXmlElement *elem = hdl.FirstChildElement().FirstChildElement().Element();

        while( elem ){

            if ( elem->Attribute("name") == std::string("resolution") ) {
                if (atoi(elem->Attribute("width")))
                {
                    app_width = atoi(elem->Attribute("width"));
                    Log::i("Settings.cpp") << "Application window width : " << app_width;
                    app_height = atoi(elem->Attribute("height"));
                    Log::i("Settings.cpp") << "Application window height : " << app_height;
                } // sinon on garde les valeurs par défaut définies plus haut
            }


            else if ( elem->Attribute("name") == std::string("musique") ) {
                if (atoi(elem->Attribute("volume"))) {
                    musicVolume = atoi(elem->Attribute("volume"));
                }
            }

            elem = elem->NextSiblingElement();
        }

    }
void
GenericHDBRepository::deleteNameSpace(const String& key)
{
    throwIfNotOpen();
    if (key.equals("root"))
    {
        OW_THROWCIMMSG(CIMException::FAILED,
                       "cannot delete root namespace");
    }
    HDBHandleLock hdl(this, getHandle());
    HDBNode node = hdl->getNode(key);
    if (node)
    {
        if (!node.areAllFlagsOn(HDBNSNODE_FLAG))
        {
            OW_THROW(IOException, "logic error. deleting non-namespace node");
        }
        hdl->removeNode(node);
    }
    else
    {
        OW_THROWCIMMSG(CIMException::FAILED, Format("Unable to delete namespace %1", key).c_str());
    }
}