• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ shared_from_this函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中shared_from_this函数的典型用法代码示例。如果您正苦于以下问题:C++ shared_from_this函数的具体用法?C++ shared_from_this怎么用?C++ shared_from_this使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: TcpConnection

void my::GateServer::handle_accept(ConnectionPtr conn, boost::system::error_code err)
{
	if (err)
	{
		LogE << err.message() << LogEnd;
		conn->getSocket().close();
		ConnectionPtr nextConn = boost::shared_ptr<TcpConnection>(new TcpConnection(core.getService(), m_GateHandler, shared_from_this()));
		m_pAcceptor->async_accept(nextConn->getSocket(), boost::bind(&GateServer::handle_accept, this, nextConn, boost::asio::placeholders::error));
	}
	else
	{
		//new incomming player!!!
		LogD << conn->getSocket().remote_endpoint().address() << " " << conn->getSocket().remote_endpoint().port() << LogEnd;

		boost::recursive_mutex::scoped_lock lock(mtx);
		conn->setNetId(m_nNetIdHolder);
		ip::tcp::no_delay option(true);
		conn->getSocket().set_option(option);
		m_ConnMap.insert(std::make_pair<int, ConnectionPtr>(m_nNetIdHolder, conn));		
		conn->start();
		m_nNetIdHolder = (m_nNetIdHolder + 1) % MAX_NET_ID;
		m_nConnCount++;
			
		ConnectionPtr nextConn = boost::shared_ptr<TcpConnection>(new TcpConnection(core.getService(), m_GateHandler, shared_from_this()));
		m_pAcceptor->async_accept(nextConn->getSocket(), boost::bind(&GateServer::handle_accept, this, nextConn, boost::asio::placeholders::error));
	}
}
开发者ID:elenno,项目名称:MyServer,代码行数:27,代码来源:gateServer.cpp


示例2: FilterImpl

