本文整理汇总了C++中FWObject::addRef方法的典型用法代码示例。如果您正苦于以下问题:C++ FWObject::addRef方法的具体用法?C++ FWObject::addRef怎么用?C++ FWObject::addRef使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FWObject
的用法示例。
在下文中一共展示了FWObject::addRef方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: groupObjects
void ObjectManipulator::groupObjects()
{
if (getCurrentObjectTree()->getNumSelected()==0) return;
FWObject *co = getCurrentObjectTree()->getSelectedObjects().front();
newGroupDialog ngd(this, m_project->db());
if (ngd.exec()==QDialog::Accepted)
{
QString objName = ngd.m_dialog->obj_name->text();
QString libName = ngd.m_dialog->libs->currentText();
QString type = ObjectGroup::TYPENAME;
if (Service::cast(co)!=NULL) type=ServiceGroup::TYPENAME;
if (Interval::cast(co)!=NULL) type=IntervalGroup::TYPENAME;
FWObject *parent = NULL;
FWObject *newgrp = NULL;
list<FWObject*> ll = m_project->db()->getByType( Library::TYPENAME );
for (FWObject::iterator i=ll.begin(); i!=ll.end(); i++)
{
FWObject *lib=*i;
if (libName==QString::fromUtf8(lib->getName().c_str()))
{
/* TODO: need to show a dialog and say that chosen library is
* read-only. this is not critical though since newGroupDialog fills
* the pull-down only with names of read-write libraries
*/
if (lib->isReadOnly()) return;
parent = FWBTree().getStandardSlotForObject(lib,type);
if (parent==NULL)
{
if (fwbdebug)
qDebug("ObjectManipulator::groupObjects(): could not find standard slot for object of type %s in library %s",
type.toAscii().constData(),lib->getName().c_str());
return;
}
newgrp = m_project->db()->create(type.toStdString());
newgrp->setName(string(objName.toUtf8().constData()));
break;
}
}
if (newgrp==NULL) return;
FWCmdAddObject *cmd = new FWCmdAddObject(
m_project, parent, newgrp, QObject::tr("Create new group"));
FWObject *new_state = cmd->getNewState();
new_state->add(newgrp);
vector<FWObject*> so = getCurrentObjectTree()->getSimplifiedSelection();
for (vector<FWObject*>::iterator i=so.begin(); i!=so.end(); ++i)
newgrp->addRef(*i);
m_project->undoStack->push(cmd);
}
}
示例2: if
bool RoutingCompiler::ConvertToAtomicForDST::processNext()
{
RoutingRule *rule=getNext(); if (rule==NULL) return false;
//RuleElementSrc *src=rule->getSrc(); assert(src);
RuleElementRDst *dst=rule->getRDst(); assert(dst);
for (FWObject::iterator it=dst->begin(); it!=dst->end(); ++it)
{
RoutingRule *r = compiler->dbcopy->createRoutingRule();
r->duplicate(rule);
compiler->temp_ruleset->add(r);
FWObject *s = r->getRDst(); assert(s);
s->clearChildren();
s->addRef(FWReference::getObject(*it));
tmp_queue.push_back(r);
}
return true;
}
示例3: main
//.........这里部分代码省略.........
<< libfwbuilder::Constants::getDataFormatVersion() << endl;
}
else if (cmd == NEWOBJECT)
{
newObject(objdb, objtype, name, comment_txt, parent, ops);
}
else if (cmd == DELOBJECT)
{
delObject(objdb, object);
}
else if (cmd == MODOBJECT)
{
modObject(objdb, object, comment_txt, ops);
}
else
{
list<FWObject*> objects;
findObjects(object, objdb, objects);
if (objects.size()==0)
{
cout << "Object " << object << " not found" << endl;
exit(-1);
}
for (list<FWObject*>::iterator it=objects.begin();
it!=objects.end(); ++it)
{
FWObject *obj = *it;
if (cmd==ADDGRP)
{
list<FWObject*> groups;
findObjects(group, objdb, groups);
if (groups.size()==0)
{
cout << "Group " << group << " not found" << endl;
exit(-1);
}
FWObject *grp = groups.front();
cout << "Adding object '" << obj->getName()
<< "' to the group '" << grp->getName()
<< "'" << endl;
grp->addRef(obj);
}
if (cmd==REMGRP)
{
list<FWObject*> groups;
findObjects(group, objdb, groups);
if (groups.size()==0)
{
cout << "Group " << group << " not found" << endl;
exit(-1);
}
FWObject *grp = groups.front();
cout << "Removing object '" << obj->getName()
<< "' from the group '" << grp->getName()
<< "'" << endl;
grp->removeRef(obj);
}
}
}
QString filename_qstr = QString::fromUtf8(filename.c_str());
QString bakfile = filename_qstr + ".bak";
QFile bakf(bakfile);
if (bakf.exists()) bakf.remove();
QFile dataf(filename_qstr);
if (dataf.rename(bakfile))
{
objdb->saveFile(filename);
} else
{
cout << "Could not rename data file, abroting operation" << endl;
cout << dataf.errorString().toStdString() << endl;
exit(-1);
}
} catch(FWException &ex) {
cerr << ex.toString() << endl;
exit(1);
} catch (std::string s) {
cerr << s;
exit(1);
} catch (std::exception ex) {
cerr << ex.what();
exit(1);
} catch (...) {
cerr << "Unsupported exception";
exit(1);
}
return(0);
}
示例4: pixNetworkZoneChecks
//.........这里部分代码省略.........
* require any recursive expanding anymore. Since objects were added
* to netzones directly, we do not need to bother with dereferencing,
* too.
*/
list<FWObject*> ol;
helper.expand_group_recursive(netzone, ol);
FWObject *nz = objdb->createObjectGroup();
assert(nz!=NULL);
nz->setName("netzone_" + iface->getLabel());
objdb->add(nz);
for (list<FWObject*>::iterator j=ol.begin(); j!=ol.end(); ++j)
{
Address *addr = Address::cast(*j);
if (addr == NULL || addr->getAddressPtr() == NULL)
{
QString err("Network zone of interface '%1' uses object '%2' "
"that is not an address");
abort(fw, NULL, NULL,
err.arg(iface->getLabel().c_str())
.arg((*j)->getName().c_str()).toStdString());
throw FatalErrorInSingleRuleCompileMode();
}
/*
Commented out for SF bug 3213019
currently we do not support ipv6 with PIX/ASA and FWSM. If user
creates a group to be used as network zone object and places ipv6
address in it, this address should be ignored while compiling the
policy but this should not be an error. Compiler uses network zone
group to do various address matching operations when it tries to
determine an interface for a rule where user did not specify
one. Since we never (should) have ipv6 in policy and nat rules,
compiler is not going to have anything to compare to ipv6 address in
the network zone even if there is one and this ipv6 address is going
to be ignored.
if (addr->getAddressPtr()->isV6())
{
QString err("Network zone of interface '%1' uses object '%2' "
"that is IPv6 address");
abort(fw, NULL, NULL,
err.arg(iface->getLabel().c_str())
.arg((*j)->getName().c_str()).toStdString());
throw FatalErrorInSingleRuleCompileMode();
}
*/
netzone_objects.insert(
pair<string,FWObject*>(iface->getLabel(),*j));
nz->addRef(*j);
}
iface->setStr("orig_netzone_id", netzone_id );
iface->setStr("network_zone",
FWObjectDatabase::getStringId(nz->getId()) );
}
/*
* the same object (network or host) can not belong to network zones
* of two different interfaces. Map netzone_objects holds pairs
* interface_id/object. We just make sure the same object does not
* appear in two pairs with different interfaces.
*/
multimap<string,FWObject*>::iterator k;
for (k=netzone_objects.begin(); k!=netzone_objects.end(); ++k)
{
multimap<string,FWObject*>::iterator l;
l=k;
++l;
for ( ; l!=netzone_objects.end(); ++l)
{
if ( l->second->getId() == k->second->getId() )
{
if (k->first==l->first)
{
QString err("Object %1 is used more than once in network "
"zone of interface '%2'");
abort(fw, NULL, NULL,
err.arg(l->second->getName().c_str())
.arg(k->first.c_str()).toStdString());
throw FatalErrorInSingleRuleCompileMode();
} else
{
QString err("Object %1 is used in network zones of "
"interfaces '%2' and '%3'");
abort(fw, NULL, NULL,
err.arg(l->second->getName().c_str())
.arg(k->first.c_str())
.arg(l->first.c_str()).toStdString());
throw FatalErrorInSingleRuleCompileMode();
}
}
}
}
}