Ejemplo n.º 1
0
void
WindowManager::removeView( boost::intrusive_ptr< IView > _view )
{
	DockWidgetByViewCollectionIterator iterator = m_dockWidgetByViewCollection.find( _view );

	if ( iterator != m_dockWidgetByViewCollection.end() )
	{
		_view->getViewWidget()->setParent( NULL );
		m_mainWindow->removeDockWidget( iterator->second );

		_view->viewWasClosed();

		m_dockWidgetByViewCollection.erase( _view );
	}

	CentralViewsCollectionIterator centralViewiterator = m_centralViewsCollection.find( _view );

	if ( centralViewiterator != m_centralViewsCollection.end() )
	{
		_view->getViewWidget()->setParent( NULL );
		m_centralWidget->removeTab( m_centralWidget->indexOf( _view->getViewWidget() ) );

		_view->viewWasClosed();

		m_centralViewsCollection.erase( _view );
	}

} // WindowManager::removeView
Ejemplo n.º 2
0
void tSolution3::Execute(boost::intrusive_ptr<tShipCommand> shipCommand){
int a=0;// 123
	boost::intrusive_ptr<tObj> conPoint;
	boost::intrusive_ptr<tObj> stationPoint;
	if (!shipCommand->_command) return;
	int cmd=shipCommand->GetCommandId();
	switch(cmd){
		case 3:
/*
			conPoint=_base->starInterface->GetConnectPoint();
//123					(*sIter)->_ship->New_Target(tar);
			shipCommand->SetTarget(conPoint);
			shipCommand->_command=boost::intrusive_ptr<tICommand5> (new tICommand5);//cPatrul;//next command
			//shipCommand->SetCommand(
			shipCommand->m_refCounter+=tSolution3::m_refCounter-1;//???check!!!!
			break;
		case 5:
*/
			shipCommand->_ship->obj->SetMinSpeed(0.5f);
			stationPoint=_base->starInterface->GetNearStation();
			shipCommand->SetTarget(stationPoint);
			shipCommand->_command=boost::intrusive_ptr<tICommand4> (new tICommand4);//cReturn;//next command
			shipCommand->m_refCounter+=tSolution3::m_refCounter-1;//???check!!!!
			break;
		default:
			//shipCommand->_command=0;
			break;
	}

}
Ejemplo n.º 3
0
/**
 * Stores a message before it has been enqueued
 * (enqueueing automatically stores the message so this is
 * only required if storage is required prior to that
 * point).
 */
