Exemplo n.º 1
0
//////////////////////////////////////////////////////////////////////////
// processLoadedResource
void CsCore::processLoadedResource()
{
	BcScopedLock< BcMutex > Lock( ContainerLock_ );
	
	static BcBool DumpResources = BcFalse;
	
	if( DumpResources )
	{
		BcPrintf( "==========================================\n" );
		BcPrintf( "CsCore: Dump Resource:\n" );
		BcPrintf( "==========================================\n" );
	}
	
	TResourceListIterator It( LoadedResources_.begin() );
	while( It != LoadedResources_.end() )
	{
		CsResource* pResource = (*It);
		BcUnusedVar( pResource );
		
		// NOTE: Placeholder for doing stuff. Probably don't need to other
		//       than for debug purposes.
		if( DumpResources )
		{
			BcPrintf( "%s (%s)\n", (*pResource->getName()).c_str(), (*pResource->getType()).c_str() );
		}
		
		++It;
	}

	if( DumpResources )
	{
		BcPrintf( "==========================================\n" );
		DumpResources = BcFalse;
	}
}
//virtual
std::string CsSerialiserPackageObjectCodec::serialiseAsStringRef( 
	void* InData, 
	const ReClass* InType )
{
	std::string RetVal;

	if( Package_ != nullptr )
	{
		const ReClass* InClass = static_cast< const ReClass* >( InType );

		// Check if it's a resource.
		if( InClass->hasBaseClass( ReObject::StaticGetClass() ) )
		{
			CsResource* Resource = reinterpret_cast< CsResource* >( InData );
			ReObject* ResourceRootOwner = Resource->getRootOwner();
			if( ResourceRootOwner != nullptr )
			{
				BcChar OutChars[ 128 ];
				BcSPrintf( OutChars, "$(%s:%s.%s)",  
					(*Resource->getClass()->getName()).c_str(), 
					(*ResourceRootOwner->getName()).c_str(),
					(*Resource->getName()).c_str() );
				RetVal = OutChars;
			}
		}
	}

	if( RetVal.empty() )
	{
		// Default formatting.
		BcChar OutChars[ 128 ];
		BcSPrintf( OutChars, "$(%s:%s.%llu)",   
			(*InType->getName()).c_str(),
			( "this" ),
			( (unsigned long long)InData ) );
	}

	return RetVal;
}
Exemplo n.º 3
0
//////////////////////////////////////////////////////////////////////////
// close
//virtual 
void CsCore::close()
{
	// Verify we have no more resources to be created or loading.
	BcVerifyMsg( CreateResources_.size() == 0, "CsCore: Resources to be created, but system is closing!" );
	BcVerifyMsg( LoadingResources_.size() == 0, "CsCore: Resources currently loading, but system is closing!" );

	while( PackageList_.size() > 0 )
	{
		freeUnreferencedPackages();

		// Finish processing unloading resources.
		if( UnloadingResources_.size() > 0 )
		{
			processUnloadingResources();
		}
	}

	if( LoadedResources_.size() > 0 )
	{
		BcPrintf( "==========================================\n" );
		BcPrintf( "CsCore: Dump Resource On Exit:\n" );
		BcPrintf( "==========================================\n" );
	
		TResourceListIterator It( LoadedResources_.begin() );
		while( It != LoadedResources_.end() )
		{
			CsResource* pResource = (*It);
			BcPrintf( "%s.%s:%s \n", (*pResource->getPackageName()).c_str(), (*pResource->getName()).c_str(), (*pResource->getTypeName()).c_str() );
			++It;
		}
		BcPrintf( "==========================================\n" );
	}

	// Verify we don't have any left floating loaded or unloading.
	BcVerifyMsg( LoadedResources_.size() == 0, "CsCore: Resources still loaded, but system is closing! Has the scene cleaned up properly?" );
	BcVerifyMsg( UnloadingResources_.size() == 0, "CsCore: Resources still unloading, but system is closing!" );
}