本文整理汇总了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();
}
示例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();
}