void
MessageStorePlugin::stage(const boost::intrusive_ptr<broker::PersistableMessage>& msg)
{
    if (msg->getPersistenceId() == 0 && !msg->isContentReleased()) {
        provider->second->stage(msg);
    }
}
Ejemplo n.º 4
0
void
WindowManager::addView(
		boost::intrusive_ptr< IView > _view
	,	const ViewPosition::Enum _position )
{
	assert( m_dockWidgetByViewCollection.find( _view ) == m_dockWidgetByViewCollection.end() );

	if ( _position == ViewPosition::Center )
	{
		m_centralWidget->addTab( _view->getViewWidget(), _view->getViewTitle() );
		m_centralViewsCollection.insert( _view );
	}
	else
	{
		Qt::DockWidgetArea viewPossition( getQtViewPossition( _position ) );

		QDockWidget* docWidget( new QDockWidget() );

		docWidget->setWindowTitle( _view->getViewTitle() );
		docWidget->setWidget( _view->getViewWidget() );

		m_mainWindow->addDockWidget( viewPossition, docWidget );

		m_dockWidgetByViewCollection.insert( std::make_pair( _view, docWidget ) );
	}

} // WindowManager::addView
Ejemplo n.º 5
0
template <> void
BlobEncoder::encode(const boost::intrusive_ptr<qpid::broker::PersistableMessage> &item)
{
    // NOTE! If this code changes, verify the recovery code in MessageRecordset
    SAFEARRAYBOUND bound[1] = {0, 0};
    bound[0].cElements = item->encodedSize() + sizeof(uint32_t);
    blob = SafeArrayCreate(VT_UI1, 1, bound);
    if (S_OK != SafeArrayLock(blob)) {
        SafeArrayDestroy(blob);
        blob = 0;
        throw qpid::Exception("Error locking blob area for message");
    }
    try {
        uint32_t headerSize = item->encodedHeaderSize();
        qpid::framing::Buffer buff((char *)blob->pvData, bound[0].cElements);
        buff.putLong(headerSize);
        item->encode(buff);
    }
    catch(...) {
        SafeArrayUnlock(blob);
        SafeArrayDestroy(blob);
        blob = 0;
        throw;
    }
    this->vt = VT_ARRAY | VT_UI1;
    this->parray = blob;
    SafeArrayUnlock(blob);
}
//typename boost::enable_if<typename intrusive_traits<T>::user_allocator>::type
void
intrusive_make_valid_unique(boost::intrusive_ptr<T> & p)
{
  if (!p)
    p.reset(construct<typename intrusive_traits<T>::user_allocator,T>());
  else if (!p->unique())
    p.reset(intrusive_clone(*p));
}
Ejemplo n.º 7
0
static as_object*
getInterface()
{
    GNASH_REPORT_FUNCTION;
    static boost::intrusive_ptr<as_object> o;
    if (o == NULL) {
	o = new as_object();
    }
    return o.get();
}
Ejemplo n.º 8
0
 void drawScene()
 {
     program_->create();
     program_->bind();
     applyCamera();
     glEnable(GL_BLEND);
     glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
     game_->getRenderService()->draw();
     glDisable(GL_BLEND);
     program_->unbind();
 }
Ejemplo n.º 9
0
// Called in connection thread to insert an updated shadow connection.
void Cluster::addShadowConnection(const boost::intrusive_ptr<Connection>& c) {
    QPID_LOG(debug, *this << " new shadow connection " << c->getId());
    // Safe to use connections here because we're pre-catchup, stalled
    // and discarding, so deliveredFrame is not processing any
    // connection events.
    assert(discarding);
    pair<ConnectionMap::iterator, bool> ib
        = connections.insert(ConnectionMap::value_type(c->getId(), c));
    // Like this to avoid tripping up unused variable warning when NDEBUG set
    if (!ib.second) assert(ib.second);
}
Ejemplo n.º 10
0
// static
StatusWith<std::unique_ptr<CanonicalQuery>> CanonicalQuery::canonicalize(
    OperationContext* opCtx,
    std::unique_ptr<QueryRequest> qr,
    const boost::intrusive_ptr<ExpressionContext>& expCtx,
    const ExtensionsCallback& extensionsCallback,
    MatchExpressionParser::AllowedFeatureSet allowedFeatures) {
    auto qrStatus = qr->validate();
    if (!qrStatus.isOK()) {
        return qrStatus;
    }

    std::unique_ptr<CollatorInterface> collator;
    if (!qr->getCollation().isEmpty()) {
        auto statusWithCollator = CollatorFactoryInterface::get(opCtx->getServiceContext())
                                      ->makeFromBSON(qr->getCollation());
        if (!statusWithCollator.isOK()) {
            return statusWithCollator.getStatus();
        }
        collator = std::move(statusWithCollator.getValue());
    }

    // Make MatchExpression.
    boost::intrusive_ptr<ExpressionContext> newExpCtx;
    if (!expCtx.get()) {
        newExpCtx.reset(new ExpressionContext(opCtx, collator.get()));
    } else {
        newExpCtx = expCtx;
        invariant(CollatorInterface::collatorsMatch(collator.get(), expCtx->getCollator()));
    }
    StatusWithMatchExpression statusWithMatcher = MatchExpressionParser::parse(
        qr->getFilter(), newExpCtx, extensionsCallback, allowedFeatures);
    if (!statusWithMatcher.isOK()) {
        return statusWithMatcher.getStatus();
    }
    std::unique_ptr<MatchExpression> me = std::move(statusWithMatcher.getValue());

    // Make the CQ we'll hopefully return.
    std::unique_ptr<CanonicalQuery> cq(new CanonicalQuery());

    Status initStatus =
        cq->init(opCtx,
                 std::move(qr),
                 parsingCanProduceNoopMatchNodes(extensionsCallback, allowedFeatures),
                 std::move(me),
                 std::move(collator));

    if (!initStatus.isOK()) {
        return initStatus;
    }
    return std::move(cq);
}
Ejemplo n.º 11
0
        void drawSceneToTarget()
        {
            if (!targetTexture_ ||
                targetTexture_->getWidth() != 2 * window_->getWidth() ||
                targetTexture_->getHeight() != 2 * window_->getHeight())
            {
                targetTexture_ = window_->getContext()->createTexture();
                targetTexture_->setSize(2 * window_->getWidth(),
                                        2 * window_->getHeight());
                targetTexture_->setMinFilter(GL_LINEAR);
                targetTexture_->setMagFilter(GL_LINEAR);

                targetFrameBuffer_ = window_->getContext()->createFrameBuffer();
                targetFrameBuffer_->setColorAttachment(targetTexture_);
            }
            
            targetFrameBuffer_->create();

            glViewport(0, 0, window_->getWidth() * 2,
                       window_->getHeight() * 2);
            glBindFramebuffer(GL_FRAMEBUFFER, targetFrameBuffer_->getName());
            glClearColor(0.0, 0.0, 0.0, 0.0);
            glClear(GL_COLOR_BUFFER_BIT);
            drawScene();
            glBindFramebuffer(GL_FRAMEBUFFER, 0);
            glViewport(0, 0, window_->getWidth(), window_->getHeight());
        }