CrowdDetectorFilterImpl::CrowdDetectorFilterImpl (
  const std::vector<std::shared_ptr<RegionOfInterest>> &rois,
  std::shared_ptr< MediaObjectImpl > parent) :
  FilterImpl (parent)
{
  GstBus *bus;
  std::shared_ptr<MediaPipelineImpl> pipe;
  GstStructure *roisStructure;

  pipe = std::dynamic_pointer_cast<MediaPipelineImpl> (getMediaPipeline() );

  g_object_set (element, "filter-factory", "crowddetector", NULL);

  bus = gst_pipeline_get_bus (GST_PIPELINE (pipe->getPipeline() ) );

  g_object_get (G_OBJECT (element), "filter", &crowdDetector, NULL);

  if (crowdDetector == NULL) {
    g_object_unref (bus);
    throw KurentoException (MEDIA_OBJECT_NOT_AVAILABLE,
                            "Media Object not available");
  }

  roisStructure = gst_structure_new_empty  ("Rois");

  for (auto roi : rois) {
    GstStructure *roiStructureAux = get_structure_from_roi (roi);

    gst_structure_set (roisStructure,
                       roi->getId().c_str(), GST_TYPE_STRUCTURE,
                       roiStructureAux,
                       NULL);

    gst_structure_free (roiStructureAux);
  }

  g_object_set (G_OBJECT (crowdDetector), ROIS_PARAM, roisStructure, NULL);
  gst_structure_free (roisStructure);

  busMessageLambda = [&] (GstMessage * message) {
    const GstStructure *st;
    gchar *roiID;
    const gchar *type;
    std::string roiIDStr, typeStr;

    if (GST_MESSAGE_SRC (message) != GST_OBJECT (crowdDetector) ||
        GST_MESSAGE_TYPE (message) != GST_MESSAGE_ELEMENT) {
      return;
    }

    st = gst_message_get_structure (message);
    type = gst_structure_get_name (st);

    if (!gst_structure_get (st, "roi", G_TYPE_STRING , &roiID, NULL) ) {
      GST_WARNING ("The message does not contain the roi ID");
      return;
    }

    roiIDStr = roiID;
    typeStr = type;

    g_free (roiID);

    if (typeStr == "fluidity-event") {

      double fluidity_percentage;
      int fluidity_level;

      if (! (gst_structure_get (st, "fluidity_percentage", G_TYPE_DOUBLE,
                                &fluidity_percentage, NULL) ) ) {
        GST_WARNING ("The message does not contain the fluidity percentage");
        return;
      }

      if (! (gst_structure_get (st, "fluidity_level", G_TYPE_INT,
                                &fluidity_level, NULL) ) ) {
        GST_WARNING ("The message does not contain the fluidity level");
        return;
      }

      try {
        CrowdDetectorFluidity event (fluidity_percentage, fluidity_level, roiIDStr,
                                     shared_from_this(),
                                     CrowdDetectorFluidity::getName() );
        signalCrowdDetectorFluidity (event);
      } catch (std::bad_weak_ptr &e) {
      }
    } else if (typeStr == "occupancy-event") {

      double occupancy_percentage;
      int occupancy_level;

      if (! (gst_structure_get (st, "occupancy_percentage", G_TYPE_DOUBLE,
                                &occupancy_percentage, NULL) ) ) {
        GST_WARNING ("The message does not contain the occupancy percentage");
        return;
      }

      if (! (gst_structure_get (st, "occupancy_level", G_TYPE_INT,
                                &occupancy_level, NULL) ) ) {
//.........这里部分代码省略.........
开发者ID:apismontana,项目名称:kurento-media-server,代码行数:101,代码来源:CrowdDetectorFilterImpl.cpp


示例3: forwardProperty

void Node::forwardProperty(int ourProperty, std::shared_ptr<Node> toNode, int toProperty) {
	forwarded_properties[ourProperty] = std::make_tuple(toNode, toProperty);
	toNode->addPropertyBackref(toProperty, std::static_pointer_cast<Node>(shared_from_this()), ourProperty);
	simulation->invalidatePlan();
}
开发者ID:moshverhavikk,项目名称:libaudioverse,代码行数:5,代码来源:node.cpp


示例4:

std::shared_ptr<base::IBlock> BlockFS::block() const {
    return std::const_pointer_cast<BlockFS>(shared_from_this());
}
开发者ID:G-Node,项目名称:nix,代码行数:3,代码来源:BlockFS.cpp


示例5:

neb::fnd::app::Base * const		THIS::get_fnd_app()
{
	auto a = std::dynamic_pointer_cast<neb::fnd::app::Base>(shared_from_this());

	return a.get();
}
开发者ID:nebula-engine,项目名称:Nebula-Core,代码行数:6,代码来源:Parent.cpp


示例6: plugin_tkn


//.........这里部分代码省略.........
            std::vector<OSG::FieldContainerType*> core_types;
            const unsigned int num_types = model_elt->getNum(core_type_tkn);
            for ( unsigned int t = 0; t < num_types; ++t )
            {
               const std::string type_name = 
                  model_elt->getProperty<std::string>(core_type_tkn, i);
               OSG::FieldContainerType* fct =
                  OSG::FieldContainerFactory::the()->findType(
                     type_name.c_str()
                  );

               if ( NULL != fct )
               {
                  core_types.push_back(fct);
               }
               else
               {
                  VRKIT_STATUS << "Skipping unknown type '" << type_name
                               << "'" << std::endl;
               }
            }

            DynamicSceneObjectPtr scene_obj;

            if ( ! core_types.empty() )
            {
               util::CoreTypePredicate pred(core_types);
               scene_obj = DynamicSceneObject::create()->init(model_node,
                                                              pred, true);
            }
            else
            {
               scene_obj =
                  DynamicSceneObjectTransform::create()->init(model_node);
            }

            // scene_obj's root will be added as a child of
            // scene_xform_root.
            child_root = scene_obj->getRoot();
            scene_obj->moveTo(xform_mat_osg);
            viewer->addObject(scene_obj);
         }
         // If this model is not supposed to be grabbable, we examine the
         // core of the root node.
         else
         {
            OSG::NodeCorePtr root_core = model_node->getCore();
            OSG::TransformPtr xform_core =
#if OSG_MAJOR_VERSION < 2
               OSG::TransformPtr::dcast(root_core);
#else
               OSG::cast_dynamic<OSG::TransformPtr>(root_core);
#endif

            // If model_node's core is of type OSG::Transform, then we set
            // set the matrix on that core to be xform_mat_osg.
            if ( OSG::NullFC != xform_core )
            {
#if OSG_MAJOR_VERSION < 2
               OSG::CPEditor xce(xform_core, OSG::Transform::MatrixFieldMask);
#endif
               xform_core->setMatrix(xform_mat_osg);

               // model_node will be added as a child of scene_xform_root.
               child_root = model_node;
            }
            // If model_node's core is not of type OSG::Transform, then we
            // need to make a new node with an OSG::Transform core and make
            // it the parent of model_node.
            else
            {
               OSG::TransformNodePtr xform_node(OSG::Transform::create());

#if OSG_MAJOR_VERSION < 2
               OSG::CPEditor xnce(xform_node.core(),
                                  OSG::Transform::MatrixFieldMask);
#endif
               xform_node->setMatrix(xform_mat_osg);

#if OSG_MAJOR_VERSION < 2
               OSG::CPEditor xne(xform_node.node(),
                                 OSG::Node::ChildrenFieldMask);
#endif
               xform_node.node()->addChild(model_node);

               // xform_node will be added as a child of scene_xform_root.
               child_root = xform_node.node();
            }
         }

         vprASSERT(child_root != OSG::NullFC);

         // The OSG::{begin,end}EditCP() calls for scene_xform_root wrap
         // the for loop that we are in.
         scene_xform_root.node()->addChild(child_root);
      }
   }

   return shared_from_this();
}
开发者ID:patrickhartling,项目名称:vrkit,代码行数:101,代码来源:ModelLoaderPlugin.cpp


