本文整理汇总了C++中IObject::addRef方法的典型用法代码示例。如果您正苦于以下问题:C++ IObject::addRef方法的具体用法?C++ IObject::addRef怎么用?C++ IObject::addRef使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IObject
的用法示例。
在下文中一共展示了IObject::addRef方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createObject
IObject* SimpleDynamicLoader::createObject() {
IObject* obj;
obj = factory();
if(obj)
obj->addRef();
return obj;
}
示例2: createObject
IObject* GenericFactory::createObject() {
IObject* obj;
obj = factory();
if(obj)
obj->addRef();
return obj;
}
示例3: test006
void test006() {
IServiceManager* servmgr;
IStaticServiceHandler* handler;
IMonikerService* monikers;
IObject* testobj;
IObject* obj;
servmgr = XPLC_getServiceManager();
ASSERT(servmgr != 0, "could not obtain service manager");
obj = servmgr->getObject(XPLC::staticServiceHandler);
ASSERT(obj != 0, "could not obtain static service handler");
handler = mutate<IStaticServiceHandler>(obj);
ASSERT(handler != 0, "static service handler does not have the IStaticServiceHandler interface");
testobj = new TestObject;
ASSERT(testobj != 0, "could not create TestObject");
testobj->addRef();
handler->addObject(TestObject_CID, testobj);
VERIFY(servmgr->getObject(TestObject_CID) == testobj, "adding the test object did not work");
VERIFY(testobj->release() == 2, "incorrect refcount on test object");
obj = servmgr->getObject(XPLC::monikers);
ASSERT(obj != 0, "could not obtain moniker component");
monikers = mutate<IMonikerService>(obj);
ASSERT(monikers != 0, "moniker service does not have the IMoniker interface");
monikers->registerObject("moniker", XPLC::monikers);
monikers->registerObject("testobject", TestObject_CID);
obj = monikers->resolve("testobject");
ASSERT(obj != 0, "resolving the test object returned nothing");
ASSERT(obj == testobj, "the testobject moniker resolved to something else than the test object");
VERIFY(obj->release() == 2, "refcount is wrong on the test object");
obj = monikers->resolve("moniker:testobject");
ASSERT(obj != 0, "resolving the test object indirectly returned nothing");
ASSERT(obj == testobj, "the testobject moniker indirectly resolved to something else than the test object");
VERIFY(obj->release() == 2, "refcount is wrong on the test object");
obj = monikers->resolve("moniker:");
VERIFY(obj == 0, "resolving an empty sub-moniker returned something");
VERIFY(monikers->release() == 1, "incorrect refcount on moniker service");
VERIFY(handler->release() == 2, "incorrect refcount on static service handler");
VERIFY(servmgr->release() == 0, "service manager has non-zero refcount after release");
VERIFY(testobj->release() == 0, "refcount is wrong on the test object");
delete testobj;
}
示例4: XPLC_getInterface_real
UUID_MAP_END
IObject* XPLC_getInterface_real(void* self, const UUID& uuid,
const UUID_Info* uuidlist) {
IObject* rv;
while(uuidlist->iid) {
if(uuidlist->iid->equals(uuid)) {
rv = reinterpret_cast<IObject*>
(reinterpret_cast<ptrdiff_t>(self) + uuidlist->delta);
rv->addRef();
return rv;
}
uuidlist++;
}
return 0;
}
示例5: test
void test() {
MyTestObject* test = 0;
IObject* iobj = 0;
IFoo* ifoo = 0;
IBar* ibar = 0;
test = MyTestObject::create();
ASSERT(test, "could not instantiate test object");
iobj = static_cast<IFoo*>(test)->getInterface(IObject::IID);
VERIFY(iobj, "getInterface(IObject::IID) failed on test object");
VERIFY(reinterpret_cast<void*>(iobj) == reinterpret_cast<void*>(test), "identity test failed");
ifoo = get<IFoo>(iobj);
VERIFY(ifoo, "get<IFoo> failed on test object");
ibar = get<IBar>(ifoo);
VERIFY(ibar, "get<IBar> failed on test object");
ifoo->setFoo(10);
ibar->setBar(20);
VERIFY(ifoo->getFoo() == 10, "test object has unexpected behavior");
VERIFY(ibar->getBar() == 20, "test object has unexpected behavior");
VERIFY(iobj->addRef() == 4, "incorrect refcount");
VERIFY(ifoo->addRef() == 5, "incorrect refcount");
VERIFY(ibar->addRef() == 6, "incorrect refcount");
VERIFY(iobj->release() == 5, "incorrect refcount");
VERIFY(ifoo->release() == 4, "incorrect refcount");
VERIFY(ibar->release() == 3, "incorrect refcount");
VERIFY(iobj->release() == 2, "incorrect refcount");
VERIFY(ifoo->release() == 1, "incorrect refcount");
VERIFY(ibar->release() == 0, "incorrect refcount");
}