Ejemplo n.º 12
0
 void drawTargetToScreen()
 {
     glMatrixMode(GL_PROJECTION);
     glLoadIdentity();
     glOrtho(0.0, double(window_->getWidth() * 2),
             0.0, double(window_->getHeight() * 2),
             -1.0, 1.0);
     glMatrixMode(GL_MODELVIEW);
     glLoadIdentity();
     
     glEnable(GL_TEXTURE_2D);
     glBindTexture(GL_TEXTURE_2D, targetTexture_->getName());
     glColor3ub(255, 255, 255);
     glBegin(GL_QUADS);
     {
         glTexCoord2i(0, 0);
         glVertex2i(0, 0);
         glTexCoord2i(1, 0);
         glVertex2i(window_->getWidth() * 2, 0);
         glTexCoord2i(1, 1);
         glVertex2i(window_->getWidth() * 2, window_->getHeight() * 2);
         glTexCoord2i(0, 1);
         glVertex2i(0, window_->getHeight() * 2);
     }
     glEnd();
     glBindTexture(GL_TEXTURE_2D, 0);
     glDisable(GL_TEXTURE_2D);
 }
Ejemplo n.º 13
0
 peer_connection_handle::peer_connection_handle(boost::intrusive_ptr<peer_connection> pc, aux::session_impl* pses) : m_pses(pses)
 {
     if (pc)
     {
         m_np = pc->get_network_point();
     }
 }
Ejemplo n.º 14
0
/**
 * Round trips the pipeline through serialization by calling serialize(), then Pipeline::parse().
 * fasserts if it fails to parse after being serialized.
 */