示例7: getName

bool Subscription::negotiateConnection(const std::string& xmlrpc_uri)
{


  XmlRpcValue tcpros_array, protos_array, params;
  XmlRpcValue udpros_array;
  ros::TransportUDPPtr udp_transport;
  int protos = 0;
  ros::V_string transports = transport_hints_.getTransports();
  if (transports.empty())
  {
    transport_hints_.reliable();
    transports = transport_hints_.getTransports();
  }
  for (ros::V_string::const_iterator it = transports.begin();
       it != transports.end();
       ++it)
  {
    if (*it == "UDP")
    {
      int max_datagram_size = transport_hints_.getMaxDatagramSize();
      udp_transport = ros::TransportUDPPtr(new ros::TransportUDP(&ros::PollManager::instance()->getPollSet()));
      if (!max_datagram_size)
        max_datagram_size = udp_transport->getMaxDatagramSize();
      udp_transport->createIncoming(0, false);
      udpros_array[0] = "UDPROS";
      M_string m;
      m["topic"] = getName();
      m["md5sum"] = md5sum();
      m["callerid"] = ros::this_node::getName();
      m["type"] = datatype();
      boost::shared_array<uint8_t> buffer;
      uint32_t len;
      ros::Header::write(m, buffer, len);
      XmlRpcValue v(buffer.get(), len);
      udpros_array[1] = v;
      udpros_array[2] = ros::network::getHost();
      udpros_array[3] = udp_transport->getServerPort();
      udpros_array[4] = max_datagram_size;

      protos_array[protos++] = udpros_array;
    }
    else if (*it == "TCP")
    {
      tcpros_array[0] = std::string("TCPROS");
      protos_array[protos++] = tcpros_array;
    }
    else
    {
      ROS_WARN("Unsupported transport type hinted: %s, skipping", it->c_str());
    }
  }
  params[0] = ros::this_node::getName();
  params[1] = name_;
  params[2] = protos_array;
  std::string peer_host;
  uint32_t peer_port;
  if (!ros::network::splitURI(xmlrpc_uri, peer_host, peer_port))
  {
    ROS_ERROR("Bad xml-rpc URI: [%s]", xmlrpc_uri.c_str());
    return false;
  }

  XmlRpcClient* c = new XmlRpcClient(peer_host.c_str(),
                                                     peer_port, "/");
 // if (!c.execute("requestTopic", params, result) || !g_node->validateXmlrpcResponse("requestTopic", result, proto))

  // Initiate the negotiation.  We'll come back and check on it later.
  if (!c->executeNonBlock("requestTopic", params))
  {
    ROSCPP_LOG_DEBUG("Failed to contact publisher [%s:%d] for topic [%s]",
              peer_host.c_str(), peer_port, name_.c_str());
    delete c;
    if (udp_transport)
    {
      udp_transport->close();
    }

    return false;
  }

  ROSCPP_LOG_DEBUG("Began asynchronous xmlrpc connection to [%s:%d]", peer_host.c_str(), peer_port);

  // The PendingConnectionPtr takes ownership of c, and will delete it on
  // destruction.
  PendingConnectionPtr conn(new PendingConnection(c, udp_transport, shared_from_this(), xmlrpc_uri));

//ROS_INFO("add connection to xmlrpcmanager");

  XMLRPCManager::instance()->addASyncConnection(conn);
  // Put this connection on the list that we'll look at later.
  {
    boost::mutex::scoped_lock pending_connections_lock(pending_connections_mutex_);
    pending_connections_.insert(conn);
  }

  return true;
}
开发者ID:Formal-Systems-Laboratory,项目名称:ROSRV,代码行数:98,代码来源:subscription.cpp


