Go to the source code of this file.
Definition in file refcount.hh.
|
Value: { type ptr = value; \ try { body; if(ptr) (ptr)->release(); \ } catch(...) { if(ptr) (ptr)->release(); throw; } }
This macro defines a lexical scope in which you have a reference to a reference-counted object. The purpose of this macro is to simplify tracking the acquire/release pair in the most common case of accessing a refcounted object by calling release() for you when you're clearly done accessing the refcounted object. This example should make it clearer: pREF(Sphere*, sphere, MetaObject::meta_cast<Sphere*>(MetaFactory::createLocalObject(&ls, typeid(Sphere).name(), 0));, sphere->setAccessControl(&NoPropertyAccessControl::static_NoPropertyAccessControl); sphere->setMaterial("#FF0000"); // more sphere->setSomething(); method calls model->insertChild(-1, "ball", sphere); ); { Sphere* sphere = MetaObject::meta_cast<Sphere*>(MetaFactory::createLocalObject(&ls, typeid(Sphere).name(), 0)); try { sphere->setAccessControl(&NoPropertyAccessControl::static_NoPropertyAccessControl); sphere->setMaterial("#FF0000"); // more sphere->setSomething(); method calls model->insertChild(-1, "ball", sphere); if(sphere) sphere->release(); } catch(exception x) { if(sphere) sphere->release(); throw; } }
Definition at line 114 of file refcount.hh. Referenced by ExtrapolatedRemoteProperty::addExtrapolationListener(), RemoteProperty::asyncRead(), LocalSite::checkScheduleHoldsSite(), RemoteLogin::doRequestLogin(), VOS::RemoteVobject::findChild(), BufferedRemoteProperty::flush(), VOS::RemoteVobject::getParents(), RemoteProperty::getRawLength(), VOS::RemoteVobject::getTypes(), LocalLogin::handleLoginChallengeReply(), LocalLogin::handleRequestLogin(), RemoteLogin::handleRequestLoginChallenge(), LocalImage2D::initialize(), VOS::RemoteVobject::insertChild(), LocalSound::pause(), LocalSound::play(), RemoteProperty::readRaw(), VOS::RemoteVobject::removeChildListener(), ExtrapolatedRemoteProperty::removeExtrapolationListener(), VOS::RemoteVobject::removeParentListener(), VOS::RemoteVobject::removeTypeListener(), LocalSound::resume(), VOS::RemoteStreamSite::runScript(), VOS::RemoteSocketSite::secureConnection(), ExtrapolatedLocalProperty::sendMessage(), VOS::LocalSocketSite::sendMessage(), ExtrapolatedRemoteProperty::set(), VOS::RemoteVobject::setChild(), and LocalSound::stop(). |
|