boost::intrusive_ptr<Pipeline> reparsePipeline(
    const boost::intrusive_ptr<Pipeline>& pipeline,
    const AggregationRequest& request,
    const boost::intrusive_ptr<ExpressionContext>& expCtx) {
    auto serialized = pipeline->serialize();

    // Convert vector<Value> to vector<BSONObj>.
    std::vector<BSONObj> parseableSerialization;
    parseableSerialization.reserve(serialized.size());
    for (auto&& serializedStage : serialized) {
        invariant(serializedStage.getType() == BSONType::Object);
        parseableSerialization.push_back(serializedStage.getDocument().toBson());
    }

    auto reparsedPipeline = Pipeline::parse(parseableSerialization, expCtx);
    if (!reparsedPipeline.isOK()) {
        error() << "Aggregation command did not round trip through parsing and serialization "
                   "correctly. Input pipeline: "
                << Value(request.getPipeline()).toString()
                << ", serialized pipeline: " << Value(serialized).toString();
        fassertFailedWithStatusNoTrace(40175, reparsedPipeline.getStatus());
    }

    reparsedPipeline.getValue()->injectExpressionContext(expCtx);
    reparsedPipeline.getValue()->optimizePipeline();
    return reparsedPipeline.getValue();
}
Ejemplo n.º 15
0
	find_data_observer(
		boost::intrusive_ptr<find_data> const& algorithm
		, node_id self)
		: observer(algorithm->allocator())
		, m_algorithm(algorithm)
		, m_self(self)
	{}
Ejemplo n.º 16
0
	// non prioritized means that, if there's a line for bandwidth,
	// others will cut in front of the non-prioritized peers.
	// this is used by web seeds
	int bandwidth_manager::request_bandwidth(boost::intrusive_ptr<bandwidth_socket> const& peer
		, int blk, int priority
		, bandwidth_channel* chan1
		, bandwidth_channel* chan2
		, bandwidth_channel* chan3
		, bandwidth_channel* chan4
		, bandwidth_channel* chan5
		)
	{
		INVARIANT_CHECK;
		if (m_abort) return 0;

		TORRENT_ASSERT(blk > 0);
		TORRENT_ASSERT(priority > 0);
		TORRENT_ASSERT(!is_queued(peer.get()));

		bw_request bwr(peer, blk, priority);
		int i = 0;
		if (chan1 && chan1->throttle() > 0) bwr.channel[i++] = chan1;
		if (chan2 && chan2->throttle() > 0) bwr.channel[i++] = chan2;
		if (chan3 && chan3->throttle() > 0) bwr.channel[i++] = chan3;
		if (chan4 && chan4->throttle() > 0) bwr.channel[i++] = chan4;
		if (chan5 && chan5->throttle() > 0) bwr.channel[i++] = chan5;
		if (i == 0)
		{
			// the connection is not rate limited by any of its
			// bandwidth channels, or it doesn't belong to any
			// channels. There's no point in adding it to
			// the queue, just satisfy the request immediately
			return blk;
		}
		m_queued_bytes += blk;
		m_queue.push_back(bwr);
		return 0;
	}
Ejemplo n.º 17
0
    inline virtual To eval()
    {
        cached_number = Converter::do_conv(from_expr->eval());

        // Here we may be returning a reference to the cached value instead of by-value.
        return cached_number;
    }
Ejemplo n.º 18
0
	int seekLowerBound(fstring key, llong* id, valvec<byte>* retKey) override {
		assert(key.size() == sizeof(Int));
		if (key.size() != sizeof(Int)) {
			THROW_STD(invalid_argument,
				"key.size must be sizeof(Int)=%d", int(sizeof(Int)));
		}
		auto owner = static_cast<const SeqNumIndex*>(m_index.get());
		Int keyId = unaligned_load<Int>(key.udata());
		if (keyId <= owner->m_min) {
			m_curr = 0;
			return -1;
		}
		else if (keyId > owner->m_min + owner->m_cnt) {
			m_curr = owner->m_cnt;
			*id = owner->m_cnt - 1;
			Int forwardMax = owner->m_min + owner->m_cnt - 1;
			retKey->assign((const byte*)&forwardMax, sizeof(Int));
			return 1;
		}
		else {
			keyId -= owner->m_min;
			m_curr = keyId;
			*id = keyId;
			retKey->assign(key.udata(), key.size());
			return 0;
		}
	}