示例8: be

CameraPtr Camera::init()
{
   // Create a transform to contain the location and orientation of the camera.
   mTransform = OSG::Transform::create();

   OSG::NodePtr beacon = OSG::Node::create();
#if OSG_MAJOR_VERSION < 2
   OSG::CPEditor be(beacon, OSG::Node::CoreFieldMask);
#endif
   beacon->setCore(mTransform);

   mLeftTexture = tex_chunk_t::create();
#if OSG_MAJOR_VERSION < 2
   OSG::CPEditor lte(mLeftTexture);
   mLeftTexture->setEnvMode(GL_MODULATE);
#else
   mLeftTexEnv = OSG::TextureEnvChunk::create();
   mLeftTexEnv->setEnvMode(GL_MODULATE);
#endif

   mRightTexture = tex_chunk_t::create();
#if OSG_MAJOR_VERSION < 2
   OSG::CPEditor rte(mRightTexture);
   mRightTexture->setEnvMode(GL_MODULATE);
#else
   mRightTexEnv = OSG::TextureEnvChunk::create();
   mRightTexEnv->setEnvMode(GL_MODULATE);
#endif

   mCurrentTexture = mLeftTexture;
#if OSG_MAJOR_VERSION >= 2
   mCurrentTexEnv = mLeftTexEnv;
#endif

   // setup camera
   mCamera = OSG::PerspectiveCamera::create();
#if OSG_MAJOR_VERSION < 2
   OSG::CPEditor ce(mCamera);
#endif
   mCamera->setFov(
#if OSG_MAJOR_VERSION < 2
      OSG::osgdegree2rad(60.0)
#else
      OSG::osgDegree2Rad(60.0)
#endif
   );
   mCamera->setNear(0.01);
   mCamera->setFar(10000);
   mCamera->setBeacon(beacon);

   mLeftImage = OSG::Image::create();
   mRightImage = OSG::Image::create();

   OSG::ImagePtr img;

   // Set up FBO textures.
   img = mLeftImage;
   mLeftTexture->setMinFilter(GL_LINEAR);
   mLeftTexture->setMagFilter(GL_LINEAR);
   mLeftTexture->setTarget(GL_TEXTURE_2D);
   mLeftTexture->setInternalFormat(GL_RGBA8);
   mLeftTexture->setImage(img);

   img = mRightImage;
   mRightTexture->setMinFilter(GL_LINEAR);
   mRightTexture->setMagFilter(GL_LINEAR);
   mRightTexture->setTarget(GL_TEXTURE_2D);
   mRightTexture->setInternalFormat(GL_RGBA8);
   mRightTexture->setImage(img);

   mCurrentImage = mLeftImage;

   return shared_from_this();
}
开发者ID:patrickhartling,项目名称:vrkit,代码行数:74,代码来源:Camera.cpp


示例9: QueryProvider

void SuggestionsSidebarBlock::QueryProvider(SuggestionsBackend& backend, const CatalogItemPtr& item, uint64_t queryId)
{
    m_pendingQueries++;

    // we need something to talk to GUI thread through that is guaranteed
    // to exist, and the app object is a good choice:
    auto backendPtr = &backend;
    std::weak_ptr<SuggestionsSidebarBlock> weakSelf = std::dynamic_pointer_cast<SuggestionsSidebarBlock>(shared_from_this());

    m_provider->SuggestTranslation
    (
        backend,
        m_parent->GetCurrentSourceLanguage(),
        m_parent->GetCurrentLanguage(),
        item->GetString().ToStdWstring(),

        // when receiving data
        [=](const SuggestionsList& hits){
            call_on_main_thread([weakSelf,queryId,hits]{
                auto self = weakSelf.lock();
                // maybe this call is already out of date:
                if (!self || self->m_latestQueryId != queryId)
                    return;
                self->UpdateSuggestions(hits);
                if (--self->m_pendingQueries == 0)
                    self->OnQueriesFinished();
            });
        },

        // on error:
        [=](std::exception_ptr e){
            call_on_main_thread([weakSelf,queryId,backendPtr,e]{
                auto self = weakSelf.lock();
                // maybe this call is already out of date:
                if (!self || self->m_latestQueryId != queryId)
                    return;
                self->ReportError(backendPtr, e);
                if (--self->m_pendingQueries == 0)
                    self->OnQueriesFinished();
            });
        }
    );
}
开发者ID:BenKeyFSI,项目名称:poedit,代码行数:43,代码来源:sidebar.cpp


