当前位置: 首页>>代码示例>>C++>>正文


C++ NN_ASSERT函数代码示例

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


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

示例1: NN_ASSERT

//============================================================================
//		NDBHandlePool::Open : Open the database.
//----------------------------------------------------------------------------
NStatus NDBHandlePool::Open(const NFile &theFile, NDBFlags theFlags, const NString &theVFS)
{	NDBHandlePtr		dbHandle;
	NStatus				theErr;



	// Validate our parameters and state
	NN_ASSERT(theFile.IsValid());
	NN_ASSERT(!IsOpen());
	


	// Update our state
	mFile  = theFile;
	mFlags = theFlags;
	mVFS   = theVFS;



	// Create the initial connection
	//
	// The initial connection allows us to test that we can actually open the
	// database, and may be all that we need if we're only to connect once.
	theErr = CreateConnection(dbHandle);
	NN_ASSERT_NOERR(theErr);

	mIsOpen = (dbHandle != NULL);

	if (mIsOpen)
		mPool.PushBack(dbHandle);

	return(theErr);
}
开发者ID:refnum,项目名称:nano,代码行数:36,代码来源:NDBHandlePool.cpp

示例2: NN_ASSERT

//============================================================================
//		NUnicodeParser::GetChar : Get a character.
//----------------------------------------------------------------------------
utf32_t NUnicodeParser::GetChar(NIndex theIndex, bool toLower) const
{   NStringEncoder		theEncoder;
    NRange				theRange;
    const uint8_t		*srcPtr;
    utf32_t				theChar;



    // Validate our parameters
    NN_ASSERT(theIndex >= 0 && theIndex < GetSize());



    // Get the state we need
    theRange = GetRange(theIndex);
    srcPtr   = mData.GetData(theRange.GetLocation());



    // Convert the character
    theChar = theEncoder.ConvertToUTF32(mEncoding, theRange.GetSize(), srcPtr);
    NN_ASSERT(theChar != 0);

    if (toLower)
        theChar = GetLower(theChar);

    return(theChar);
}
开发者ID:refnum,项目名称:nano,代码行数:31,代码来源:NUnicodeParser.cpp

示例3: switch

//============================================================================
//		TTestClient::ReceivedMessage : The client has received a message.
//----------------------------------------------------------------------------
void TTestClient::ReceivedMessage(const NNetworkMessage &theMsg)
{	NString		theValue;



	// Update our state
	mState += kStateClientReceivedMessage;



	// Handle the message
	switch (theMsg.GetType()) {
		case kTestClientBroadcastMsg:
			// Validate the message
			theValue = theMsg.GetValueString(kTestTokenKey);
			NN_ASSERT(theValue == kTokenClientBroadcast);
			break;


		case kTestServerClientMsg:
			// Validate the message
			theValue = theMsg.GetValueString(kTestTokenKey);
			NN_ASSERT(theValue == kTokenServerClient);
			
			// Update our state
			mIsDone = true;
			break;


		default:
			NMessageClient::ReceivedMessage(theMsg);
			break;
		}
}
开发者ID:x414e54,项目名称:nano,代码行数:37,代码来源:TMessageServer.cpp

示例4: NSocket

//============================================================================
//		TSocketClient::ExecuteCustom : Execute a custom client test.
//----------------------------------------------------------------------------
void TSocketClient::ExecuteCustom(bool *isDone, UInt16 thePort)
{	UInt32		n, theValue;
	NSocket		*theSocket;
	NStatus		theErr;



	// Open the socket
	theSocket = new NSocket(this);
	theSocket->Open("127.0.0.1", thePort);
	
	while (theSocket->GetStatus() != kNSocketOpened)
		NThread::Sleep();



	// Get/set optins
	theErr = theSocket->SetOption(kNSocketNoDelay, (SInt32) true);
	NN_ASSERT_NOERR(theErr);
	
	theValue = theSocket->GetOption(kNSocketNoDelay);
	NN_ASSERT(theValue == (SInt32) true);



	// Write some data
	for (n = 0; n < kTestNumItems; n++)
		{
		theErr = theSocket->WriteUInt32(n);
		NN_ASSERT_NOERR(theErr);
		}



	// Read the response
	for (n = 0; n < kTestNumItems; n++)
		{
		theErr = theSocket->ReadUInt32(theValue);
		NN_ASSERT_NOERR(theErr);
		NN_ASSERT(theValue == (n * n));
		}



	// Clean up
	theSocket->Close();

	while (theSocket->GetStatus() != kNSocketClosed)
		NThread::Sleep();
	
	delete theSocket;



	// Finish off
	*isDone = true;
}
开发者ID:x414e54,项目名称:nano,代码行数:60,代码来源:TSocket.cpp