Ejemplo n.º 19
0
	bool increment(llong* id, valvec<byte>* key) override {
		auto owner = static_cast<const SeqNumIndex*>(m_index.get());
		if (nark_likely(m_curr < owner->m_cnt)) {
			getIndexKey(id, key, owner, --m_curr);
			return true;
		}
		return false;
	}
Ejemplo n.º 20
0
    void
    launcher_class_init(as_object &obj)
    {
//	GNASH_REPORT_FUNCTION;
	// This is going to be the global "class"/"function"
	static boost::intrusive_ptr<builtin_function> cl;
	if (cl == NULL) {
        Global_as* gl = getGlobal(global);
        as_object* proto = getInterface();
        cl = gl->createClass(&launcher_ctor, proto);
// 	    // replicate all interface to class, to be able to access
// 	    // all methods as static functions
 	    attachInterface(cl.get());
	}
	
	obj.init_member("Launcher", cl.get());
    }
Ejemplo n.º 21
0
void DtxWorkRecord::recover(std::auto_ptr<TPCTransactionContext> _txn, boost::intrusive_ptr<DtxBuffer> ops)
{
    add(ops);
    txn = _txn;
    ops->markEnded();
    completed = true;
    prepared = true;
}
Ejemplo n.º 22
0
    void enqueue(TransactionContext* tx,
                 const boost::intrusive_ptr<PersistableMessage>& pmsg,
                 const PersistableQueue& queue)
    {
        ostringstream o;
        string data = getContent(pmsg);
        o << "<enqueue " << queue.getName() << " " << data;
        if (tx) o << " tx=" << getId(*tx);
        o << ">";
        log(o.str());

        // Dump the message if there is a dump file.
        if (dump.get()) {
            *dump << "Message(" << data.size() << "): " << data << endl;
        }
        string logPrefix = "TestStore "+name+": ";
        Action action(data);
        bool doComplete = true;
        if (action.index && action.executeIn(name)) {
            switch (action.index) {

              case Action::THROW:
                throw Exception(logPrefix + data);
                break;

              case Action::DELAY: {
                  if (action.args.empty()) {
                      QPID_LOG(error, logPrefix << "async-id needs argument: " << data);
                      break;
                  }
                  asyncIds[action.args[0]] = pmsg;
                  QPID_LOG(debug, logPrefix << "delayed completion " << action.args[0]);
                  doComplete = false;
                  break;
              }

              case Action::COMPLETE: {
                  if (action.args.empty()) {
                      QPID_LOG(error, logPrefix << "complete-id needs argument: " << data);
                      break;
                  }
                  AsyncIds::iterator i = asyncIds.find(action.args[0]);
                  if (i != asyncIds.end()) {
                      i->second->enqueueComplete();
                      QPID_LOG(debug, logPrefix << "completed " << action.args[0]);
                      asyncIds.erase(i);
                  } else {
                      QPID_LOG(info, logPrefix << "not found for completion " << action.args[0]);
                  }
                  break;
              }

              default:
                QPID_LOG(error, logPrefix << "unknown action: " << data);
            }
        }
        if (doComplete) pmsg->enqueueComplete();
    }
Ejemplo n.º 23
0
void tcontainer_::init_grid(
		const boost::intrusive_ptr<tbuilder_grid>& grid_builder)
{
	log_scope2(log_gui_general, LOG_SCOPE_HEADER);

	assert(initial_grid().get_rows() == 0 && initial_grid().get_cols() == 0);

	grid_builder->build(&initial_grid());
}
Ejemplo n.º 24
0
 inline void save(Archive& ar, boost::intrusive_ptr<T> const& t,
     unsigned int const)
 {
     // The most common cause of trapping here would be serializing
     // something like intrusive_ptr<int>.  This occurs because int
     // is never tracked by default.  Wrap int in a trackable type
     BOOST_STATIC_ASSERT((tracking_level<T>::value != track_never));
     T const* ptr = t.get();
     ar << ptr;
 }