示例10: AddPlayList

void PlayListFolder::AddPlayList(boost::shared_ptr<PlayListElement> playList) {
    playList->SetParent(shared_from_this());
    playlists_.push_back(playList);
}
开发者ID:unimpossible,项目名称:SpotifyDuplicateScanner,代码行数:4,代码来源:PlayListFolder.cpp


示例11: IDatabaseSPtr

IDatabaseSPtr RedisServer::createDatabase(IDataBaseInfoSPtr info) {
  return IDatabaseSPtr(new RedisDatabase(shared_from_this(), info));
}
开发者ID:kunyuqiushuang,项目名称:fastonosql,代码行数:3,代码来源:redis_server.cpp


示例12: shared_from_this

StructuredScript::Interfaces::Node::Ptr StructuredScript::Nodes::EchoNode::ptr(){
	return shared_from_this();
}
开发者ID:benbraide,项目名称:StructuredScript,代码行数:3,代码来源:EchoNode.cpp


示例13: serverPtr

void my::GateServer::init()
{
	boost::shared_ptr<TcpServer> serverPtr(this); //make sure that shared_from_this() can run perfectly ok!
	Json::Value gateConf = util::fileSystem::loadJsonFileEval(jsonconf::server_config);
	if (gateConf == Json::nullValue)
	{
		LogW << "Error init GateServer, null gateConf" << LogEnd;
		return;
	}
	//初始化httpSvr
	{
		m_HttpServerPtr = HttpServerPtr(new http::HttpServer());
		m_HttpServerPtr->init(gateConf);
		m_HttpServerPtr->run();
	}
	m_GateConf = gateConf;
	int	port = gateConf["gateSvrPort"].asInt();
	std::string gameSvrIp = gateConf["gameSvrIp"].asString();
	int gameSvrPort = gateConf["gameSvrPort"].asInt();
	std::string accountSvrIp = gateConf["accountSvrIp"].asString();
	int accountSvrPort = gateConf["accountSvrPort"].asInt();

	m_nConnCount = 0;
	m_nNetIdHolder = 0;
	m_pEndpoint = EndpointPtr(new boost::asio::ip::tcp::endpoint(ip::tcp::v4(), port));
	m_pAcceptor = AcceptorPtr(new boost::asio::ip::tcp::acceptor(core.getService(), *m_pEndpoint));

	m_GateHandler = boost::shared_ptr<GateHandler>(new GateHandler());
	ConnectionPtr nextConn = boost::shared_ptr<TcpConnection>(new TcpConnection(core.getService(), m_GateHandler, shared_from_this()));
	m_pAcceptor->async_accept(nextConn->getSocket(), boost::bind(&GateServer::handle_accept, this, nextConn, boost::asio::placeholders::error));

	connectToGameSvr(gameSvrIp, gameSvrPort);
	connectToAccountSvr(accountSvrIp, accountSvrPort);

	LogD << "Init Gate Server Ok!!!" << LogEnd;

	update();
}
开发者ID:elenno,项目名称:MyServer,代码行数:38,代码来源:gateServer.cpp


示例14: temp

void CShips::Retreat(const CPoint& ptRetreatSector, COMBAT_TACTIC::Typ const* NewCombatTactic)
{
	NotifySector temp(shared_from_this());
	CShip::Retreat(ptRetreatSector, NewCombatTactic);
}
开发者ID:bote-team,项目名称:bote,代码行数:5,代码来源:Ships.cpp


示例15: collidedBy

void Player::collidedBy(std::shared_ptr<Actor> a) {
    a->collideWith(std::static_pointer_cast<Player>(shared_from_this()));
}
开发者ID:JonesAndrew,项目名称:JamGame,代码行数:3,代码来源:player.cpp


