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


C++ Ptr::BaseObject方法代码示例

本文整理汇总了C++中Ptr::BaseObject方法的典型用法代码示例。如果您正苦于以下问题:C++ Ptr::BaseObject方法的具体用法?C++ Ptr::BaseObject怎么用?C++ Ptr::BaseObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Ptr的用法示例。


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

示例1: TestKillSelfPointer1

void TestKillSelfPointer1(void)
{
	ObjectsInit();

	Ptr<CRoot>				pRoot;
	Ptr<CTestNamedObject>	pObject;
	BOOL					bResult;
	CBaseObject*			pvObject;

	pRoot = ORoot();

	pObject = OMalloc(CTestNamedObject);
	pObject->Init(1);
	pObject->mpNamedTest1 = pObject;

	pRoot->Add(pObject);
	AssertInt(1, pRoot->NumObjects());

	AssertLongLongInt(3, gcObjects.NumMemoryIndexes());

	pvObject = pObject.BaseObject();
	pObject = NULL;

	//pObject should be destroyed here and not cause a stack overflow.
	bResult = pRoot->Remove(pvObject);
	AssertTrue(bResult);
	AssertInt(0, pRoot->NumObjects());

	AssertLongLongInt(2, gcObjects.NumMemoryIndexes());

	ObjectsKill();
}
开发者ID:chrisjaquet,项目名称:Codaphela.Test,代码行数:32,代码来源:TestKill.cpp

示例2: TestObjectsObjectSave

void TestObjectsObjectSave(void)
{
	CFileUtil						cFileUtil;
	Ptr<CTestDoubleNamedString>		pDouble;
	BOOL							bResult;
	CIndexedConfig					cConfig;

	cFileUtil.RemoveDir("Output");
	cFileUtil.MakeDir("Output/ObjectSave");
	cConfig.OptimiseForStreaming("Output/ObjectSave");
	cConfig.SetObjectCacheSize(128 MB);

	ObjectsInit(&cConfig);

	pDouble = SetupObjectsForDehollowfication();

	AssertLongLongInt(0, gcObjects.NumDatabaseObjects());
	AssertLongLongInt(9, gcObjects.NumMemoryIndexes());
	AssertLongLongInt(6, gcObjects.NumMemoryNames());
	AssertTrue(pDouble.IsDirty());
	
	bResult = gcObjects.Save(pDouble.BaseObject());
	AssertTrue(bResult);
	AssertTrue(pDouble.IsDirty());  //This object is *still* dirty after save.  Almost no objects will answer true to IsDirty.

	AssertLongLongInt(1, gcObjects.NumDatabaseObjects());
	AssertLongLongInt(9, gcObjects.NumMemoryIndexes());
	AssertLongLongInt(6, gcObjects.NumMemoryNames());
	AssertInt(106, pDouble->SerialisedSize());
	AssertLongLongInt(1, gcObjects.NumDatabaseObjectsCached(106));
	AssertLongLongInt(0, gcObjects.NumDatabaseObjectsCached(118));

	bResult = gcObjects.Save(pDouble.BaseObject());
	AssertTrue(bResult);
	AssertLongLongInt(1, gcObjects.NumDatabaseObjects());
	AssertInt(106, pDouble->SerialisedSize());
	AssertLongLongInt(1, gcObjects.NumDatabaseObjectsCached(106));
	AssertLongLongInt(0, gcObjects.NumDatabaseObjectsCached(118));
	
	pDouble->mszString = OMalloc(CString);
	pDouble->mszString->Init("A String");

	bResult = gcObjects.Save(pDouble.BaseObject());
	AssertTrue(bResult);
	AssertLongLongInt(1, gcObjects.NumDatabaseObjects());
	AssertInt(118, pDouble->SerialisedSize());
	AssertLongLongInt(0, gcObjects.NumDatabaseObjectsCached(106));
	AssertLongLongInt(1, gcObjects.NumDatabaseObjectsCached(118));

	pDouble->mszString = OMalloc(CString);
	pDouble->mszString->Init("Different Object");

	AssertInt(118, pDouble->SerialisedSize());
	bResult = gcObjects.Save(pDouble.BaseObject());
	AssertTrue(bResult);
	AssertLongLongInt(1, gcObjects.NumDatabaseObjects());
	AssertInt(118, pDouble->SerialisedSize());
	AssertLongLongInt(0, gcObjects.NumDatabaseObjectsCached(106));
	AssertLongLongInt(1, gcObjects.NumDatabaseObjectsCached(118));

	ObjectsKill();
}
开发者ID:andrewpaterson,项目名称:Codaphela.Test,代码行数:62,代码来源:TestObjects.cpp


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