Ejemplo n.º 25
0
/**
 * Appends content to a previously staged message
 */
void
MessageStorePlugin::appendContent
  (const boost::intrusive_ptr<const broker::PersistableMessage>& msg,
   const std::string& data)
{
    if (msg->getPersistenceId())
        provider->second->appendContent(msg, data);
    else
        THROW_STORE_EXCEPTION("Cannot append content. Message not known to store!");
}
Ejemplo n.º 26
0
void tStorage::AddObj(boost::intrusive_ptr<tObj> obj) {
    tSendData tmp;
    tmp.pos=obj->GetPos();
    tmp.dir=obj->tz;
    tmp.up=obj->ty;
    //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//	tmp.uin=obj->uin;
//	tmp.radius=obj->radius;
//	physObj.push_back(tmp);
}
Ejemplo n.º 27
0
DocumentSourceLookUp::DocumentSourceLookUp(NamespaceString fromNs,
                                           std::string as,
                                           std::string localField,
                                           std::string foreignField,
                                           const boost::intrusive_ptr<ExpressionContext>& pExpCtx)
    : DocumentSourceNeedsMongod(pExpCtx),
      _fromNs(std::move(fromNs)),
      _as(std::move(as)),
      _localField(std::move(localField)),
      _foreignField(foreignField),
      _foreignFieldFieldName(std::move(foreignField)) {
    const auto& resolvedNamespace = pExpCtx->getResolvedNamespace(_fromNs);
    _fromExpCtx = pExpCtx->copyWith(resolvedNamespace.ns);
    _fromPipeline = resolvedNamespace.pipeline;

    // We append an additional BSONObj to '_fromPipeline' as a placeholder for the $match stage
    // we'll eventually construct from the input document.
    _fromPipeline.reserve(_fromPipeline.size() + 1);
    _fromPipeline.push_back(BSONObj());
}
Ejemplo n.º 28
0
 inline void load(Archive& ar, boost::intrusive_ptr<T>& t,
     const unsigned int)
 {
     // The most common cause of trapping here would be serializing
     // something like intrusive_ptr<int>.  This occurs because int
     // is never tracked by default.  Wrap int in a trackable type
     BOOST_STATIC_ASSERT((tracking_level<T>::value != track_never));
     T* ptr;
     ar >> ptr;
     t.reset(ptr);
 }
Ejemplo n.º 29
0
/**
 * Loads (a section) of content data for the specified
 * message (previously stored through a call to stage or
 * enqueue) into data. The offset refers to the content
 * only (i.e. an offset of 0 implies that the start of the
 * content should be loaded, not the headers or related
 * meta-data).
 */
void
MessageStorePlugin::loadContent(const broker::PersistableQueue& queue,
                                const boost::intrusive_ptr<const broker::PersistableMessage>& msg,
                                std::string& data,
                                uint64_t offset,
                                uint32_t length)
{
    if (msg->getPersistenceId())
        provider->second->loadContent(queue, msg, data, offset, length);
    else
        THROW_STORE_EXCEPTION("Cannot load content. Message not known to store!");
}
bool LLFloaterBuyLandUI::checkTransaction()
{
	if (!mResponder)
	{
		return false;
	}
	
	if (!mResponder->is_finished())
	{
		return false;
	}

	if (mResponder->result_code() != CURLE_OK || mResponder->http_status() < 200 || mResponder->http_status() >= 400)
	{
		tellUserError(mResponder->reason(), mResponder->getURL());
	}
	else {
		switch (mTransactionType)
		{	
			case TransactionPreflight:	finishWebSiteInfo();	break;
			case TransactionBuy:		finishWebSitePrep();	break;
			default: ;
		}
	}
	
	// We're done with this data.
	mResponder = NULL;
	
	return true;
}