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


C++ shared_ptr::reset方法代码示例

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


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

示例1: boot

int boot(int argc, char *args[]) {
    screen.reset(new P47Screen());
    pad.reset(new Pad());
    try {
        pad->openJoystick();
    } catch (const exception& e) {}
    gameManager.reset(new P47GameManager());
    prefManager.reset(new P47PrefManager());
    mainLoop.reset(new MainLoop(screen, pad, gameManager, prefManager));
    try {
        parseArgs(argc, args);
    } catch (const exception& e) {
        return EXIT_FAILURE;
    }
    mainLoop->loop();
    return EXIT_SUCCESS;
}
开发者ID:,项目名称:,代码行数:17,代码来源:

示例2: mount_sshfs

  sshfs_t filesystem_adaptor::mount_sshfs (const saga::session & s, const saga::url & u )
  {
    saga::url   tgt = u;

    // if url is any:// based, convert to ssh:// as expected by sshfs
    if ( tgt.get_scheme () == "any" )
    {
      tgt.set_scheme ("ssh");
    }

    std::string id  = get_sshfs_id (tgt);

    
    // std::cout << " mounted_        mount  :  " << this             << std::endl;
    // std::cout << " mounted_.size() mount 1:  " << mounted_.size () << std::endl;
    // std::cout << " tested__.size() mount 1:  " << tested__.size () << std::endl;

    // check if we have that mounted already
    if ( mounted_.find (id) != mounted_.end () )
    {
      // make sure the fs is mounted
      mounted_[id]->mount ();

      return mounted_[id];
    }

    // is not mounted, yet - try to mount it, store a new shared pointer, and
    // return it.
    SAGA_LOG_ALWAYS ("to mount new sshfs");
    SAGA_LOG_ALWAYS (id.c_str ());
    SAGA_LOG_ALWAYS (tgt.get_string ().c_str ());

    TR1::shared_ptr <sshfs> ptr;
    try 
    {
      ptr.reset (new sshfs (ini_, s, tgt));
    }
    catch ( const saga::exception & e )
    {
      SAGA_LOG_ERROR (e.what ());
      std::stringstream ss;
      ss << "Could not mount sshfs for " << tgt << " : \n  " << e.what () <<
        std::endl;
      SAGA_ADAPTOR_THROW_NO_CONTEXT (ss.str ().c_str (), saga::BadParameter);
    }

    if ( ! ptr )
    {
      // cannot mount the fs for some reason - throw a BadParameter
      SAGA_ADAPTOR_THROW_NO_CONTEXT ("sshfs mount failed for unknown reason",
                                     saga::NoSuccess);
    }

    // std::cout << " mounted_.size() mount 2:  " << mounted_.size () << std::endl;
    // std::cout << " tested__.size() mount 2:  " << tested__.size () << std::endl;

    // got the fs mounted - register it, and return the ptr
    mounted_[id] = ptr;
    tested__[id] = 1;
    SAGA_LOG_ALWAYS ("register mounted sshfs");
    SAGA_LOG_ALWAYS (id.c_str ());

    // std::cout << " === register mounted sshfs: " << id << std::endl;
    // std::cout << " mounted_.size() mount 3:  " << mounted_.size () << std::endl;
    // std::cout << " tested__.size() mount 3:  " << tested__.size () << std::endl;

    return ptr;
  }
开发者ID:carriercomm,项目名称:saga-cpp-adaptor-ssh,代码行数:68,代码来源:sshfs_file_adaptor.cpp


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