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

C++ ENSURE函数代码示例

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

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



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

示例1: return

BOOL OperationHistory::ReduceSize(UINT32 MaxHistorySize, BOOL ExcludeLastUndo, BOOL DeleteWhatYouCan /*= FALSE*/)
{
    // If the Current size of the operation history is less than or equal to MaxHistorySize then
    // there is no need to do anything.
    if ((CurrentSize <= MaxHistorySize))
        return (TRUE);

    // If The NowPtr is NULL then there are no undo operations to be deleted so return FALSE
    if (NowPtr == NULL)
        return (FALSE);

    // Calculate how many bytes we need to reduce the size of the Operation history by
    UINT32 Reduction = (CurrentSize - MaxHistorySize);

    //-------------------------------------------------------------------------------
    // Check if the operation history can be reduced to MaxHistorySize bytes or less

    // The OpSize total is the count of the number of bytes we can reduce the Operation
    // history by.
    UINT32 OpSizeTotal = 0;

    // We know that the NowPtr is not NULL so the oldest undo operation will be found at
    // the head of the OpHistoryList.
    ListItem* pOp = OpHistoryList.GetHead();

    // We are allowed to delete all operations from the head of the list
    // upto and excluding StopOp. StopOp is the last undo operation if the
    // ExcludeLastUndo flag is TRUE, else it is the first redo operation.
    ListItem* StopOp = (ExcludeLastUndo) ? NowPtr: OpHistoryList.GetNext(NowPtr);


    // Loop until we either hit StopOp or we have found enough operations to delete
    while ((pOp != StopOp) && (OpSizeTotal < Reduction))
    {
        // In a sane world this should always be true
        ENSURE(	pOp != NULL,
                "OperationHistory::ReduceSize: Pointer OperationHistory is NULL");

        // Increase the OpSizeTotal by the number of bytes of the current operation
        OpSizeTotal += ((Operation*)pOp)->GetSize();

        // Get the next operation
        pOp = OpHistoryList.GetNext(pOp);
    };

    //-------------------------------------------------------------------------------
    // Now if we can,  reduce the operation history size

    if ((OpSizeTotal >= Reduction) || (DeleteWhatYouCan && (OpSizeTotal != 0))) // The size can be reduced
    {
        // Start at the head of the OpHistoryList
        ListItem* pDeleteOp = OpHistoryList.GetHead();

#ifdef _DEBUG
        UINT32 TotalChk = 0;
#endif

        while (pDeleteOp != pOp)
        {
            DecSize(((Operation*)pDeleteOp)->GetSize());  // Reduce history size

#ifdef _DEBUG
            TotalChk += ((Operation*)pDeleteOp)->GetSize();
#endif
            ListItem* pNextDeleteOp = OpHistoryList.GetNext(pDeleteOp);

            // If the operation which is about to be deleted is the operation pointed to by the NowPtr
            // then it is the last undo operation, so set NowPtr to NULL.
            if (NowPtr == pDeleteOp)
                NowPtr = NULL;
            delete(OpHistoryList.RemoveItem(pDeleteOp));         // Delete the operation
            pDeleteOp = pNextDeleteOp;
        }

        // Defensive programming

#ifdef _DEBUG                       // Required because of TotalChk variable
        ENSURE(	OpSizeTotal == TotalChk,
                "OperationHistory::ReduceSize: OpSizeTotal != TotalChk");
#endif


        Reduced = TRUE;

        return (TRUE);
    }
    else
        return (FALSE); // Cannot reduce size of history to MaxHistorySize bytes or less
}
开发者ID:vata,项目名称:xarino,代码行数:89,代码来源:ophist.cpp


示例2: switch

VfsPath CColladaManager::GetLoadablePath(const VfsPath& pathnameNoExtension, FileType type)
{
	std::wstring extn;
	switch (type)
	{
	case PMD: extn = L".pmd"; break;
	case PSA: extn = L".psa"; break;
		// no other alternatives
	}

	/*

	Algorithm:
	* Calculate hash of skeletons.xml and converter version.
	* Use CCacheLoader to check for archived or loose cached .pmd/psa.
	* If cached version exists:
		* Return pathname of cached .pmd/psa.
	* Else, if source .dae for this model exists:
		* Convert it to cached .pmd/psa.
		* If converter succeeded:
			* Return pathname of cached .pmd/psa.
		* Else, fail (return empty path).
	* Else, if uncached .pmd/psa exists:
		* Return pathname of uncached .pmd/psa.
	* Else, fail (return empty path).

	Since we use CCacheLoader which automatically hashes file size and mtime,
	and handles archived files and loose cache, when preparing the cache key
	we add converter version number (so updates of the converter cause
	regeneration of the .pmd/psa) and the global skeletons.xml file size and
	mtime, as modelers frequently change the contents of skeletons.xml and get
	perplexed if the in-game models haven't updated as expected (we don't know
	which models were affected by the skeletons.xml change, if any, so we just
	regenerate all of them)

	TODO (maybe): The .dae -> .pmd/psa conversion may fail (e.g. if the .dae is
	invalid or unsupported), but it may take a long time to start the conversion
	then realise it's not going to work. That will delay the loading of the game
	every time, which is annoying, so maybe it should cache the error message
	until the .dae is updated and fixed. (Alternatively, avoid having that many
	broken .daes in the game.)

	*/

	// Now we're looking for cached files
	CCacheLoader cacheLoader(m_VFS, extn);
	MD5 hash;
	u32 version;
	m->PrepareCacheKey(hash, version);

	VfsPath cachePath;
	VfsPath sourcePath = pathnameNoExtension.ChangeExtension(L".dae");
	Status ret = cacheLoader.TryLoadingCached(sourcePath, hash, version, cachePath);

	if (ret == INFO::OK)
		// Found a valid cached version
		return cachePath;

	// No valid cached version, check if we have a source .dae
	if (ret != INFO::SKIPPED)
	{
		// No valid cached version was found, and no source .dae exists
		ENSURE(ret < 0);

		// Check if source (uncached) .pmd/psa exists
		sourcePath = pathnameNoExtension.ChangeExtension(extn);
		if (m_VFS->GetFileInfo(sourcePath, NULL) != INFO::OK)
		{
			// Broken reference, the caller will need to handle this
			return L"";
		}
		else
		{
			return sourcePath;
		}
	}

	// No valid cached version was found - but source .dae exists
	// We'll try converting it

	// We have a source .dae and invalid cached version, so regenerate cached version
	if (! m->Convert(sourcePath, cachePath, type))
	{
		// The COLLADA converter failed for some reason, this will need to be handled
		//	by the caller
		return L"";
	}

	return cachePath;
}
开发者ID:2asoft,项目名称:0ad,代码行数:90,代码来源:ColladaManager.cpp


示例3: AfxGetModuleThreadState

void CControlBar::OnTimer(UINT_PTR nIDEvent)
{
	if (GetKeyState(VK_LBUTTON) < 0)
		return;

	AFX_MODULE_THREAD_STATE* pModuleThreadState = AfxGetModuleThreadState();

	// get current mouse position for hit test
	CPoint point; GetCursorPos(&point);
	ScreenToClient(&point);
	INT_PTR nHit = OnToolHitTest(point, NULL);
	if (nHit >= 0)
	{
		CWnd *pParent=GetTopLevelParent();
		// determine if status bar help should go away
        if(!IsTopParentActive())
        {
            nHit=-1;
        }
        else
        {
			ENSURE(pParent);
		    if(!pParent->IsWindowEnabled())
            {
			    nHit = -1;
            }
        }

		// remove status help if capture is set
		HWND hWndTip = pModuleThreadState->m_pToolTip->GetSafeHwnd();
		CWnd* pCapture = GetCapture();
		if (pCapture != this && pCapture->GetSafeHwnd() != hWndTip &&
			pCapture->GetTopLevelParent() == pParent)
		{
			nHit = -1;
		}
	}
	else
	{
		pModuleThreadState->m_nLastStatus = static_cast<INT_PTR>(-1);
	}

	// make sure it isn't over some other app's window
	if (nHit >= 0)
	{
		ClientToScreen(&point);
		HWND hWnd = ::WindowFromPoint(point);
		if (hWnd == NULL || (hWnd != m_hWnd && !::IsChild(m_hWnd, hWnd) &&
			pModuleThreadState->m_pToolTip->GetSafeHwnd() != hWnd))
		{
			nHit = -1;
			pModuleThreadState->m_nLastStatus = static_cast<INT_PTR>(-1);
		}
	}

	// handle the result
	if (nHit < 0)
	{
		if (pModuleThreadState->m_nLastStatus == static_cast<INT_PTR>(-1))
			KillTimer(ID_TIMER_CHECK);
		SetStatusText(static_cast<INT_PTR>(-1));
	}

	// set status text after initial timeout
	if (nIDEvent == ID_TIMER_WAIT)
	{
		KillTimer(ID_TIMER_WAIT);
		if (nHit >= 0)
			SetStatusText(nHit);
	}
}
开发者ID:jbeaurain,项目名称:omaha_vs2010,代码行数:71,代码来源:barcore.cpp


示例4: while

BOOL OutputDIB::WriteBlock( UINT32 YPos, UINT32 Height, LPBYTE BlockStart, UINT32 InputBPP,
							INT32 ProgressOffset)
{
	FNPTR_SCANLINE ConvertFn = NULL;
	LPBYTE Buffer = NULL;
	size_t BufSize = 0L;
	size_t ChunkHeight = 1;
	DIBConvert *DoConvert = NULL;

	// Set up the size and other information for the dib block that we require. This is
	// dependent on the export depth or bpp required.
	if ( !SetUpBlock( &BufSize, &ChunkHeight, &DoConvert, &ConvertFn ) )
		return FALSE;			// Error details already set up

	if (BufSize)
	{
		Buffer = (LPBYTE)CCMalloc( BufSize );
		if (Buffer==NULL)
			return FALSE;
	}

	if ( DoConvert )
	{
		// use new classes to do it
		// 8bpp, 4bpp and 1bpp conversion
		INT32 h = Height;
		INT32 count = 0;
		LPBYTE Data = BlockStart;
		const size_t SourceWidth = DIBUtil::ScanlineSize( BitmapInfo.biWidth, InputBPP ) * ChunkHeight;
		const size_t DestWidth   = DIBUtil::ScanlineSize( BitmapInfo.biWidth, BitmapInfo.biBitCount );

		while (h)
		{
			ENSURE(h >= 0, "bad looping");

			const size_t ThisBit = min( h, (INT32)ChunkHeight );
			if (!DoConvert->Convert( Data, Buffer, ThisBit, IsFirstStrip ))
				break;								// stop if conversion failed

			IsFirstStrip = FALSE;

			OutputFile->write( Buffer, ThisBit * DestWidth );
			if (OutputFile->bad())
				break;								// stop if file errored
			Data += SourceWidth;
			h -= ThisBit;

			// now update the progress display, started with CurrentExportSize
			// CurrentExport size is now the point to go from in the export
			count++;
			ContinueSlowJob( (INT32)( ProgressOffset + count ));
			//ContinueSlowJob( (INT32)(100*count/(Height)) );
		}
	}
	// now the bytes (this is crying out for a virtual function or two)
	else if ( ConvertFn && Buffer )
	{
		// Write via conversion function
		// 24 bpp convert
		UINT32 h = Height;
		INT32 count = 0;
		LPBYTE Data = BlockStart;
		const size_t SourceWidth = DIBUtil::ScanlineSize( BitmapInfo.biWidth, InputBPP );

		while (h)
		{
			ConvertFn( BitmapInfo.biWidth, Data, Buffer );
			OutputFile->write( Buffer, BufSize );
			if (OutputFile->bad())
				break;								// stop if file errored
			Data += SourceWidth;
			h -= ChunkHeight;

			// now update the progress display, started with CurrentExportSize
			// ProgressOffset size is now the point to go from in the export
			count++;
			ContinueSlowJob( (INT32)( ProgressOffset + count ));
			//ContinueSlowJob( (INT32)((CurrentExportSize * count)/Height) );
		}
	}
	else
	{
		// Write it all out in one go
		//OutputFile->write( BlockStart, BitmapInfo.biSizeImage );
		// Write the actual bytes out to file. Used to do it in one go but we really
		// require some progress bar indication so we will do it in chunks.
		DWORD BitsSize = BitmapInfo.biSizeImage; 
		if (BitsSize > 0)
		{
			if (BitsSize < 1024)
			{
				// File very small or no progress bar required, so load in one go
				OutputFile->write( BlockStart, BitsSize);
			}
			else
			{
				// Load in chunks, for present split into 100 chunks
				DWORD ChunkSize = BitsSize/100;
				DWORD Position = 0;
				LPBYTE pBitInfo = BlockStart;
//.........这里部分代码省略.........
开发者ID:Amadiro,项目名称:xara-cairo,代码行数:101,代码来源:outptdib.cpp


示例5: GetClientRect

void CInformErrorDialog::GetDialogInfo()
{
	// Skip this if we've already done it.
	if (ValidInfo)
		return;

	// Find out how bug the dialog is by default.
	CRect DlgRect;
	GetClientRect(&DlgRect);
	DialogSize.cx = DlgRect.Width();
	DialogSize.cy = DlgRect.Height();

	// Find out the button spacing/sizes etc.
	CWnd *pCtrl1 = GetDlgItem(ButtonID[0]);
	CWnd *pCtrl2 = GetDlgItem(ButtonID[1]);
	ENSURE((pCtrl1 != NULL) && (pCtrl2 != NULL), 
		   "Can't find control in CInformErrorDialog::OnInitDialog()");

	// Safety check.
	if ((pCtrl1 == NULL) || (pCtrl2 == NULL))
		return;

	// Get width of buttons, and the spacing between the buttons and the edge of the dialog.
	WINDOWPLACEMENT Placement;
	Placement.length = sizeof(WINDOWPLACEMENT);
	pCtrl1->GetWindowPlacement(&Placement);

	DefTopOfButton = Placement.rcNormalPosition.top;
	DefButtonSize.cx = Placement.rcNormalPosition.right - Placement.rcNormalPosition.left;
	DefButtonSize.cy = Placement.rcNormalPosition.bottom - Placement.rcNormalPosition.top;
	EdgeSpacing = Placement.rcNormalPosition.left;

	// Get space between adjacent buttons.
	Placement.length = sizeof(WINDOWPLACEMENT);
	pCtrl2->GetWindowPlacement(&Placement);

	ButtonSpacing = Placement.rcNormalPosition.left - (EdgeSpacing + DefButtonSize.cx);

	// Find the position of the icon.
	CWnd *pIconCtrl = GetDlgItem(_R(IDC_ERRORBOX_ICON));
	ENSURE(pIconCtrl != NULL, "Can't find Icon control in CInformErrorDialog::GetDialogInfo()");

	// Safety check.
	if (pIconCtrl == NULL)
		return;

	Placement.length = sizeof(WINDOWPLACEMENT);
	pIconCtrl->GetWindowPlacement(&Placement);
	
	DefIconPos.x = Placement.rcNormalPosition.left;
	DefIconPos.y = Placement.rcNormalPosition.top;

	// Find the position of the message text area.
	CWnd *pMsgCtrl = GetDlgItem(_R(IDC_ERRORBOX_TEXT));
	ENSURE(pMsgCtrl != NULL, "Can't find Text control in CInformErrorDialog::GetDialogInfo()");

	// Safety check.
	if (pMsgCtrl == NULL)
		return;

	Placement.length = sizeof(WINDOWPLACEMENT);
	pMsgCtrl->GetWindowPlacement(&Placement);

	DefMsgSize.cx = Placement.rcNormalPosition.right - Placement.rcNormalPosition.left;
	DefMsgSize.cy = Placement.rcNormalPosition.bottom - Placement.rcNormalPosition.top;

	// The static variables now contain valid information.
	ValidInfo = TRUE;
}
开发者ID:UIKit0,项目名称:xara-xtreme,代码行数:69,代码来源:errorbox.cpp


示例6: GetDlgItem

BOOL CInformErrorDialog::SetupButtons(HDC hDC, INT32 NumButtons)
{
	// Set the default button in the dialog.
	CWnd *pDefCtrl = GetDlgItem(ButtonID[m_OK - 1]);
	ENSURE(pDefCtrl != NULL, "Can't get handle to default control in CInformErrorDialog");

	// If we can't get at this button then ooer...bit of a fatal error
	if (pDefCtrl == NULL)
	{
		ENSURE(FALSE, "Can't get default button in error box!");
		return FALSE;
	}

	// Set the keyboard focus to the default button, and give it a 'default' border.
	pDefCtrl->SetFocus();
	SendMessage(DM_SETDEFID, ButtonID[m_OK - 1], 0);

	// Read in the button texts, and find which is the widest string.
	INT32 ButtonWidth = DefButtonSize.cx;
	INT32 i;
	for (i = 0; i < NumButtons; i++)
	{
		// Try to load text for this button
		if (!ButtonText[i].Load(m_ButtonStr[i], m_OwnerModule))
		{
			ENSURE(FALSE, "Unable to load button text for error box!");
			return FALSE;
		}

		// Try to read the size of this button text.
		SIZE TextSize;
		if (!GetTextExtentPoint(hDC, (TCHAR *) ButtonText[i], ButtonText[i].Length(),
						   	    &TextSize))
		{
			// Error reading text size
			ENSURE(FALSE, "Unable to read button text size for error box!");
			return FALSE;
		}

		if (TextSize.cx > ButtonWidth)
			ButtonWidth = TextSize.cx + 8;
	}

	// Allow for space on either side in the button
	ButtonWidth += 8;

	// Find out how big the buttons can be at the most.
	INT32 MaxWidth = DialogSize.cx - 
				   (2 * EdgeSpacing) - 
				   ((NumButtons - 1) * ButtonSpacing);

	// NumButtons cannot be 0 if we get to here...but just in case :-)
	if (NumButtons == 0)
	{
		ENSURE(FALSE, "NumButtons is zero in error box!");
		return FALSE;
	}

	// Safe to do a divide now!
	MaxWidth /= NumButtons;

	// The width of the dialog may change.
	INT32 NewWidth = DialogSize.cx;

	// Find out if we need to make the dialog bigger to accomodate the buttons.
	if (ButtonWidth > MaxWidth)
	{
		// Yes - find out if the buttons actually fit on screen - if not, make them
		// smaller and truncate the button text (this shouldn't happen too often!)

		// Get required dialog width
		NewWidth = (EdgeSpacing * 2) +
				   (NumButtons * ButtonWidth) +
				   ((NumButtons - 1) * ButtonSpacing);

		// Does this actually fit on screen?
		INT32 ScreenWidth = GetSystemMetrics(SM_CXSCREEN);

		if (ScreenWidth < NewWidth)
		{
			// They don't fit - downsize the buttons to fit.
			ButtonWidth = ScreenWidth - 
					      (2 * EdgeSpacing) - 
					      ((NumButtons - 1) * ButtonSpacing);
			ButtonWidth /= NumButtons;

			NewWidth = ScreenWidth;
		}

		// Ok - buttons are now correct size - resize the dialog.
		SIZE BorderSize;
		BorderSize.cx = 2 * ::GetSystemMetrics(SM_CXDLGFRAME);
		BorderSize.cy = ::GetSystemMetrics(SM_CYDLGFRAME) + 
						::GetSystemMetrics(SM_CYCAPTION);

		if (!SetWindowPos(NULL, 0, 0, 
					 	  NewWidth + BorderSize.cx, DialogSize.cy + BorderSize.cy,
					      SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE | SWP_NOREDRAW))
		{
			ENSURE(FALSE, "Unable to resize the error box!");
//.........这里部分代码省略.........
开发者ID:UIKit0,项目名称:xara-xtreme,代码行数:101,代码来源:errorbox.cpp


示例7: ENSURE

u32 CNetServerTurnManager::GetSavedTurnLength(u32 turn)
{
	ENSURE(turn <= m_ReadyTurn);
	return m_SavedTurnLengths.at(turn);
}
开发者ID:Epidilius,项目名称:0ad,代码行数:5,代码来源:NetTurnManager.cpp


示例8: ENSURE

void OpLayerChange::Do(OpDescriptor*)
{   
	ENSURE(FALSE,"This shouldn't have been called");
/*
	Spread* pSpread = Document::GetCurrent()->GetLayerMgr().GetCurrentSpread(); 
	// Find the first layer on the spread. All siblings of the first layer node should
	// be layer nodes
	Node* CurrentTreeLayer = pSpread->FindFirstLayer(); // skips over page nodes 

	ENSURE(CurrentTreeLayer->GetRuntimeClass() == CC_RUNTIME_CLASS(Layer), 
			"A next sibling of a layer node is not a layer"); 


	// Get the first layer details record 
	LyrDetails* CurLyrDet = (LyrDetails*)
		(Document::GetCurrent()->GetLayerMgr()).LyrDetList.GetHead(); 
	
	BOOL InvalidateLayersRgn; // Flag used to decide if we should invalidate
							  // a layers region
	BOOL RemoveSelections; 	  // Flag used to indicate if we should remove all
							  // selections from the layer 

    // loop while there are more changes to be made 
	while (CurLyrDet != NULL) 
	{
		InvalidateLayersRgn = FALSE;
		RemoveSelections = FALSE; 

		// We can ignore all new layers which have been deleted 
		if (!((CurLyrDet->New) && (CurLyrDet->Deleted)))
		{
			// Is the layer a new layer ? 
			if (CurLyrDet->New)
			{
				// Attempt to create a new layer node 
				Layer* NewLyr; 
				ALLOC_WITH_FAIL(NewLyr, (new Layer()), this); 	      
				if (NewLyr == NULL)
				{
					goto EndOperation; // We were unable to create a new layer so 
									   // abort the operation 
				}
				// Set the new layer's status  
				NewLyr->SetLayerStatus(CurLyrDet->Status); 
		   
			    // Create a hide node action to hide the new node when we undo/redo
			    HideNodeAction* UndoHideNodeAction; 
			    // ** Change !!!    
				if (!HideNodeAction::Init(this,                    
							 			  &UndoActions,
										  NewLyr, 
										  TRUE, 
							  			  ( Action**)(&UndoHideNodeAction))      
							  			  != AC_FAIL)
				{
					delete NewLyr;     // We won't be needing this 
					goto EndOperation; 		
				}
				// All is well 
				if (CurrentTreeLayer != NULL)
				{
					// Add the new layer to the tree as a previous sibling of 
					// the CurrentTreeLayer 
					NewLyr->AttachNode(CurrentTreeLayer, PREV); 
				}
				else 
				{
					// Add the new layer as a last child of the spread 
					NewLyr->AttachNode(Document::GetCurrent()->
						GetLayerMgr().GetCurrentSpread(), LASTCHILD); 
				}
			}

			// Has the layer been deleted 
			else if (CurLyrDet->Deleted)
			{
				if ( CurLyrDet->Layer == CurrentTreeLayer )
				{
					// We are about to hide the CurrentTreeLayer so we need to find the 
					// next layer before we do this 
					CurrentTreeLayer = ((Layer*)CurrentTreeLayer)->FindNextLayer(); 
				}
				
				// If a layer has been deleted then we ignore all attribute changes 
				// which may have been made prior to the layer being deleted. 
				// Change 
				if (!DoHideNode(CurLyrDet->Layer, 
								TRUE				// Include subtree size 
								)) // Hide the node 
					goto EndOperation; 
				InvalidateLayersRgn = TRUE; // We will need to invalidate the hidden 
											// layers bounding region. 
				RemoveSelections = TRUE;    
			}
			else 
			{
				// Have the attributes of the layer changed 
				if ( !(CurLyrDet->Status == CurLyrDet->Layer->GetLayerStatus()) )	
				{
		
//.........这里部分代码省略.........
开发者ID:Amadiro,项目名称:xara-cairo,代码行数:101,代码来源:layermgr.cpp


示例9: bar

void bar(void) {
    ENSURE(1 == 2);
}
开发者ID:hudsonsferreira,项目名称:thc,代码行数:3,代码来源:test_thc.c


示例10: foo

void foo(void) {
    ENSURE(1 == 1);
}
开发者ID:hudsonsferreira,项目名称:thc,代码行数:3,代码来源:test_thc.c


示例11: test_functional_columns

    void test_functional_columns(smt_params fparams, params_ref& params) {
        ast_manager m;
        register_engine re;
        context ctx(m, re, fparams);
        rel_context_base& rctx = *ctx.get_rel_context();
        ctx.updt_params(params);
        relation_manager & rmgr(rctx.get_rmanager());

        sparse_table_plugin & plugin = 
            static_cast<sparse_table_plugin &>(*rctx.get_rmanager().get_table_plugin(symbol("sparse")));
        ENSURE(&plugin);
        table_signature sig2;
        sig2.push_back(2);
        sig2.push_back(2);
        sig2.set_functional_columns(1);
        ENSURE(plugin.can_handle_signature(sig2));
        
        table_fact f00;
        f00.push_back(0);
        f00.push_back(0);
        table_fact f01;
        f01.push_back(0);
        f01.push_back(1);
        table_fact f11;
        f11.push_back(1);
        f11.push_back(1);

        {
            table_aptr t0 = plugin.mk_empty(sig2);
            ENSURE(t0->empty());
            t0->add_fact(f00);
            ENSURE(!t0->empty());
            ENSURE(t0->get_size_estimate_rows()==1);
            t0->add_fact(f01);
            ENSURE(t0->get_size_estimate_rows()==1);
            t0->add_fact(f11);
            ENSURE(t0->get_size_estimate_rows()==2);

            unsigned rem_cols0[]={0};
            scoped_ptr<table_transformer_fn> project0 = rmgr.mk_project_fn(*t0, 1, rem_cols0);
            table_aptr t1 = (*project0)(*t0);
            ENSURE(t1->get_size_estimate_rows()==2);
            ENSURE(t1->get_signature().functional_columns()==0); //project on non-functional column cancels functional

            unsigned rem_cols1[]={1};
            scoped_ptr<table_transformer_fn> project1 = rmgr.mk_project_fn(*t0, 1, rem_cols1);
            table_aptr t2 = (*project1)(*t0);
            ENSURE(t2->get_size_estimate_rows()==2);

            idx_set acc;
            collector_of_reduced * reducer = alloc(collector_of_reduced, acc);
            scoped_ptr<table_transformer_fn> rproject = rmgr.mk_project_with_reduce_fn(*t0, 1, rem_cols0, reducer);
            table_aptr rt = (*rproject)(*t0);
            ENSURE(acc.num_elems()==1);
            ENSURE(rt->get_size_estimate_rows()==1);
        }
        {
            table_aptr t0 = plugin.mk_empty(sig2);
            t0->add_fact(f01);

            unsigned join_cols[]={1};
            scoped_ptr<table_join_fn> join0 = rmgr.mk_join_fn(*t0, *t0, 1, join_cols, join_cols);
            table_aptr t1 = (*join0)(*t0, *t0);
            ENSURE(t1->get_signature().size()==4);
            ENSURE(t1->get_signature().functional_columns()==2);

            table_fact f0011;
            f0011.push_back(0);
            f0011.push_back(0);
            f0011.push_back(1);
            f0011.push_back(1);
            ENSURE(t1->contains_fact(f0011));
            table_fact f0111 = f0011;
            f0111[1] = 1;
            ENSURE(!t1->contains_fact(f0111));
        }

        {
            table_aptr t0 = plugin.mk_empty(sig2);
            t0->display(std::cout<<"0:");
            ENSURE(t0->get_signature().functional_columns()==1);
            
            table_fact aux_fact;

            aux_fact = f01;
            TRUSTME( t0->suggest_fact(aux_fact) );
            t0->display(std::cout<<"1:");
            ENSURE(t0->contains_fact(f01));
            ENSURE(aux_fact[1]==1);

            aux_fact = f00;
            TRUSTME( !t0->suggest_fact(aux_fact) );
            t0->display(std::cout<<"2:");
            ENSURE(t0->contains_fact(f01));
            ENSURE(!t0->contains_fact(f00));
            ENSURE(aux_fact[1]==1);

            t0->ensure_fact(f00);
            t0->display(std::cout<<"3:");
            ENSURE(t0->contains_fact(f00));
//.........这里部分代码省略.........
开发者ID:NikolajBjorner,项目名称:z3,代码行数:101,代码来源:dl_product_relation.cpp


示例12: ENSURE

 const NPb::FieldDescriptor* TProtoSerial::GetFieldDescr(int protoField) {
     const auto* fd = Descr->FindFieldByNumber(protoField);
     ENSURE(fd, "Can't find field number " << protoField << " in message " << Message.GetTypeName());
     return fd;
 }
开发者ID:alexeyche,项目名称:ground,代码行数:5,代码来源:proto_serial.cpp


示例13: _R

BOOL CInformErrorDialog::OnInitDialog()
{
	CDialog::OnInitDialog();
	
	String_64 BoxTitle;
	BoxTitle = _R(IDS_ERROR_BOX_SERIOUS_ERROR);	// "Serious error"

	String_256 VerySeriousError;
	VerySeriousError = _R(IDS_ERROR_BOX_VERY_SERIOUS_ERROR); // "A very serious error has occured - please consult your technical support."

	// Andy Hills, 22-11-00
	// Store the help context.
	// We need to do this here, because the global help context variable
	// nNextMessageHelpContext may change before the user clicks the 'Help'
	// button. This fixes bug 6359.
	m_nHelpContext = Error::GetErrorNumber();
	if (! m_nHelpContext) m_nHelpContext = GetNextMsgHelpContext();

	// Find out how many buttons there are.
	for (INT32 NumButtons = ERRORDLG_MAXBUTTONS; NumButtons > 0; NumButtons--)
	{
		if (m_ButtonStr[NumButtons - 1] != 0) break;
	}

	// Adjust the OK and Cancel fields if necessary
	if (m_OK > (UINT32) NumButtons)
	{
		if (IsUserName("Tim"))
		{
			TRACE( _T("OK out of range, OK=%u, NumButtons=%d\n"), m_OK, NumButtons);
		}
		// Default to first button
		m_OK = 1;
	}

	if (m_Cancel > (UINT32) NumButtons)
	{
		if (IsUserName("Tim"))
		{
			TRACE( _T("Cancel out of range, Cancel=%u, NumButtons=%d\n"), m_Cancel, NumButtons);
		}

		// Default to be the same as OK (this means a box with a single OK box will
		// respond to Enter and Esc without the user having to specify a Cancel ID).
		m_Cancel = m_OK;
	}

	if (m_Help > (UINT32) NumButtons)
	{
		TRACEUSER( "JustinF", _T("Help button (%d) out of range (%d)\n"),
									(INT32) m_Help, (INT32) NumButtons);
		
		// The only really safe thing we can do is drop the help button.
		m_Help = 0;
	}
		
	// Make sure we have correct dialog information
	GetDialogInfo();
	if (!ValidInfo)
	{
		// Serious error - fall back to to MessageBox().
		goto SevereError;
	}

	// Get icon position
	IconPos = DefIconPos;


	// Get a DC for this dialog, so we can find out the size of text strings.
	// We'll also need to select in our font or else it'll base the width upon the
	// System font rather than the font we're using (MS Sans Serif at last check)
	CDC *pDC;
	CFont *OldFont;

	pDC = GetDC();
	ENSURE(pDC != NULL, "Can't get DC for error box dialog");

	// Check the DC
	if (pDC == NULL)
		goto SevereError;

	OldFont = pDC->SelectObject(GetFont());

	// Set buttons text and move/resize buttons according to the number of them,
	// and their contents.
	BOOL Success;
	Success = SetupButtons(pDC->m_hDC, NumButtons);

	// Size the error message control, and put the message in it.
	Success = Success && SetupMessage(pDC->m_hDC);

	if (OldFont != NULL)
		pDC->SelectObject(OldFont);

	// We've finished with this DC now.
	ReleaseDC(pDC);


	// Check for failure in button/message setup.
	if (!Success)
//.........这里部分代码省略.........
开发者ID:UIKit0,项目名称:xara-xtreme,代码行数:101,代码来源:errorbox.cpp


示例14: switch

BOOL OutputDIB::SetUpBlock( size_t *pBufSize, size_t *pChunkHeight, DIBConvert **pDoConvert,
							FNPTR_SCANLINE *pConvertFn )
{
	BOOL Problems = FALSE;

	switch (SourceBitmapDepth)
	{
		case 32:
		{
			switch (BitmapInfo.biBitCount)
			{
				case 32:
					{
						// real 32-bit BMPs here
						// our 'filter' zeros the transparency bits
						*pConvertFn = DIBUtil::Convert32to32;
						*pBufSize = DIBUtil::ScanlineSize( BitmapInfo.biWidth, 32 );
					}
					break;
				case 24:
					{
						// convert 32-bit BMPs to 24-bit ones so things can read them
						*pConvertFn = DIBUtil::Convert32to24;	  						// 32->24
						*pBufSize = DIBUtil::ScanlineSize( BitmapInfo.biWidth, 24 );	// size of 24-bit scanline
					}
					break;
				case 8:
					{
						// 32->8 we do in bigger chunks because of dithering
						*pDoConvert = DIBConvert::Create( SourceBitmapDepth, 8, BitmapInfo.biWidth, OutputPalette, Dither );
						if (*pDoConvert==NULL)
						{
							ENSURE(FALSE, "DIBConvert::Create returned NULL");
							return FALSE;
						}
						*pChunkHeight = 16;
						*pBufSize = DIBUtil::ScanlineSize( BitmapInfo.biWidth, 8 ) * (*pChunkHeight);
					}
					break;
				case 4:
					{
						// 32->4 we do in bigger chunks because of dithering
						*pDoConvert = DIBConvert::Create( SourceBitmapDepth, 4, BitmapInfo.biWidth, OutputPalette, Dither );
						if (*pDoConvert==NULL)
						{
							ENSURE(FALSE, "DIBConvert::Create returned NULL");
							return FALSE;
						}
						*pChunkHeight = 16;
						*pBufSize = DIBUtil::ScanlineSize( BitmapInfo.biWidth, 4 ) * (*pChunkHeight);
					}
					break;
				case 1:
					{
						// 32->1 we do in bigger chunks because of dithering
						*pDoConvert = DIBConvert::Create( SourceBitmapDepth, 1, BitmapInfo.biWidth, OutputPalette, Dither );
						if (*pDoConvert==NULL)
						{
							ENSURE(FALSE, "DIBConvert::Create returned NULL");
							return FALSE;
						}
						*pChunkHeight = 16;
						*pBufSize = DIBUtil::ScanlineSize( BitmapInfo.biWidth, 1 ) * (*pChunkHeight);
					}
					break;
				default:
					Problems = TRUE;
					break;
			}
			break;
		}
		case 8:
			if (BitmapInfo.biBitCount==8)
			{
				// real 8-bit BMPs here
				// we basically just do a memory copy from source to dest
				*pConvertFn = DIBUtil::Convert8to8;
				*pBufSize = DIBUtil::ScanlineSize( BitmapInfo.biWidth, 8 );
				break;

			}
			Problems = TRUE;
			break;

		default:
			Problems = TRUE;
			break;
	}

	if(Problems)
	{
		Error::SetError( _R(IDE_FORMATNOTSUPPORTED) );
		return FALSE;
	}

	return TRUE;
}
开发者ID:Amadiro,项目名称:xara-cairo,代码行数:97,代码来源:outptdib.cpp


示例15: Init

	virtual void Init(const CParamNode& paramNode)
	{
		// The minimum obstruction size is the navcell size * sqrt(2)
		// This is enforced in the schema as a minimum of 1.5
		fixed minObstruction = (Pathfinding::NAVCELL_SIZE.Square() * 2).Sqrt();
		m_TemplateFlags = 0;
		if (paramNode.GetChild("BlockMovement").ToBool())
			m_TemplateFlags |= ICmpObstructionManager::FLAG_BLOCK_MOVEMENT;
		if (paramNode.GetChild("BlockPathfinding").ToBool())
			m_TemplateFlags |= ICmpObstructionManager::FLAG_BLOCK_PATHFINDING;
		if (paramNode.GetChild("BlockFoundation").ToBool())
			m_TemplateFlags |= ICmpObstructionManager::FLAG_BLOCK_FOUNDATION;
		if (paramNode.GetChild("BlockConstruction").ToBool())
			m_TemplateFlags |= ICmpObstructionManager::FLAG_BLOCK_CONSTRUCTION;

		m_Flags = m_TemplateFlags;
		if (paramNode.GetChild("DisableBlockMovement").ToBool())
			m_Flags &= (flags_t)(~ICmpObstructionManager::FLAG_BLOCK_MOVEMENT);
		if (paramNode.GetChild("DisableBlockPathfinding").ToBool())
			m_Flags &= (flags_t)(~ICmpObstructionManager::FLAG_BLOCK_PATHFINDING);

		if (paramNode.GetChild("Unit").IsOk())
		{
			m_Type = UNIT;

			CmpPtr<ICmpUnitMotion> cmpUnitMotion(GetEntityHandle());
			if (cmpUnitMotion)
				m_Clearance = cmpUnitMotion->GetUnitClearance();
		}
		else if (paramNode.GetChild("Static").IsOk())
		{
			m_Type = STATIC;
			m_Size0 = paramNode.GetChild("Static").GetChild("@width").ToFixed();
			m_Size1 = paramNode.GetChild("Static").GetChild("@depth").ToFixed();
			ENSURE(m_Size0 > minObstruction);
			ENSURE(m_Size1 > minObstruction);
		}
		else
		{
			m_Type = CLUSTER;
			CFixedVector2D max = CFixedVector2D(fixed::FromInt(0), fixed::FromInt(0));
			CFixedVector2D min = CFixedVector2D(fixed::FromInt(0), fixed::FromInt(0));
			const CParamNode::ChildrenMap& clusterMap = paramNode.GetChild("Obstructions").GetChildren();
			for(CParamNode::ChildrenMap::const_iterator it = clusterMap.begin(); it != clusterMap.end(); ++it)
			{
				Shape b;
				b.size0 = it->second.GetChild("@width").ToFixed();
				b.size1 = it->second.GetChild("@depth").ToFixed();
				ENSURE(b.size0 > minObstruction);
				ENSURE(b.size1 > minObstruction);
				b.dx = it->second.GetChild("@x").ToFixed();
				b.dz = it->second.GetChild("@z").ToFixed();
				b.da = entity_angle_t::FromInt(0);
				b.flags = m_Flags;
				m_Shapes.push_back(b);
				max.X = MAX(max.X, b.dx + b.size0/2);
				max.Y = MAX(max.Y, b.dz + b.size1/2);
				min.X = MIN(min.X, b.dx - b.size0/2);
				min.Y = MIN(min.Y, b.dz - b.size1/2);
			}
			m_Size0 = fixed::FromInt(2).Multiply(MAX(max.X, -min.X));
			m_Size1 = fixed::FromInt(2).Multiply(MAX(max.Y, -min.Y));
		}

		m_Active = paramNode.GetChild("Active").ToBool();
		m_ControlPersist = paramNode.GetChild("ControlPersist").IsOk();

		m_Tag = tag_t();
		if (m_Type == CLUSTER)
			m_ClusterTags.clear();
		m_Moving = false;
		m_ControlGroup = GetEntityId();
		m_ControlGroup2 = INVALID_ENTITY;
	}
开发者ID:Rektosauros,项目名称:0ad,代码行数:74,代码来源:CCmpObstruction.cpp


示例16: ENSURE

void GUITooltip::ShowTooltip(IGUIObject* obj, CPos pos, const CStr& style, CGUI* gui)
{
	ENSURE(obj);

	// Ignore attempts to use tooltip ""
	if (style.empty())
		return;

	// Get the object referenced by 'tooltip_style'
	IGUIObject* tooltipobj = gui->FindObjectByName("__tooltip_"+style);
	if (! tooltipobj)
	{
		LOGERROR(L"Cannot find tooltip named '%hs'", style.c_str());
		return;
	}

	IGUIObject* usedobj = tooltipobj; // object actually used to display the tooltip in

	CStr usedObjectName;
	if (GUI<CStr>::GetSetting(tooltipobj, "use_object", usedObjectName) == PSRETURN_OK
		&& !usedObjectName.empty())
	{
		usedobj = gui->FindObjectByName(usedObjectName);
		if (! usedobj)
		{
			LOGERROR(L"Cannot find object named '%hs' used by tooltip '%hs'", usedObjectName.c_str(), style.c_str());
			return;
		}

		// Unhide the object. (If it had use_object and hide_object="true",
		// still unhide it, because the used object might be hidden by default)
		GUI<bool>::SetSetting(usedobj, "hidden", false);
	}
	else
	{
		// Unhide the object
		GUI<bool>::SetSetting(usedobj, "hidden", false);

		// Store mouse position inside the CTooltip
		if (GUI<CPos>::SetSetting(usedobj, "_mousepos", pos) != PSRETURN_OK)
			debug_warn(L"Failed to set tooltip mouse position");
	}

	// Retrieve object's 'tooltip' setting
	CStrW text;
	if (m_IsIconTooltip)
	{
		// Use icon tooltip property
		if (GUI<CStrW>::GetSetting(obj, "_icon_tooltip", text) != PSRETURN_OK)
			debug_warn(L"Failed to retrieve icon tooltip text"); // shouldn't fail
	}
	else
	{
		// Use normal tooltip property
		if (GUI<CStrW>::GetSetting(obj, "tooltip", text) != PSRETURN_OK)
			debug_warn(L"Failed to retrieve tooltip text"); // shouldn't fail
	}

	// Do some minimal processing ("\n" -> newline, etc)
	text = text.UnescapeBackslashes();

	// Set tooltip's caption
	if (usedobj->SetSetting("caption", text) != PSRETURN_OK)
		debug_warn(L"Failed to set tooltip caption"); // shouldn't fail

	// Make the tooltip object regenerate its text
	SGUIMessage msg(GUIM_SETTINGS_UPDATED, "caption");
	usedobj->HandleMessage(msg);
}
开发者ID:Marlinc,项目名称:0ad,代码行数:69,代码来源:GUITooltip.cpp


示例17: tst1

static void tst1() {
  map<char const *, int, str_hash_proc, str_eq_proc> str2int;
  str2int.insert("foo", 35);
  ENSURE(str2int.contains("foo"));
  ENSURE(str2int.find_iterator("foo") != str2int.end());
  ENSURE((*(str2int.find_iterator("foo"))).m_value == 35);
  ENSURE(str2int.size() == 1);
  str2int.insert("boo", 32);
  ENSURE(str2int.contains("foo"));
  ENSURE(str2int.find_iterator("foo") != str2int.end());
  ENSURE((*(str2int.find_iterator("foo"))).m_value == 35);
  ENSURE(str2int.contains("boo"));
  ENSURE(str2int.find_iterator("boo") != str2int.end());
  ENSURE((*(str2int.find_iterator("boo"))).m_value == 32);
  ENSURE(str2int.size() == 2);
  str2int.remove("boo");
  ENSURE(str2int.size() == 1);
  ENSURE(!str2int.contains("boo"));
  ENSURE(str2int.contains("foo"));
}
开发者ID:NikolajBjorner,项目名称:z3,代码行数:20,代码来源:map.cpp


示例18: ENSURE

JS::Value ScriptInterface::GetCachedValue(CACHED_VAL valueIdentifier)
{
	std::map<ScriptInterface::CACHED_VAL, JS::PersistentRootedValue>::iterator it = m->m_ScriptValCache.find(valueIdentifier);
	ENSURE(it != m->m_ScriptValCache.end());
	return it->second.get();
}
开发者ID:2asoft,项目名称:0ad,代码行数:6,代码来源:ScriptInterface.cpp


示例19: _start

void
_start (void)
{
  // debugging
  /*
  volatile char xxx = 0;
  while (xxx == 0)
    asm volatile ("pause" ::: "memory");
  //*/

  // clear BSS:
  memset (&_section_bss_start[0], 0,
          &_section_bss_end[0] - &_section_bss_start[0]);

  videoram_cls (COLOR_NORMAL);

  // some welcoming information:
  videoram_printf ("\n  Welcome to \e%c chaOS! \n\n", COLOR_ERROR);
  put_cpu_info ();
  put_memory_map ();

  if (!nx_bit_present ())
    {
      videoram_puts (" Your CPU does not support the NX bit! \n", COLOR_ERROR);
      khalt ();
    }

  init_subsystem ("interrupt handling", &interrupts_init, NULL);

  videoram_puts ("Running a syscall test: ", COLOR_NORMAL);
  if (syscall_test ())
    videoram_put_right (" ok ", COLOR_INFO);
  else
    {
      videoram_put_right (" FAIL ", COLOR_ERROR);
      khalt ();
    }

  init_subsystem ("PIC", &pic_init, NULL);
  pit_set_handler (pic_handler_fun);
  pic_mask (~PIC_MASK_PIT);

  videoram_puts ("Setting CPU standards", COLOR_NORMAL);
  cr0_set_reset (CR0_WP|CR0_NE, CR0_MP|CR0_EM|CR0_NE|CR0_AM|CR0_CD|CR0_NW);
  msr_set_reset (MSR_EFER, EFER_NXE, 0);
  videoram_put_right (" ok ", COLOR_INFO);

  init_subsystem ("paging", &paging_in 

鲜花

握手

雷人

路过

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

请发表评论

全部评论

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