示例16: shared_from_this

sf::Vector2f CBaseControl::ConvertPointToControl(const sf::Vector2f & pt, const CBaseControlConstPtr & control) const
{
	return control->ConvertPointFromControl(pt, shared_from_this());
}
开发者ID:Dzzirt,项目名称:ShapesApp,代码行数:4,代码来源:BaseControl.cpp


示例17: RequestFocus

void UIWidget::RequestFocus(){
  auto p = parent.lock();
  if(!p) return;
  p->OnChildFocusRequested(shared_from_this());
}
开发者ID:rafalcieslak,项目名称:AlgAudio,代码行数:5,代码来源:UIWidget.cpp


示例18: handleReadError

void Connection::parsePacket(const boost::system::error_code& error)
{
	m_connectionLock.lock();
	m_readTimer.cancel();

	if (error) {
		handleReadError(error);
	}

	if (m_connectionState != CONNECTION_STATE_OPEN || m_readError) {
		closeConnection();
		m_connectionLock.unlock();
		return;
	}

	uint32_t timePassed = std::max<uint32_t>(1, (time(nullptr) - m_timeConnected) + 1);
	if ((++m_packetsSent / timePassed) > (uint32_t)g_config.getNumber(ConfigManager::MAX_PACKETS_PER_SECOND)) {
		std::cout << convertIPToString(getIP()) << " disconnected for exceeding packet per second limit." << std::endl;
		closeConnection();
		m_connectionLock.unlock();
		return;
	}

	if (timePassed > 2) {
		m_timeConnected = time(nullptr);
		m_packetsSent = 0;
	}

	//Check packet checksum
	uint32_t checksum;
	int32_t len = m_msg.getMessageLength() - m_msg.getReadPos() - 4;
	if (len > 0) {
		checksum = adlerChecksum(m_msg.getBuffer() + m_msg.getReadPos() + 4, len);
	} else {
		checksum = 0;
	}

	uint32_t recvChecksum = m_msg.get<uint32_t>();
	if (recvChecksum != checksum) {
		// it might not have been the checksum, step back
		m_msg.SkipBytes(-4);
	}

	if (!m_receivedFirst) {
		// First message received
		m_receivedFirst = true;

		if (!m_protocol) {
			// Game protocol has already been created at this point
			m_protocol = m_service_port->make_protocol(recvChecksum == checksum, m_msg);
			if (!m_protocol) {
				closeConnection();
				m_connectionLock.unlock();
				return;
			}

			m_protocol->setConnection(shared_from_this());
		} else {
			m_msg.GetByte();    // Skip protocol ID
		}

		m_protocol->onRecvFirstMessage(m_msg);
	} else {
		m_protocol->onRecvMessage(m_msg);    // Send the packet to the current protocol
	}

	try {
		m_readTimer.expires_from_now(boost::posix_time::seconds(Connection::read_timeout));
		m_readTimer.async_wait( std::bind(&Connection::handleReadTimeout, std::weak_ptr<Connection>(shared_from_this()),
		                                    std::placeholders::_1));

		// Wait to the next packet
		boost::asio::async_read(getHandle(),
		                        boost::asio::buffer(m_msg.getBuffer(), NetworkMessage::header_length),
		                        std::bind(&Connection::parseHeader, shared_from_this(), std::placeholders::_1));
	} catch (boost::system::system_error& e) {
		if (m_logError) {
			std::cout << "[Network error - Connection::parsePacket] " << e.what() << std::endl;
			m_logError = false;
		}

		closeConnection();
	}

	m_connectionLock.unlock();
}
开发者ID:ArthurF5,项目名称:lforgottenserver,代码行数:86,代码来源:connection.cpp


示例19: IsFocused

bool UIWidget::IsFocused() const{
  auto p = parent.lock();
  if(!p) return IsRoot(); // Root widgets are always focused, but parentless widgets never.
  return p->OnChildFocusTested(shared_from_this());
}
开发者ID:rafalcieslak,项目名称:AlgAudio,代码行数:5,代码来源:UIWidget.cpp


示例20: lock

