Пример #1
0
void Settings::RegisterVariable( std::string name, boost::weak_ptr<BaseDator> dator )
{
    boost::shared_ptr<BaseDator> real_dator = dator.lock();

    StringMap::iterator it = unparsed_settings_map.find( name );
    if( it != unparsed_settings_map.end() && real_dator )
    {
        std::string ret = real_dator->Set( it->second );
        UpdateListeners( name, it->second, ret );
        unparsed_settings_map.erase( it );
    }
    else {
        DatorMap::iterator it = dator_map.find( name );
        if( it != dator_map.end() && real_dator )
        {
            boost::shared_ptr<BaseDator> other_dator = it->second.lock();
            if( other_dator ) {
                std::string ret = real_dator->Set( other_dator->Get() );
                UpdateListeners( name, real_dator->Get(), ret );
            }
            else {
                dator_map.erase( it );
            }
        }
    }

    if( !dator.expired() ) {
        dator_map.insert( std::make_pair( name, dator ) );
    }
}
Пример #2
0
void ServicePort::services(boost::weak_ptr<ServicePort> weakService, IPAddressList ips, uint16_t port)
{
	if(weakService.expired())
		return;

	if(ServicePort_ptr service = weakService.lock())
		service->open(ips, port);
}
Пример #3
0
void ServicePort::openAcceptor(boost::weak_ptr<ServicePort> weak_service, uint16_t port)
{
	if(weak_service.expired())
		return;

	if(ServicePort_ptr service = weak_service.lock())
		service->open(port);
}
Пример #4
0
void SceneDict::Insert(boost::weak_ptr<zeitgeist::Leaf> leaf, const FileRef& ref)
{
    if (leaf.expired())
        {
            return;
        }

    mDictionary[leaf] = ref;
}
Пример #5
0
void TimerMaster::Register(boost::weak_ptr<Timer> weak_timer) {
  boost::mutex::scoped_lock locker(mutex_);
  boost::shared_ptr<Timer> timer = weak_timer.lock();
  if (weak_timer.expired()) {
    return;
  }
  TimerSlot *slot = new TimerSlot;
  InternalAddTimer(slot, weak_timer, timer->timeout() + timer_jiffies_);
}
void ServicePort::onOpen(boost::weak_ptr<ServicePort> weakService, uint16_t port)
{
	if(weakService.expired())
		return;

	if(ServicePort_ptr service = weakService.lock())
	{
		#ifdef __DEBUG_NET_DETAIL__
		std::cout << "ServicePort::onOpen" << std::endl;
		#endif
		service->open(port);
	}
}
    boost::shared_ptr< _ResolverMap > get_resolvers()
    {
        static boost::weak_ptr< _ResolverMap > singleton;

        boost::shared_ptr< _ResolverMap > shared(singleton.lock());
        if (singleton.expired()) {
            shared = boost::shared_ptr< _ResolverMap >(new _ResolverMap);
            singleton = shared;

            // Populate resolver list
            foreach (Resolver * resolver, Utopia::instantiateAllExtensions< Resolver >()) {
                (*shared)[resolver->weight()].push_back(boost::shared_ptr< Resolver >(resolver));
            }
Пример #8
0
void ServicePort::service(boost::weak_ptr<ServicePort> weakService, IPAddress ip, uint16_t port)
{
	if(weakService.expired())
		return;

	ServicePort_ptr service = weakService.lock();
	if(!service)
		return;

	IPAddressList ips;
	ips.push_back(ip);
	service->open(ips, port);
}
Пример #9
0
void Connection::handleWriteTimeout(boost::weak_ptr<Connection> weak, const boost::system::error_code& error)
{
	if(error == boost::asio::error::operation_aborted || weak.expired())
		return;

	if(shared_ptr<Connection> connection = weak.lock())
	{
		#ifdef __DEBUG_NET_DETAIL__
		std::clog << "Connection::handleWriteTimeout" << std::endl;
		#endif
		connection->onWriteTimeout();
	}
}
Пример #10
0
void Connection::handleWriteTimeout(boost::weak_ptr<Connection> weak_conn, const boost::system::error_code& error)
{
	if (error == boost::asio::error::operation_aborted) {
		return;
	}

	if (weak_conn.expired()) {
		return;
	}

	if (Connection_ptr connection = weak_conn.lock()) {
		connection->onWriteTimeout();
	}
}
Пример #11
0
void ServicePort::openAcceptor(boost::weak_ptr<ServicePort> weak_service, IPAddress ip, uint16_t port)
{
  if(weak_service.expired()){
    return;
  }

  if(ServicePort_ptr service = weak_service.lock()){
    #ifdef __DEBUG_NET_DETAIL__
    std::cout << "ServicePort::openAcceptor" << std::endl;
    #endif
    IPAddressList ips;
    ips.push_back(ip);
    service->open(ips, port);
  }
}
Пример #12
0
void Connection::handleReadTimeout(boost::weak_ptr<Connection> weak_conn, const boost::system::error_code& error)
{
	if(error != boost::asio::error::operation_aborted){
		if(weak_conn.expired()){
			return;
		}

		if(shared_ptr<Connection> connection = weak_conn.lock()){
			#ifdef __DEBUG_NET_DETAIL__
			std::cout << "Connection::handleReadTimeout" << std::endl;
			#endif

			connection->onReadTimeout();
		}
	}
}
Пример #13
0
libusb::session::sptr libusb::session::get_global_session(void){
    static boost::weak_ptr<session> global_session;

    //not expired -> get existing session
    if (not global_session.expired()) return global_session.lock();

    //create a new global session
    sptr new_global_session(new libusb_session_impl());
    global_session = new_global_session;

    //set logging if envvar is set
    const char *level_string = getenv("LIBUSB_DEBUG_LEVEL");
    if (level_string != NULL)
    {
        const int level = int(level_string[0] - '0'); //easy conversion to integer
        if (level >= 0 and level <= 3) libusb_set_debug(new_global_session->get_context(), level);
    }

    return new_global_session;
}
Пример #14
0
void CPNUIPlugin::OpenNIThread(boost::weak_ptr<CPNUIPluginAPI> JSAPI,
	xn::Context& Context)
{
	printf("Started OpenNI thread\n");

	extern boost::weak_ptr<CPNUIPluginAPI> GJSAPI;
	GJSAPI = JSAPI;

	while (!JSAPI.expired())
	{
		XnStatus rc = Context.WaitAnyUpdateAll();
		if (rc != XN_STATUS_OK)
		{
			printf("Read failed: %s\n", xnGetStatusString(rc));
			//m_NUIAvailable = false;
			return;
		}
	}
	printf("JSAPI pointer expired!\n");
}
Пример #15
0
				void check_expired() const {
					if (memory_.expired()) {
						throw position_expired("Position expired.");
					}
				}
Пример #16
0
	bool isHolding() const { return !holdingObject_.expired(); }