示例5: NN_ASSERT

//============================================================================
//		NTask::SetCommand : Set the command.
//----------------------------------------------------------------------------
void NTask::SetCommand(const NString &theCmd)
{


	// Validate our parameters and state
	NN_ASSERT(!theCmd.IsEmpty());
	NN_ASSERT(!IsRunning());



	// Set the command
	mCommand = theCmd;
}
开发者ID:x414e54,项目名称:nano,代码行数:16,代码来源:NTask.cpp

示例6: NN_ASSERT

//============================================================================
//		NSocketRequest::ProcessedData : Mark data as having been processed.
//----------------------------------------------------------------------------
void NSocketRequest::ProcessedData(NIndex theSize)
{


	// Validate our state
	NN_ASSERT(!IsFinished());
	
	
	
	// Process the data
	mProcessed += theSize;
	NN_ASSERT(mProcessed <= mData.GetSize());
}
开发者ID:x414e54,项目名称:nano,代码行数:16,代码来源:NSocketRequest.cpp

示例7: acquireLock

//============================================================================
//		NThreadPool::Pause : Pause the pool.
//----------------------------------------------------------------------------
void NThreadPool::Pause(void)
{	StLock	acquireLock(mLock);



	// Validate our state
	NN_ASSERT(!mIsPaused);
	NN_ASSERT(mTasksPending.empty());



	// Update our state
	mIsPaused = true;
}
开发者ID:refnum,项目名称:nano,代码行数:17,代码来源:NThreadPool.cpp

示例8: NN_ASSERT

//============================================================================
//		NMessageServer::SetMaxClients : Set the max clients.
//----------------------------------------------------------------------------
void NMessageServer::SetMaxClients(NIndex maxClients)
{


	// Validate our parameters and state
	NN_ASSERT(maxClients >= 1 && maxClients <= kNEntityClientsMax);

	NN_ASSERT(GetStatus() == kNServerStopped);



	// Set the max clients
	mMaxClients = maxClients;
}
开发者ID:x414e54,项目名称:nano,代码行数:17,代码来源:NMessageServer.cpp

示例9: NN_ASSERT

//============================================================================
//		TTestClient::~TTestClient : Destructor.
//----------------------------------------------------------------------------
TTestClient::~TTestClient(void)
{


	// Validate our state
	NN_ASSERT(GetStatus() == kNClientDisconnected);
}
开发者ID:x414e54,项目名称:nano,代码行数:10,代码来源:TMessageServer.cpp

示例10: acquireLock

//============================================================================
//		NTimer::ResetTimer : Reset a timer.
//----------------------------------------------------------------------------
void NTimer::ResetTimer(NTime fireAfter, NTimerID theTimer)
{	StLock					acquireLock(mLock);
	NTimerMapIterator		theIter;



	// Adjust all timers
	if (theTimer == kNTimerAll)
		{
		for (theIter = mTimers.begin(); theIter != mTimers.end(); theIter++)
			NTargetTime::TimerReset(theIter->first, fireAfter);
		}
	
	
	
	// Adjust a single timer
	else
		{
		theIter = mTimers.find(theTimer);
		NN_ASSERT(theIter != mTimers.end());
		
		if (theIter != mTimers.end())
			NTargetTime::TimerReset(theIter->first, fireAfter);
		}
}
开发者ID:refnum,项目名称:nano,代码行数:28,代码来源:NTimer.cpp

示例11: NN_ASSERT

//=============================================================================
//		NGeometryUtilities::ComparePointToPolygon : Compare a point to a polygon.
//-----------------------------------------------------------------------------
template<class T> NGeometryComparison NGeometryUtilities::ComparePointToPolygon(const NPointT<T> &thePoint, NIndex numPoints, const NPointT<T> *thePoints)
{	bool			p1Above, p2Above;
	SInt32			crossNum;
	NPointT<T>		p1, p2;
 	T				c, w;
    NIndex			n;



	// Validate our parameters
	NN_ASSERT(numPoints >= 3);



	// Test the polygon
	crossNum = 0;
	p1       = thePoints[numPoints-1];
	p1Above  = (p1.y > thePoint.y);
	
	for (n = 0; n < numPoints; n++)
		{
		// Look for a crossing in y
		p2      = thePoints[n];
		p2Above = (p2.y > thePoint.y);

		if (p1Above != p2Above)
			{
			// If the segment is entirely to the left in x, it can't cross
			if (std::max(p1.x, p2.x) < thePoint.x)
				;
			
			
			// If the segment is entirely to the right in x, it must cross
			else if (std::min(p1.x, p2.x) > thePoint.x)
				crossNum++;
			
			
			// Otherwise we need to check the intersection
			else
				{
				w = (thePoint.y - p1.y) / (p2.y - p1.y);
				c = p1.x + (w * (p2.x - p1.x));
				
				if (thePoint.x < c)
					crossNum++;
				}
			}
		
		p1      = p2;
		p1Above = p2Above;
		}



	// Process the result
    if (NMathUtilities::IsOdd(crossNum))
		return(kNGeometryInside);
	else
		return(kNGeometryOutside);
}
开发者ID:x414e54,项目名称:nano,代码行数:63,代码来源:NGeometryUtilities.cpp

示例12: NN_ASSERT

//============================================================================
//		NDate::SetDate : Set the date.
//----------------------------------------------------------------------------
void NDate::SetDate(const NGregorianDate &theDate)
{


    // Validate our parameters
    NN_ASSERT(theDate.month  >= 1   && theDate.month  <= 12);
    NN_ASSERT(theDate.day    >= 1   && theDate.day    <= 31);
    NN_ASSERT(theDate.hour   >= 0   && theDate.hour   <= 23);
    NN_ASSERT(theDate.minute >= 0   && theDate.minute <= 59);
    NN_ASSERT(theDate.second >= 0.0 && theDate.second <= 60.0);



    // Set the time
    mTime = NTargetTime::ConvertDateToTime(theDate);
}
开发者ID:refnum,项目名称:nano,代码行数:19,代码来源:NDate.cpp

示例13: NN_ASSERT

//============================================================================
//		NFileUtilities::GetDirectorySize : Get a directory size.
//----------------------------------------------------------------------------
uint64_t NFileUtilities::GetDirectorySize(const NFile &theDirectory)
{	NFileIterator				fileIterator;
	NFileList					theFiles;
	NFile						theFile;
	uint64_t					theSize;
	NFileListConstIterator		theIter;



	// Validate our parameters
	NN_ASSERT(theDirectory.IsDirectory());



	// Get the state we need
	theFiles = fileIterator.GetFiles(theDirectory);
	theSize  = 0;



	// Get the size
	for (theIter = theFiles.begin(); theIter != theFiles.end(); theIter++)
		{
		theFile = *theIter;

		if (theFile.IsFile())
			theSize += theFile.GetSize();
		}

	return(theSize);
}
开发者ID:refnum,项目名称:nano,代码行数:34,代码来源:NFileUtilities.cpp

示例14: NN_ASSERT

//============================================================================
//		NCGShading::UpdateShading : Update the shading.
//----------------------------------------------------------------------------
void NCGShading::UpdateShading(void) const
{	CGColorSpaceRef		cgColorSpace;



	// Validate our state
	NN_ASSERT(!mShading.IsValid());



	// Create the new shading
	cgColorSpace = NCGColor::GetDeviceRGB();

	switch (mMode) {
		case kShadingNone:
			ResetShading();
			break;

		case kShadingLinear:
			mShading.SetObject(CGShadingCreateAxial( cgColorSpace, ToCG(mStartPoint), ToCG(mEndPoint), mEvaluate, mStartExtend, mEndExtend));
			break;

		case kShadingRadial:
			mShading.SetObject(CGShadingCreateRadial(cgColorSpace, ToCG(mStartPoint), mStartRadius, ToCG(mEndPoint), mEndRadius, mEvaluate, mStartExtend, mEndExtend));
			break;

		default:
			NN_LOG("Unknown shading mode: %d", mMode);
			break;
		}
}
开发者ID:refnum,项目名称:nano,代码行数:34,代码来源:NCGShading.cpp

示例15: NN_ASSERT

//============================================================================
//		NThreadPool::ScheduleTask : Schedule a task for execution.
//----------------------------------------------------------------------------
void NThreadPool::ScheduleTask(NThreadTask *theTask)
{


	// Validate our state
	NN_ASSERT(mLock.IsLocked());
	


	// Add the task
	PushTask(mTasks, theTask);
	mHavePushed = true;



	// Update the workers
	//
	// If we've reached the thread limit then the existing threads will need to
	// process this task, so we signal to let them know there's more work to do.
	//
	// Incrementing the thread count must be done by the main thread, since a large
	// number of tasks may be queued up before any worker thread gets a chance to run. 
	if (mActiveThreads < mThreadLimit)
		NThreadUtilities::DetachFunctor(BindSelf(NThreadPool::ExecuteTasks));

	mSemaphore.Signal();
}
开发者ID:refnum,项目名称:nano,代码行数:30,代码来源:NThreadPool.cpp


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