void Subscription::pendingConnectionDone(const PendingConnectionPtr& conn, XmlRpcValue& result)
{
  boost::mutex::scoped_lock lock(shutdown_mutex_);
  if (shutting_down_ || dropped_)
  {
    return;
  }

  {
    boost::mutex::scoped_lock pending_connections_lock(pending_connections_mutex_);
    pending_connections_.erase(conn);
  }

  ros::TransportUDPPtr udp_transport;

  std::string peer_host = conn->getClient()->getHost();
  uint32_t peer_port = conn->getClient()->getPort();
  std::stringstream ss;
  ss << "http://" << peer_host << ":" << peer_port << "/";
  std::string xmlrpc_uri = ss.str();
  udp_transport = conn->getUDPTransport();

  XmlRpc::XmlRpcValue proto;
  if(!XMLRPCManager::instance()->validateXmlrpcResponse("requestTopic", result, proto))
  {
  	ROSCPP_LOG_DEBUG("Failed to contact publisher [%s:%d] for topic [%s]",
              peer_host.c_str(), peer_port, name_.c_str());
  	closeTransport(udp_transport);
  	return;
  }

  if (proto.size() == 0)
  {
  	ROSCPP_LOG_DEBUG("Couldn't agree on any common protocols with [%s] for topic [%s]", xmlrpc_uri.c_str(), name_.c_str());
  	closeTransport(udp_transport);
  	return;
  }

  if (proto.getType() != XmlRpcValue::TypeArray)
  {
  	ROSCPP_LOG_DEBUG("Available protocol info returned from %s is not a list.", xmlrpc_uri.c_str());
  	closeTransport(udp_transport);
  	return;
  }
  if (proto[0].getType() != XmlRpcValue::TypeString)
  {
  	ROSCPP_LOG_DEBUG("Available protocol info list doesn't have a string as its first element.");
  	closeTransport(udp_transport);
  	return;
  }

  std::string proto_name = proto[0];
  if (proto_name == "TCPROS")
  {
    if (proto.size() != 3 ||
        proto[1].getType() != XmlRpcValue::TypeString ||
        proto[2].getType() != XmlRpcValue::TypeInt)
    {
    	ROSCPP_LOG_DEBUG("publisher implements TCPROS, but the " \
                "parameters aren't string,int");
      return;
    }
    std::string pub_host = proto[1];
    int pub_port = proto[2];
    ROSCPP_LOG_DEBUG("Connecting via tcpros to topic [%s] at host [%s:%d]", name_.c_str(), pub_host.c_str(), pub_port);

//ROS_INFO("here in subscription");

    //ros::TransportTCPPtr transport(new ros::TransportTCP(&ros::PollManager::instance()->getPollSet()));
    ros::TransportTCPPtr transport(new ros::TransportTCP(&poll_manager_->getPollSet()));
    if (transport->connect(pub_host, pub_port))
    {
      ros::ConnectionPtr connection(new ros::Connection());
      TransportPublisherLinkPtr pub_link(new TransportPublisherLink(shared_from_this(), xmlrpc_uri, transport_hints_));

      connection->initialize(transport, false, ros::HeaderReceivedFunc());
      pub_link->initialize(connection);

      ConnectionManager::instance()->addConnection(connection);

      boost::mutex::scoped_lock lock(publisher_links_mutex_);
      addPublisherLink(pub_link);

      ROSCPP_LOG_DEBUG("Connected to publisher of topic [%s] at [%s:%d]", name_.c_str(), pub_host.c_str(), pub_port);
    }
    else
    {
    	ROSCPP_LOG_DEBUG("Failed to connect to publisher of topic [%s] at [%s:%d]", name_.c_str(), pub_host.c_str(), pub_port);
    }
  }
  else if (proto_name == "UDPROS")
  {
    if (proto.size() != 6 ||
        proto[1].getType() != XmlRpcValue::TypeString ||
        proto[2].getType() != XmlRpcValue::TypeInt ||
        proto[3].getType() != XmlRpcValue::TypeInt ||
        proto[4].getType() != XmlRpcValue::TypeInt ||
        proto[5].getType() != XmlRpcValue::TypeBase64)
    {
      ROSCPP_LOG_DEBUG("publisher implements UDPROS, but the " \
//.........这里部分代码省略.........
开发者ID:Formal-Systems-Laboratory,项目名称:ROSRV,代码行数:101,代码来源:subscription.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ shdebugstr_guid函数代码示例发布时间:2022-05-30
下一篇:
C++ sharedList函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap