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

C++ cs函数代码示例

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

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



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

示例1: rc

void CGfxPopupMenu::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
//	CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
//	CRect rcItem(lpDrawItemStruct->rcItem);
//	pDC->FillSolidRect(rcItem, RGB(255,0,0));
	if (lpDrawItemStruct->CtlType == ODT_MENU)
	{
		UINT id = lpDrawItemStruct->itemID;
		UINT state = lpDrawItemStruct->itemState;
		bool bEnab = !(state & ODS_DISABLED);
		bool bSelect = (state & ODS_SELECTED) ? true : false;
		bool bChecked = (state & ODS_CHECKED) ? true : false;
		// David 08/04/98 - start - bold font handling
		bool bBold = (state & ODS_DEFAULT) ? true : false;
		// David 08/04/98 - end - bold font handling

		SpawnItem * pItem = (SpawnItem *) lpDrawItemStruct->itemData;
		if (pItem)
		{
			CDC * pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
			CFont * pft;
			// David 08/04/98 - start - bold font handling
			if (!bBold) pft = CFont::FromHandle((HFONT) hMenuFont ? hMenuFont : hGuiFont);
			else pft = CFont::FromHandle((HFONT) hMenuBoldFont ? hMenuBoldFont : hGuiFont);
			// David 08/04/98 - end - bold font handling
			CFont * of = pDC->SelectObject(pft);

			CRect rc(lpDrawItemStruct->rcItem);
			CRect rcImage(rc), rcText(rc);
			rcImage.right = rcImage.left + rc.Height();
			rcImage.bottom = rc.bottom;

			if (pItem->iCmd == -3) // is a separator
			{
				CPen pnDk(PS_SOLID,1,cr3dShadow);
				CPen pnLt(PS_SOLID,1,cr3dHilight);
				CPen * opn = pDC->SelectObject(&pnDk);
				pDC->MoveTo(rc.left + 2, rc.top + 2);
				pDC->LineTo(rc.right - 2, rc.top + 2);
				pDC->SelectObject(&pnLt);
				pDC->MoveTo(rc.left + 2, rc.top + 3);
				pDC->LineTo(rc.right - 2, rc.top + 3);
				pDC->SelectObject(opn);
			}
			else if (pItem->iCmd == -4) // is a title item
			{
				CString cs(pItem->cText), cs1;
				CRect rcBdr(rcText);

				if (bSelect && bEnab)
				{
					rcText.top ++;
					rcText.left += 2;
				}
				pDC->FillSolidRect(rcText, crMenu);
				pDC->DrawText(cs, rcText, DT_VCENTER|DT_CENTER|DT_SINGLELINE);
				if (bSelect && bEnab) pDC->Draw3dRect(rcBdr,cr3dShadow,cr3dHilight);
			}
			else
			{
				rcText.left += rcImage.right + 1;

				int obk = pDC->SetBkMode(TRANSPARENT);
				
				COLORREF ocr;
				if (bSelect)
				{
					if (pItem->iImageIdx >= 0 || (state & ODS_CHECKED))
						pDC->FillSolidRect(rcText, crHighlight);
					else
						pDC->FillSolidRect(rc, crHighlight);

					ocr = pDC->SetTextColor(crMenuTextSel);
				}
				else
				{
					if (pItem->iImageIdx >= 0 || (state & ODS_CHECKED))
						pDC->FillSolidRect(rcText, crMenu);
					else
						pDC->FillSolidRect(rc/*rcText*/, crMenu);
					ocr = pDC->SetTextColor(crMenuText);
				}

				if (pItem->iImageIdx >= 0)
				{
					int ay = (rcImage.Height() - szImage.cy) / 2;
					int ax = (rcImage.Width()  - szImage.cx) / 2;

					if (bSelect && bEnab)
						pDC->Draw3dRect(rcImage,cr3dHilight,cr3dShadow);
					else
					{
						pDC->Draw3dRect(rcImage,crMenu,crMenu);
					}


					if (bEnab)
					{
						ilList.Draw(pDC, pItem->iImageIdx, CPoint(rcImage.left + ax, rcImage.top +ay), ILD_NORMAL);
					}
//.........这里部分代码省略.........
开发者ID:3rdexp,项目名称:jezzitest,代码行数:101,代码来源:GfxPopupMenu.cpp


示例2: getRunner

/**
 * For a given query, get a runner.
 */
Status getRunner(Collection* collection,
                 CanonicalQuery* rawCanonicalQuery,
                 Runner** out,
                 size_t plannerOptions) {

    verify(rawCanonicalQuery);
    auto_ptr<CanonicalQuery> canonicalQuery(rawCanonicalQuery);

    // This can happen as we're called by internal clients as well.
    if (NULL == collection) {
        const string& ns = canonicalQuery->ns();
        LOG(2) << "Collection " << ns << " does not exist."
               << " Using EOF runner: " << canonicalQuery->toStringShort();
        *out = new EOFRunner(canonicalQuery.release(), ns);
        return Status::OK();
    }

    // If we have an _id index we can use the idhack runner.
    if (IDHackRunner::supportsQuery(*canonicalQuery) &&
            collection->getIndexCatalog()->findIdIndex()) {
        LOG(2) << "Using idhack: " << canonicalQuery->toStringShort();
        *out = new IDHackRunner(collection, canonicalQuery.release());
        return Status::OK();
    }

    // Tailable: If the query requests tailable the collection must be capped.
    if (canonicalQuery->getParsed().hasOption(QueryOption_CursorTailable)) {
        if (!collection->isCapped()) {
            return Status(ErrorCodes::BadValue,
                          "error processing query: " + canonicalQuery->toString() +
                          " tailable cursor requested on non capped collection");
        }

        // If a sort is specified it must be equal to expectedSort.
        const BSONObj expectedSort = BSON("$natural" << 1);
        const BSONObj& actualSort = canonicalQuery->getParsed().getSort();
        if (!actualSort.isEmpty() && !(actualSort == expectedSort)) {
            return Status(ErrorCodes::BadValue,
                          "error processing query: " + canonicalQuery->toString() +
                          " invalid sort specified for tailable cursor: "
                          + actualSort.toString());
        }
    }

    // Fill out the planning params.  We use these for both cached solutions and non-cached.
    QueryPlannerParams plannerParams;
    plannerParams.options = plannerOptions;
    fillOutPlannerParams(collection, rawCanonicalQuery, &plannerParams);

    // Try to look up a cached solution for the query.

    CachedSolution* rawCS;
    if (PlanCache::shouldCacheQuery(*canonicalQuery) &&
            collection->infoCache()->getPlanCache()->get(*canonicalQuery, &rawCS).isOK()) {
        // We have a CachedSolution.  Have the planner turn it into a QuerySolution.
        boost::scoped_ptr<CachedSolution> cs(rawCS);
        QuerySolution *qs, *backupQs;
        QuerySolution*& chosenSolution=qs; // either qs or backupQs
        Status status = QueryPlanner::planFromCache(*canonicalQuery, plannerParams, *cs,
                        &qs, &backupQs);

        if (status.isOK()) {
            // the working set will be shared by the root and backupRoot plans
            // and owned by the containing single-solution-runner
            //
            WorkingSet* sharedWs = new WorkingSet();

            PlanStage *root, *backupRoot=NULL;
            verify(StageBuilder::build(collection, *qs, sharedWs, &root));
            if ((plannerParams.options & QueryPlannerParams::PRIVATE_IS_COUNT)
                    && turnIxscanIntoCount(qs)) {
                LOG(2) << "Using fast count: " << canonicalQuery->toStringShort()
                       << ", planSummary: " << getPlanSummary(*qs);

                if (NULL != backupQs) {
                    delete backupQs;
                }
            }
            else if (NULL != backupQs) {
                verify(StageBuilder::build(collection, *backupQs, sharedWs, &backupRoot));
            }

            // add a CachedPlanStage on top of the previous root
            root = new CachedPlanStage(collection, rawCanonicalQuery, root, backupRoot);

            *out = new SingleSolutionRunner(collection,
                                            canonicalQuery.release(),
                                            chosenSolution, root, sharedWs);
            return Status::OK();
        }
    }

    if (internalQueryPlanOrChildrenIndependently
            && SubplanRunner::canUseSubplanRunner(*canonicalQuery)) {

        QLOG() << "Running query as sub-queries: " << canonicalQuery->toStringShort();
        LOG(2) << "Running query as sub-queries: " << canonicalQuery->toStringShort();
//.........这里部分代码省略.........
开发者ID:Robbie1977,项目名称:mongo,代码行数:101,代码来源:get_runner.cpp


示例3: Lock

 int Lock() {
    CriticalSection cs(&_mutex);
    int old = _u._a._lock;
    _u._a._lock = 1; 
    return old;
 }
开发者ID:QuLogic,项目名称:jot-lib,代码行数:6,代码来源:ref.hpp


示例4: assert

CNode* VariableEliminator::eliminate_var_conjunct(CNode* node, VariableTerm* evar)
{

	if(DEBUG) {
		cout << "IN ELIMINATE VAR FROM CONJUNCT " << node->to_string()<< endl;
		cout << "Trying to eliminate: " << evar->to_string() <<endl;
	}

	int initial_count = fresh_var_counter;
	assert(node->is_conjunct());


	Clause cl(node);
	map<Term*, Term*> denestings;
	cl.denest( &denestings);



	if(DEBUG) {
		cout << "DENESTINGS: " << endl;
		map<Term*, Term*>::iterator it = denestings.begin();
		for(; it!= denestings.end(); it++)
		{
			cout << "\t " << it->first->to_string() <<
			"-> " << it->second->to_string() << endl;
		}
	}


	ClauseSolve cs(&cl, NULL);
	bool res = cs.is_sat();



	/*
	 * If the clause is UNSAT, the SNC is false.
	 * We call sat to ensure that all relevant interactions
	 * are propagated between the ILP and EQ domains. After calling
	 * sat, eq_members, var_to_cols etc are properly initialized.
	 */
	if(!res){
		return False::make();
	}

	Term* rep = cs.find_representative(evar);



	Term* valid_rep = NULL;
	if(rep!=NULL && !rep->contains_term(evar) && denestings.count(rep)==0) {
		valid_rep = rep;
	}
	else {
		set<Term*>& eq_class = cs.eq_members[rep];
		set<Term*>::iterator it = eq_class.begin();
		for(; it!= eq_class.end(); it++) {
			Term* cur_t = *it;
			if(!cur_t->contains_term(evar)&&denestings.count(cur_t)==0){
				valid_rep = cur_t;
				break;
			}
		}
	}


	/*
	 * We found one member in the equivalence class of this variable
	 * that does not contain that variable.
	 */
	if(valid_rep != NULL) {
		map<Term*, Term*> subs;
		subs[evar] = valid_rep;
		CNode* res = node->substitute(subs);
		node = node->substitute(denestings);
		return res;
	}


	set<FunctionTerm*> direct_parents;
	get_direct_parents(evar, direct_parents, cs.eq_members);

	if(!over_approximate) {
			if(direct_parents.size() > 0) return False::make();
		}


	/*
	 * Base case: If this term does not contain any parent terms,
	 * eliminate it from the ILP domain
	 */
	if(direct_parents.size() == 0 && cs.ilp_vars.count(evar->get_var_id()) > 0 ){
		set<CNode*> mod_constraints;
		if(DEBUG) {
			cout << "ELIMINATING FROM ILP: " << cl.to_string("&") << endl;
		}
		CNode* res= eliminate_var_from_ilp_domain(cl, evar, mod_constraints);
		if(DEBUG) {
			cout << "AFTER ELIMINATING FROM ILP: " << res->to_string() << endl;
		}
		res = eliminate_denestings(res, denestings, evar, initial_count, false);
//.........这里部分代码省略.........
开发者ID:xwangsd,项目名称:mistral,代码行数:101,代码来源:VariableEliminator.cpp


示例5: Lock

/*!
	\brief Sets all the cursors from a specified CursorSet
	\param path Path to the cursor set
	
	All cursors in the set will be assigned. If the set does not specify a cursor for a
	particular cursor specifier, it will remain unchanged. This function will fail if passed
	a NULL path, an invalid path, or the path to a non-CursorSet file.
*/
void CursorManager::SetCursorSet(const char *path)
{
	Lock();
	CursorSet cs(NULL);
	
	if(!path || cs.Load(path)!=B_OK)
		return;
	ServerCursor *csr;
	
	if(cs.FindCursor(B_CURSOR_DEFAULT,&csr)==B_OK)
	{
		if(fDefaultCursor)
			delete fDefaultCursor;
		fDefaultCursor=csr;
	}
	
	if(cs.FindCursor(B_CURSOR_TEXT,&csr)==B_OK)
	{
		if(fTextCursor)
			delete fTextCursor;
		fTextCursor=csr;
	}
	
	if(cs.FindCursor(B_CURSOR_MOVE,&csr)==B_OK)
	{
		if(fMoveCursor)
			delete fMoveCursor;
		fMoveCursor=csr;
	}
	
	if(cs.FindCursor(B_CURSOR_DRAG,&csr)==B_OK)
	{
		if(fDragCursor)
			delete fDragCursor;
		fDragCursor=csr;
	}
	
	if(cs.FindCursor(B_CURSOR_RESIZE,&csr)==B_OK)
	{
		if(fResizeCursor)
			delete fResizeCursor;
		fResizeCursor=csr;
	}
	
	if(cs.FindCursor(B_CURSOR_RESIZE_NWSE,&csr)==B_OK)
	{
		if(fNWSECursor)
			delete fNWSECursor;
		fNWSECursor=csr;
	}
	
	if(cs.FindCursor(B_CURSOR_RESIZE_NESW,&csr)==B_OK)
	{
		if(fNESWCursor)
			delete fNESWCursor;
		fNESWCursor=csr;
	}
	
	if(cs.FindCursor(B_CURSOR_RESIZE_NS,&csr)==B_OK)
	{
		if(fNSCursor)
			delete fNSCursor;
		fNSCursor=csr;
	}
	
	if(cs.FindCursor(B_CURSOR_RESIZE_EW,&csr)==B_OK)
	{
		if(fEWCursor)
			delete fEWCursor;
		fEWCursor=csr;
	}
	Unlock();
	
}
开发者ID:Ithamar,项目名称:cosmoe,代码行数:82,代码来源:CursorManager.cpp


示例6: MPI_Comm_rank

unsigned long CSysSolve::FGMRES(const CSysVector & b, CSysVector & x, CMatrixVectorProduct & mat_vec,
                               CPreconditioner & precond, double tol, unsigned long m, bool monitoring) {
	
int rank = 0;

#ifndef NO_MPI
#ifdef WINDOWS
	MPI_Comm_rank(MPI_COMM_WORLD, &rank);
#else
	rank = MPI::COMM_WORLD.Get_rank();
#endif
#endif
  
  /*---  Check the subspace size ---*/
  if (m < 1) {
    if (rank == 0) cerr << "CSysSolve::FGMRES: illegal value for subspace size, m = " << m << endl;
#ifdef NO_MPI
    exit(1);
#else
#ifdef WINDOWS
	MPI_Abort(MPI_COMM_WORLD,1);
    MPI_Finalize();
#else
    MPI::COMM_WORLD.Abort(1);
    MPI::Finalize();
#endif
#endif
  }

  /*---  Check the subspace size ---*/
  if (m > 1000) {
    if (rank == 0) cerr << "CSysSolve::FGMRES: illegal value for subspace size (too high), m = " << m << endl;
#ifdef NO_MPI
    exit(1);
#else
#ifdef WINDOWS
	MPI_Abort(MPI_COMM_WORLD,1);
    MPI_Finalize();
#else
    MPI::COMM_WORLD.Abort(1);
    MPI::Finalize();
#endif
#endif
  }
  
  /*---  Define various arrays
	 Note: elements in w and z are initialized to x to avoid creating
	 a temporary CSysVector object for the copy constructor ---*/
  vector<CSysVector> w(m+1, x);
  vector<CSysVector> z(m+1, x);
  vector<double> g(m+1, 0.0);
  vector<double> sn(m+1, 0.0);
  vector<double> cs(m+1, 0.0);
  vector<double> y(m, 0.0);
  vector<vector<double> > H(m+1, vector<double>(m, 0.0));
  
  /*---  Calculate the norm of the rhs vector ---*/
  double norm0 = b.norm();
  
  /*---  Calculate the initial residual (actually the negative residual)
	 and compute its norm ---*/
  mat_vec(x,w[0]);
  w[0] -= b;
  
  double beta = w[0].norm();
  
  if ( (beta < tol*norm0) || (beta < eps) ) {
    /*---  System is already solved ---*/
    if (rank == 0) cout << "CSysSolve::FGMRES(): system solved by initial guess." << endl;
    return 0;
  }
  
  /*---  Normalize residual to get w_{0} (the negative sign is because w[0]
	 holds the negative residual, as mentioned above) ---*/
  w[0] /= -beta;
  
  /*---  Initialize the RHS of the reduced system ---*/
  g[0] = beta;
  
  /*--- Set the norm to the initial initial residual value ---*/
  norm0 = beta;

  /*---  Output header information including initial residual ---*/
  int i = 0;
  if ((monitoring) && (rank == 0)) {
    writeHeader("FGMRES", tol, beta);
    writeHistory(i, beta, norm0);
  }
  
  /*---  Loop over all serach directions ---*/
  for (i = 0; i < m; i++) {
    
    /*---  Check if solution has converged ---*/
    if (beta < tol*norm0) break;
    
    /*---  Precondition the CSysVector w[i] and store result in z[i] ---*/
    precond(w[i], z[i]);
    
    /*---  Add to Krylov subspace ---*/
    mat_vec(z[i], w[i+1]);
//.........这里部分代码省略.........
开发者ID:CFDOPT,项目名称:SU2,代码行数:101,代码来源:linear_solvers_structure.cpp


示例7: Accept

void CQuotesProviderBase::Run()
{
	CQuotesProviderVisitorDbSettings visitor;
	Accept(visitor);

	DWORD nTimeout = get_refresh_timeout_miliseconds(visitor);
	m_sContactListFormat = Quotes_DBGetStringT(NULL,QUOTES_PROTOCOL_NAME,visitor.m_pszDbDisplayNameFormat,visitor.m_pszDefDisplayFormat);
	m_sStatusMsgFormat = Quotes_DBGetStringT(NULL,QUOTES_PROTOCOL_NAME,visitor.m_pszDbStatusMsgFormat,visitor.m_pszDefStatusMsgFormat);
	m_sTendencyFormat = Quotes_DBGetStringT(NULL,QUOTES_PROTOCOL_NAME,visitor.m_pszDbTendencyFormat,visitor.m_pszDefTendencyFormat);

	enum{
		STOP_THREAD = 0,
		SETTINGS_CHANGED = 1,
		REFRESH_CONTACT = 2,
		COUNT_SYNC_OBJECTS = 3
	};

	HANDLE anEvents[COUNT_SYNC_OBJECTS];
	anEvents[STOP_THREAD] = g_hEventWorkThreadStop;
	anEvents[SETTINGS_CHANGED] = m_hEventSettingsChanged;
	anEvents[REFRESH_CONTACT] = m_hEventRefreshContact;

	TContracts anContacts;
	{
		CGuard<CLightMutex> cs(m_cs);
		anContacts = m_aContacts;
	}

	bool bGoToBed = false;

	while(false == bGoToBed)
	{		
		{
			CBoolGuard bg(m_bRefreshInProgress);
// 			LogIt(Info,_T("Begin contacts refreshing"));
			RefreshQuotes(anContacts);
// 			LogIt(Info,_T("End contacts refreshing"));
		}
		anContacts.clear();

		DWORD dwBegin = ::GetTickCount();
		DWORD dwResult = ::WaitForMultipleObjects(COUNT_SYNC_OBJECTS,anEvents,FALSE,nTimeout);
		switch(dwResult)
		{
		case WAIT_FAILED:
			assert(!"WaitForMultipleObjects failed");
			bGoToBed = true;
			break;
		case WAIT_ABANDONED_0+STOP_THREAD:
		case WAIT_ABANDONED_0+SETTINGS_CHANGED:
		case WAIT_ABANDONED_0+REFRESH_CONTACT:
			assert(!"WaitForMultipleObjects abandoned");
		case WAIT_OBJECT_0+STOP_THREAD:
			bGoToBed = true;
			break;
		case WAIT_OBJECT_0+SETTINGS_CHANGED:
			nTimeout = get_refresh_timeout_miliseconds(visitor);
			m_sContactListFormat = Quotes_DBGetStringT(NULL,QUOTES_PROTOCOL_NAME,visitor.m_pszDbDisplayNameFormat,visitor.m_pszDefDisplayFormat);
			m_sStatusMsgFormat = Quotes_DBGetStringT(NULL,QUOTES_PROTOCOL_NAME,visitor.m_pszDbStatusMsgFormat,visitor.m_pszDefStatusMsgFormat);
			m_sTendencyFormat = Quotes_DBGetStringT(NULL,QUOTES_PROTOCOL_NAME,visitor.m_pszDbTendencyFormat,visitor.m_pszDefTendencyFormat);

			{
				CGuard<CLightMutex> cs(m_cs);
				anContacts = m_aContacts;
			}
			break;
		case WAIT_OBJECT_0+REFRESH_CONTACT:
			{
				DWORD dwTimeRest = ::GetTickCount()-dwBegin;
				if(dwTimeRest < nTimeout)
					nTimeout -= dwTimeRest;

				CGuard<CLightMutex> cs(m_cs);
				anContacts = m_aRefreshingContacts;
				m_aRefreshingContacts.clear();
			}
			break;
		case WAIT_TIMEOUT:
			nTimeout = get_refresh_timeout_miliseconds(visitor);
			{
				CGuard<CLightMutex> cs(m_cs);
				anContacts = m_aContacts;
			}
			break;
		default:
			assert(!"What is the hell?");
		}
	}

	OnEndRun();
}
开发者ID:slotwin,项目名称:miranda-ng,代码行数:91,代码来源:QuotesProviderBase.cpp


示例8: operator

		int operator()(void) const
		{
			os::CriticalSection cs("OGLplus example");
			Application::ParseCommandLineOptions(argc, argv);
			return main_func(argc, argv);
		}
开发者ID:BrainlessLabsInc,项目名称:oglplus,代码行数:6,代码来源:example_main.hpp


示例9: while

void LinkLocal::Stream::processNext()
{
	while(1) {
//		printf("################# %s\n", (proto->c2c_local) ? "Client" : "Server" );
		bool ok = proto->processStep();
		if(!ok && proto->need!=CoreProtocol::NSASLMechs && state!=WaitTLS) {
//			printf("pased: %d\n", ok ? 1 : 0);
			int need = proto->need;
//			printf("need: %d\n", need);
			if(need == CoreProtocol::NSASLMechs) {
				QStringList list;
				proto->setSASLMechList(list);
				return;
			}

			if(!in.isEmpty()) {
// 				printf("in not empty\n");
				QTimer::singleShot(0, this, SLOT(doReadyRead()));
			}

		return;
		}

		int event = proto->event;
// 		printf("event: %d\n", event);
		switch(event) {
			case CoreProtocol::EError: {
// 				printf("Error! Code=%d\n", proto->errorCode);
//				handleError();
				return;
			}
			case CoreProtocol::ESend: {
				QByteArray a = proto->takeOutgoingData();
				QByteArray cs(a.size()+1,'\0');
				memcpy(cs.data(), a.data(), a.size());
// 				printf("Need Send: {%s}\n", cs.data());
				bs_->write(a);
				break;
			}
			case CoreProtocol::ERecvOpen: {
// 				printf("Break (RecvOpen)\n");
				if(proto->old) {
					state = WaitVersion;
// 					printf("WarnOldVersion\n");
					return;
				}
				break;
			}
			case CoreProtocol::EFeatures: {
// 				printf("Break (Features)\n");
				if(state == WaitTLS)
					state = Active;
				else
					state = WaitTLS;
				break;
			}
			case CoreProtocol::ESASLSuccess: {
// 				printf("Break SASL Success\n");
				break;
			}
			case CoreProtocol::EReady: {
// 				printf("Done!\n");
				state = Active;
				ready();
				break;
			}
			case CoreProtocol::EPeerClosed: {
//				printf("DocumentClosed\n");
//				reset();
//				connectionClosed();
				return;
			}
			case CoreProtocol::EStanzaReady: {
//				printf("StanzaReady\n");
				// store the stanza for now, announce after processing all events
				Stanza s = createStanza(proto->recvStanza());
				if(s.isNull())
					break;
				in.append(new Stanza(s));
				break;
			}
			case CoreProtocol::EStanzaSent: {
//				printf("StanzasSent\n");
//				stanzaWritten();
//				if(!self)
//					return;
				break;
			}
			case CoreProtocol::EClosed: {
//				printf("Closed\n");
//				reset();
//				delayedCloseFinished();
				return;
			}
		}
	}
}
开发者ID:BackupTheBerlios,项目名称:synapse-xmpp-svn,代码行数:97,代码来源:linklocal_stream.cpp


示例10: cs

void CallTargetFinder<dsa>::findIndTargets(Module &M)
{
  dsa* T = &getAnalysis<dsa>();
  const DSCallGraph & callgraph = T->getCallGraph();
  DSGraph* G = T->getGlobalsGraph();
  DSGraph::ScalarMapTy& SM = G->getScalarMap();
  for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I)
    if (!I->isDeclaration())
      for (Function::iterator F = I->begin(), FE = I->end(); F != FE; ++F)
        for (BasicBlock::iterator B = F->begin(), BE = F->end(); B != BE; ++B)
          if (isa<CallInst>(B) || isa<InvokeInst>(B)) {
            CallSite cs(B);
            AllSites.push_back(cs);
            Function* CF = cs.getCalledFunction();

            if (isa<UndefValue>(cs.getCalledValue())) continue;
            if (isa<InlineAsm>(cs.getCalledValue())) continue;

            //
            // If the called function is casted from one function type to
            // another, peer into the cast instruction and pull out the actual
            // function being called.
            //
            if (!CF)
              CF = dyn_cast<Function>(cs.getCalledValue()->stripPointerCasts());

            if (!CF) {
              Value * calledValue = cs.getCalledValue()->stripPointerCasts();
              if (isa<ConstantPointerNull>(calledValue)) {
                ++DirCall;
                CompleteSites.insert(cs);
              } else {
                IndCall++;

                DSCallGraph::callee_iterator csi = callgraph.callee_begin(cs),
                                   cse = callgraph.callee_end(cs);
                while(csi != cse) {
                  const Function *F = *csi;
                  DSCallGraph::scc_iterator sccii = callgraph.scc_begin(F),
                    sccee = callgraph.scc_end(F);
                  for(;sccii != sccee; ++sccii) {
                    DSGraph::ScalarMapTy::const_iterator I = SM.find(SM.getLeaderForGlobal(*sccii));
                    if (I != SM.end()) {
                      IndMap[cs].push_back (*sccii);
                    }
                  }
                  ++csi;
                }
                const Function *F1 = (cs).getInstruction()->getParent()->getParent();
                F1 = callgraph.sccLeader(&*F1);
                
                DSCallGraph::scc_iterator sccii = callgraph.scc_begin(F1),
                  sccee = callgraph.scc_end(F1);
                for(;sccii != sccee; ++sccii) {
                  DSGraph::ScalarMapTy::const_iterator I = SM.find(SM.getLeaderForGlobal(*sccii));
                  if (I != SM.end()) {
                    IndMap[cs].push_back (*sccii);
                  }
                }

                DSNode* N = T->getDSGraph(*cs.getCaller())
                  ->getNodeForValue(cs.getCalledValue()).getNode();
                assert (N && "CallTarget: findIndTargets: No DSNode!");

                if (!N->isIncompleteNode() && !N->isExternalNode() && IndMap[cs].size()) {
                  CompleteSites.insert(cs);
                  ++CompleteInd;
                } 
                if (!N->isIncompleteNode() && !N->isExternalNode() && !IndMap[cs].size()) {
                  ++CompleteEmpty;
                  DEBUG(errs() << "Call site empty: '"
                                << cs.getInstruction()->getName()
                                << "' In '"
                                << cs.getInstruction()->getParent()->getParent()->getName()
                                << "'\n");
                }
              }
            } else {
              ++DirCall;
              IndMap[cs].push_back(CF);
              CompleteSites.insert(cs);
            }
          }
}
开发者ID:whonore,项目名称:llvm-dsa,代码行数:84,代码来源:CallTargets.cpp


示例11: SignalStop

	void LogToFile :: SignalStop()
	{
		CriticalSection cs(&mLock);
		cs.Signal();
	}
开发者ID:emezeske,项目名称:dnp3,代码行数:5,代码来源:LogToFile.cpp


示例12: s

// Exercise almost every LocalPointer and LocalPointerBase method.
void LocalPointerTest::TestLocalPointer() {
    // constructor
    LocalPointer<UnicodeString> s(new UnicodeString((UChar32)0x50005));
    // isNULL(), isValid(), operator==(), operator!=()
    if(s.isNull() || !s.isValid() || s==NULL || !(s!=NULL)) {
        errln("LocalPointer constructor or NULL test failure");
        return;
    }
    // getAlias(), operator->, operator*
    if(s.getAlias()->length()!=2 || s->length()!=2 || (*s).length()!=2) {
        errln("LocalPointer access failure");
    }
    // adoptInstead(), orphan()
    s.adoptInstead(new UnicodeString((UChar)0xfffc));
    if(s->length()!=1) {
        errln("LocalPointer adoptInstead(U+FFFC) failure");
    }
    UnicodeString *orphan=s.orphan();
    if(orphan==NULL || orphan->length()!=1 || s.isValid() || s!=NULL) {
        errln("LocalPointer orphan() failure");
    }
    delete orphan;
    s.adoptInstead(new UnicodeString());
    if(s->length()!=0) {
        errln("LocalPointer adoptInstead(empty) failure");
    }

    // LocalPointer(p, errorCode) sets U_MEMORY_ALLOCATION_ERROR if p==NULL.
    UErrorCode errorCode = U_ZERO_ERROR;
    LocalPointer<CharString> cs(new CharString("some chars", errorCode), errorCode);
    if(cs.isNull() && U_SUCCESS(errorCode)) {
        errln("LocalPointer(p, errorCode) failure");
        return;
    }
    errorCode = U_ZERO_ERROR;
    cs.adoptInsteadAndCheckErrorCode(new CharString("different chars", errorCode), errorCode);
    if(cs.isNull() && U_SUCCESS(errorCode)) {
        errln("adoptInsteadAndCheckErrorCode(p, errorCode) failure");
        return;
    }
    // Incoming failure: Keep the current object and delete the input object.
    errorCode = U_ILLEGAL_ARGUMENT_ERROR;
    cs.adoptInsteadAndCheckErrorCode(new CharString("unused", errorCode), errorCode);
    if(cs.isValid() && strcmp(cs->data(), "different chars") != 0) {
        errln("adoptInsteadAndCheckErrorCode(p, U_FAILURE) did not retain the old object");
        return;
    }
    errorCode = U_ZERO_ERROR;
    cs.adoptInsteadAndCheckErrorCode(NULL, errorCode);
    if(errorCode != U_MEMORY_ALLOCATION_ERROR) {
        errln("adoptInsteadAndCheckErrorCode(NULL, errorCode) did not set U_MEMORY_ALLOCATION_ERROR");
        return;
    }
    if(cs.isValid()) {
        errln("adoptInsteadAndCheckErrorCode(NULL, errorCode) kept the object");
        return;
    }
    errorCode = U_ZERO_ERROR;
    LocalPointer<CharString> null(NULL, errorCode);
    if(errorCode != U_MEMORY_ALLOCATION_ERROR) {
        errln("LocalPointer(NULL, errorCode) did not set U_MEMORY_ALLOCATION_ERROR");
        return;
    }

    // destructor
}
开发者ID:simul,项目名称:icu,代码行数:67,代码来源:itutil.cpp


示例13: tryAgain

    virtual void tryAgain() {
        // All exits of the method must emit the ready signal
        // so all exits go through a goto ready;
        if(step == 0) {
            out_mech = mechanism_;

#ifdef SIMPLESASL_PLAIN
            // PLAIN
            if (out_mech == "PLAIN") {
                // First, check if we have everything
                if(need.user || need.pass) {
                    qWarning("simplesasl.cpp: Did not receive necessary auth parameters");
                    result_ = Error;
                    goto ready;
                }
                if(!have.user)
                    need.user = true;
                if(!have.pass)
                    need.pass = true;
                if(need.user || need.pass) {
                    result_ = Params;
                    goto ready;
                }

                // Continue with authentication
                QByteArray plain;
                if (!authz.isEmpty())
                    plain += authz.toUtf8();
                plain += '\0' + user.toUtf8() + '\0' + pass.toByteArray();
                out_buf.resize(plain.length());
                memcpy(out_buf.data(), plain.data(), out_buf.size());
            }
#endif
            ++step;
            if (out_mech == "PLAIN")
                result_ = Success;
            else
                result_ = Continue;
        }
        else if(step == 1) {
            // if we still need params, then the app has failed us!
            if(need.user || need.authzid || need.pass || need.realm) {
                qWarning("simplesasl.cpp: Did not receive necessary auth parameters");
                result_ = Error;
                goto ready;
            }
            // see if some params are needed
            if(!have.user)
                need.user = true;
            //if(!have.authzid)
            //	need.authzid = true;
            if(!have.pass)
                need.pass = true;
            if(need.user || need.authzid || need.pass) {
                result_ = Params;
                goto ready;
            }

            // get props
            QByteArray cs(in_buf);
            PropList in;
            if(!in.fromString(cs)) {
                authCondition_ = QCA::SASL::BadProtocol;
                result_ = Error;
                goto ready;
            }
            //qDebug() << (QString("simplesasl.cpp: IN: %1").arg(QString(in.toString())));

            // make a cnonce
            QByteArray a(32,'\0');
            for(int n = 0; n < (int)a.size(); ++n)
                a[n] = (char)(256.0*rand()/(RAND_MAX+1.0));
            QByteArray cnonce = QCA::Base64().arrayToString(a).toLatin1();

            // make other variables
            if (realm.isEmpty())
                realm = QString::fromUtf8(in.get("realm"));
            QByteArray nonce = in.get("nonce");
            QByteArray nc = "00000001";
            QByteArray uri = service.toUtf8() + '/' + host.toUtf8();
            QByteArray qop = "auth";

            // build 'response'
            QByteArray X = user.toUtf8() + ':' + realm.toUtf8() + ':' + pass.toByteArray();
            QByteArray Y = QCA::Hash("md5").hash(X).toByteArray();
            QByteArray tmp = ':' + nonce + ':' + cnonce;
            if (!authz.isEmpty())
                tmp += ':' + authz.toUtf8();
            //qDebug() << (QString(tmp));

            QByteArray A1(Y + tmp);
            QByteArray A2 = QByteArray("AUTHENTICATE:") + uri;
            QByteArray HA1 = QCA::Hash("md5").hashToString(A1).toLatin1();
            QByteArray HA2 = QCA::Hash("md5").hashToString(A2).toLatin1();
            QByteArray KD = HA1 + ':' + nonce + ':' + nc + ':' + cnonce + ':' + qop + ':' + HA2;
            QByteArray Z = QCA::Hash("md5").hashToString(KD).toLatin1();

            //qDebug() << (QString("simplesasl.cpp: A1 = %1").arg(QString(A1)).toAscii());
            //qDebug() << (QString("simplesasl.cpp: A2 = %1").arg(QString(A2)).toAscii());
            //qDebug() << (QString("simplesasl.cpp: KD = %1").arg(QString(KD)).toAscii());
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:synapse-xmpp-svn,代码行数:101,代码来源:simplesasl.cpp


示例14: XML_GetErrorCode


//.........这里部分代码省略.........
  nsParserMsgUtils::GetLocalizedStringByID(XMLPARSER_PROPERTIES, code,
                                           description);

  if (code == XML_ERROR_TAG_MISMATCH) {
    /**
     *  Expat can send the following:
     *    localName
     *    namespaceURI<separator>localName
     *    namespaceURI<separator>localName<separator>prefix
     *
     *  and we use 0xFFFF for the <separator>.
     *
     */
    const PRUnichar *mismatch = MOZ_XML_GetMismatchedTag(mExpatParser);
    const PRUnichar *uriEnd = nullptr;
    const PRUnichar *nameEnd = nullptr;
    const PRUnichar *pos;
    for (pos = mismatch; *pos; ++pos) {
      if (*pos == kExpatSeparatorChar) {
        if (uriEnd) {
          nameEnd = pos;
        }
        else {
          uriEnd = pos;
        }
      }
    }

    nsAutoString tagName;
    if (uriEnd && nameEnd) {
      // We have a prefix.
      tagName.Append(nameEnd + 1, pos - nameEnd - 1);
      tagName.Append(PRUnichar(':'));
    }
    const PRUnichar *nameStart = uriEnd ? uriEnd + 1 : mismatch;
    tagName.Append(nameStart, (nameEnd ? nameEnd : pos) - nameStart);
    
    nsAutoString msg;
    nsParserMsgUtils::GetLocalizedStringByName(XMLPARSER_PROPERTIES,
                                               "Expected", msg);

    // . Expected: </%S>.
    PRUnichar *message = nsTextFormatter::smprintf(msg.get(), tagName.get());
    if (!message) {
      return NS_ERROR_OUT_OF_MEMORY;
    }

    description.Append(message);

    nsTextFormatter::smprintf_free(message);
  }

  // Adjust the column number so that it is one based rather than zero based.
  uint32_t colNumber = XML_GetCurrentColumnNumber(mExpatParser) + 1;
  uint32_t lineNumber = XML_GetCurrentLineNumber(mExpatParser);

  nsAutoString errorText;
  CreateErrorText(description.get(), XML_GetBase(mExpatParser), lineNumber,
                  colNumber, errorText);

  NS_ASSERTION(mSink, "no sink?");

  nsAutoString sourceText(mLastLine);
  AppendErrorPointer(colNumber, mLastLine.get(), sourceText);

  // Try to create and initialize the script error.
  nsCOMPtr<nsIScriptError> serr(do_CreateInstance(NS_SCRIPTERROR_CONTRACTID));
  nsresult rv = NS_ERROR_FAILURE;
  if (serr) {
    rv = serr->InitWithWindowID(description.get(),
                                mURISpec.get(),
                                mLastLine.get(),
                                lineNumber, colNumber,
                                nsIScriptError::errorFlag, "malformed-xml",
                                mInnerWindowID);
  }

  // If it didn't initialize, we can't do any logging.
  bool shouldReportError = NS_SUCCEEDED(rv);

  if (mSink && shouldReportError) {
    rv = mSink->ReportError(errorText.get(), 
                            sourceText.get(), 
                            serr, 
                            &shouldReportError);
    if (NS_FAILED(rv)) {
      shouldReportError = true;
    }
  }

  if (shouldReportError) {
    nsCOMPtr<nsIConsoleService> cs
      (do_GetService(NS_CONSOLESERVICE_CONTRACTID));  
    if (cs) {
      cs->LogMessage(serr);
    }
  }

  return NS_ERROR_HTMLPARSER_STOPPARSING;
}
开发者ID:Lynart,项目名称:mozilla-central,代码行数:101,代码来源:nsExpatDriver.cpp


示例15: cs

void CCredentialsManager::loadCA(const std::string& strPath)
{
	std::shared_ptr<Botan::Certificate_Store> cs(new Botan::Certificate_Store_In_Memory(strPath));
	m_vCerts.push_back(cs);
}
开发者ID:sxtyzhangzk,项目名称:LiBrother,代码行数:5,代码来源:credentials_manager.cpp


示例16: AreaLighting

void 												
World::build(void) {
	int num_samples = 100;
	
	vp.set_hres(600);
	vp.set_vres(400);
	vp.set_samples(num_samples);
		
	tracer_ptr = new AreaLighting(this);	
		
	AmbientOccluder* ambient_occluder_ptr = new AmbientOccluder;
	ambient_occluder_ptr->set_sampler(new MultiJittered(num_samples));
	ambient_occluder_ptr->set_min_amount(0.5);
	set_ambient_light(ambient_occluder_ptr);

			
	Pinhole* pinhole_ptr = new Pinhole;
	pinhole_ptr->set_eye(100, 45, 100);  
	pinhole_ptr->set_lookat(-10, 40, 0);  
	pinhole_ptr->set_view_distance(400);  
	pinhole_ptr->compute_uvw(); 
	set_camera(pinhole_ptr);

	
	Emissive* emissive_ptr = new Emissive;
	emissive_ptr->scale_radiance(0.90);
	emissive_ptr->set_ce(white);   	
		
	ConcaveSphere* sphere_ptr = new ConcaveSphere;
	sphere_ptr->set_radius(1000000.0);
	sphere_ptr->set_material(emissive_ptr);
	sphere_ptr->set_shadows(false);
	add_object(sphere_ptr);
	
	EnvironmentLight* environment_light_ptr = new EnvironmentLight;
	environment_light_ptr->set_material(emissive_ptr);
	environment_light_ptr->set_sampler(new MultiJittered(num_samples));
	environment_light_ptr->set_shadows(true);
	add_light(environment_light_ptr);
	
	
	float ka = 0.2;  		// commom ambient reflection coefficient
	float ks = 1.0;  		// commom specular reflection coefficient
	float exp = 10.0;   	// for Figure 18.11(a)
//	float exp = 50.0;   	// for Figure 18.11(b)
//	float exp = 200.0;   	// for Figure 18.11(c)
	RGBColor cs(1, 0, 0); 	// common specular color
	
	// large sphere
	
	Phong* phong_ptr1 = new Phong;			
	phong_ptr1->set_ka(ka); 
	phong_ptr1->set_kd(0.6);
	phong_ptr1->set_cd(0.75);
	phong_ptr1->set_ks(ks);
	phong_ptr1->set_exp(exp);
	phong_ptr1->set_cs(cs);
	
	Sphere* sphere_ptr1 = new Sphere(Point3D(38, 20, -24), 20);
	sphere_ptr1->set_material(phong_ptr1);
	add_object(sphere_ptr1);
	
	
	// small sphere
		
	Phong* phong_ptr2 = new Phong;			
	phong_ptr2->set_ka(ka); 
	phong_ptr2->set_kd(0.5);
	phong_ptr2->set_cd(0.95);
	phong_ptr2->set_ks(ks);
	phong_ptr2->set_exp(exp);
	phong_ptr2->set_cs(cs);
	
	Sphere* sphere_ptr2 = new Sphere(Point3D(34, 12, 13), 12);
	sphere_ptr2->set_material(phong_ptr2);
	add_object(sphere_ptr2);
	
	
	// medium sphere
	
	Phong* phong_ptr3 = new Phong;			
	phong_ptr3->set_ka(ka); 
	phong_ptr3->set_kd(0.5);
	phong_ptr3->set_cd(0.75);
	phong_ptr3->set_ks(ks);
	phong_ptr3->set_exp(exp);
	phong_ptr3->set_cs(cs);
	
	Sphere* sphere_ptr3 = new Sphere(Point3D(-7, 15, 42), 16);
	sphere_ptr3->set_material(phong_ptr3);
	add_object(sphere_ptr3);
	
	
	// cylinder
	
	Phong* phong_ptr4 = new Phong;			
	phong_ptr4->set_ka(ka); 
	phong_ptr4->set_kd(0.5);
	phong_ptr4->set_cd(0.60);
	phong_ptr4->set_ks(ks);
//.........这里部分代码省略.........
开发者ID:matthiascy,项目名称:crocus-raytracer,代码行数:101,代码来源:BuildFigure18.11.cpp


示例17: main

/**

Most of the main program is pieced together from examples on the web. We are doing the following.

-# Creating lists of include directories, defines, and input files from the command line arguments.
-# Initializing the compiler to read C++ code, and setting the compiler to think we are creating
   code for the default target architecture.
-# Creating the necessary source and file managers as well as the preprocessor.
-# Adding search directories and creating #define statements for -D command line arguments.
-# Telling clang to use our ICGASTConsumer as an ASTConsumer.
-# Parse the input file.

*/
int main( int argc , char * argv[] ) {

#if (__clang_major__ >= 6) || ((__clang_major__ == 3) && (__clang_minor__ >= 5))
    clang::TargetOptions to;
#elif (__clang_major__ == 3) && (__clang_minor__ >= 3)
    clang::TargetOptions * to = new clang::TargetOptions() ;
#else
    clang::TargetOptions to;
#endif
    clang::CompilerInstance ci;

    /* Gather all of the command line arguments into lists of include directories, defines, and input files.
       All other arguments will be ignored. */
    llvm::cl::SetVersionPrinter(ICG_version) ;
    llvm::cl::ParseCommandLineOptions(argc , argv) ;

    if ( ! validAttributesVersion(attr_version) ) {
        return -1 ;
    }

/*
    if ( show_units ) {
        list_units() ;
        return 0 ;
    }
*/

    if ( input_file_names.empty() ) {
        std::cerr << "No header file specified" << std::endl ;
        return 1 ;
    }

    ci.createDiagnostics();
    clang::DiagnosticOptions & diago = ci.getDiagnosticOpts() ;
    diago.ShowColors = 1 ;
    ci.getDiagnostics().setIgnoreAllWarnings(true) ;
#if ( GCC_MAJOR == 4 ) && ( GCC_MINOR <= 2 )
    ci.getDiagnostics().setSuppressAllDiagnostics() ;
#endif

    // Set all of the defaults to c++
    clang::CompilerInvocation::setLangDefaults(ci.getLangOpts() , clang::IK_CXX) ;
    ci.getLangOpts().CXXExceptions = true ;

    // Activate C++11 parsing
    ci.getLangOpts().CPlusPlus11 = true ;

    // Set the default target architecture
#if (__clang_major__ >= 6) || (__clang_major__ == 3) && (__clang_minor__ >= 5)
    to.Triple = llvm::sys::getDefaultTargetTriple();
#elif (__clang_major__ == 3) && (__clang_minor__ >= 3)
    to->Triple = llvm::sys::getDefaultTargetTriple();
#else
    to.Triple = llvm::s 

鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ cs_close函数代码示例发布时间:2022-05-30
下一篇:
C++ crypto_xor函数代码示例发布时间: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