本文整理汇总了C++中FWObject::getTypeName方法的典型用法代码示例。如果您正苦于以下问题:C++ FWObject::getTypeName方法的具体用法?C++ FWObject::getTypeName怎么用?C++ FWObject::getTypeName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FWObject
的用法示例。
在下文中一共展示了FWObject::getTypeName方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: compare_addrs
bool operator<( const QTreeWidgetItem & other ) const
{
int col = this->treeWidget()->sortColumn();
if ( col != 1)
return this->text(col) < other.text(col);
FWObject *otherobj = db->findInIndex(other.data(0, Qt::UserRole).toInt());
FWObject *thisobj = db->findInIndex(this->data(0, Qt::UserRole).toInt());
if (otherobj->getTypeName() != thisobj->getTypeName())
return thisobj->getTypeName() < otherobj->getTypeName();
if (IPv4::isA(thisobj) || IPv6::isA(thisobj))
{
return compare_addrs(Address::cast(thisobj)->getAddressPtr(), Address::cast(otherobj)->getAddressPtr());
}
if (Service::isA(thisobj))
{
return Service::cast(thisobj)->getProtocolNumber() < Service::cast(otherobj)->getProtocolNumber();
}
if(AddressRange::isA(thisobj))
{
return compare_addrs(&AddressRange::cast(thisobj)->getRangeStart(),
&AddressRange::cast(otherobj)->getRangeStart());
}
if (Host::isA(thisobj))
{
return compare_addrs(Host::cast(thisobj)->getAddressPtr(),
Host::cast(otherobj)->getAddressPtr());
}
return this->text(col) < other.text(col);
}
示例2: dragEnterEvent
void FWObjectDropArea::dragEnterEvent( QDragEnterEvent *ev)
{
list<FWObject*> dragol;
if (FWObjectDrag::decode(ev, dragol))
{
if (dragol.size()>0)
{
FWObject * o = dragol.front();
bool ok = false ;
if (acceptedTypes.size()==0)
ok = true ;
for (int p = 0 ; p < acceptedTypes.size(); p++)
{
QString type =o->getTypeName().c_str();
if (type==acceptedTypes[p])
{
ok = true ;
break ;
}
}
if (!ok)
{
ev->setAccepted(false);
return ;
}
}
}
ev->setAccepted( ev->mimeData()->hasFormat(FWObjectDrag::FWB_MIME_TYPE) );
}
示例3: dragObject
QDrag* ObjectListView::dragObject()
{
QTreeWidgetItem *ovi = currentItem();
// currentItem returns NULL if the list is empty
if (ovi==NULL) return NULL;
int obj_id = ovi->data(0, Qt::UserRole).toInt();
FWObject *obj = db->findInIndex(obj_id);
QString icn = (":/Icons/"+obj->getTypeName()+"/icon-ref").c_str();
//Resources::global_res->getObjResourceStr(obj, "icon-ref").c_str();
list<FWObject*> dragobj;
dragobj.push_back(obj);
FWObjectDrag *drag = new FWObjectDrag(dragobj, this);
//QPixmap pm = QPixmap::fromMimeSource( icn_filename );
QPixmap pm;
if ( ! QPixmapCache::find( icn, pm) )
{
pm.load( icn );
QPixmapCache::insert( icn, pm);
}
drag->setPixmap( pm );
drag->setHotSpot( QPoint( pm.rect().width() / 2,
pm.rect().height() / 2 ) );
return drag;
}
示例4: string
/*
* checks if one of the children of RuleElement is a host, IPv4 or
* network object with address 0.0.0.0 and netmask 0.0.0.0.
*
* Exceptions:
* - object 'any'
* - interface with dynamic address.
*
* In addition check for address A.B.C.D/0 which is most likely a
* mistake if A.B.C.D != 0.0.0.0. See #475
*/
Address* PolicyCompiler::checkForZeroAddr::findZeroAddress(RuleElement *re)
{
Address *a=NULL;
for (FWObject::iterator i=re->begin(); i!=re->end(); i++)
{
FWObject *o = FWReference::getObject(*i);
assert(o!=NULL);
MultiAddress *maddr = MultiAddress::cast(o);
if (maddr && maddr->isRunTime()) continue;
Address *addr = Address::cast(o);
if (addr==NULL && o!=NULL)
compiler->warning(
re->getParent(),
string("findZeroAddress: Unknown object in rule element: ") +
o->getName() +
" type=" + o->getTypeName());
if (addr && addr->hasInetAddress())
{
if (Interface::cast(o)!=NULL &&
(Interface::cast(o)->isDyn() ||
Interface::cast(o)->isUnnumbered() ||
Interface::cast(o)->isBridgePort()))
continue;
if ( ! addr->isAny())
{
const InetAddr *ad = addr->getAddressPtr();
const InetAddr *nm = addr->getNetmaskPtr();
// AddressRange has address but not netmask
// AddressRange with address 0.0.0.0 is acceptable
// (not equivalent to "any")
if (ad->isAny() && nm!=NULL && nm->isAny())
{
a = addr;
break;
}
// Address A.B.C.D/0 is most likely a mistake if
// A.B.C.D != 0.0.0.0
if ((Network::cast(addr) || NetworkIPv6::cast(addr)) &&
!ad->isAny() && nm!=NULL && nm->isAny())
{
a = addr;
break;
}
}
}
}
return a;
}
示例5: PrintTables
string TableFactory::PrintTables()
{
if (tables.size() == 0) return "";
stringstream output;
output << endl;
output << "# Tables: (" << tables.size() << ")" << endl;
for (map<string,string>::const_iterator i=tblnames.begin();
i!=tblnames.end(); i++)
{
string tblID = i->second;
FWObject *grp = tables[tblID];
output << "table ";
output << "<" << grp->getName() << "> ";
MultiAddressRunTime *atrt = MultiAddressRunTime::cast(grp);
if (atrt!=nullptr &&
atrt->getSubstitutionTypeName()==AddressTable::TYPENAME)
{
output << "persist";
if ( !atrt->getSourceName().empty() )
{
string path =
atrt->getSourceNameAsPath(firewall->getOptionsObject());
if (path.empty()) {
compiler->abort("Error: Firewall's data directory not set for address table: " + atrt->getName());
}
output << " file \"" << path << "\"";
}
output << endl;
continue;
}
output << "{ ";
for (FWObject::iterator i=grp->begin(); i!=grp->end(); i++)
{
if (i!=grp->begin()) output << ", ";
FWObject *o = FWReference::getObject(*i);
if (o==nullptr) compiler->abort("broken table object ");
MultiAddressRunTime *atrt = MultiAddressRunTime::cast(o);
if (atrt!=nullptr)
{
if (atrt->getSubstitutionTypeName()==DNSName::TYPENAME)
{
output << atrt->getSourceName() << " ";
}
if (atrt->getSubstitutionTypeName()==AttachedNetworks::TYPENAME)
{
output << atrt->getSourceName() << ":network ";
}
} else
{
if (Interface::cast(o))
{
output << o->getName();
} else
{
Address *A=Address::cast( o );
if (A==nullptr)
compiler->abort("table object must be an address: '" +
o->getTypeName()+"'");
const InetAddr *addr = A->getAddressPtr();
InetAddr mask = *(A->getNetmaskPtr());
if (A->dimension()==1)
{
mask = InetAddr(InetAddr::getAllOnes());
}
output << addr->toString();
if (!mask.isHostMask())
{
output << "/" << mask.getLength();
}
}
}
output << " ";
}
output << "} ";
output << endl;
}
output << endl;
return output.str();
}
示例6: exportLibraryTest
bool ProjectPanel::exportLibraryTest(list<FWObject*> &selectedLibs)
{
/* VERY IMPORTANT: External library file must be self-contained,
* otherwise it can not be exported.
*
* check if selected libraries have references to objects in other
* libraries (not exported to the same file). Exporting such libraries
* pulls in other ones because of these references. This is confusing
* because it means we end up with multiple copies of such objects (in
* exported library file and in user's data file). When user imports
* this library and opens their file, it is impossible to say which
* library an object belongs to.
*
* This is prohibited. We check if exported set of libraries has such
* references and refuse to export it. The user is supposed to clean
* it up by either moving objects into the library they are trying to
* export, or by rearranging objects. The only exception for this is
* library "Standard", which is assumed to be always present so we can
* have references to objects in it.
*/
QApplication::setOverrideCursor( QCursor( Qt::WaitCursor) );
list<FWReference*> externalRefs;
for (list<FWObject*>::iterator i=selectedLibs.begin(); i!=selectedLibs.end(); ++i)
findExternalRefs( *i, *i, externalRefs);
QApplication::restoreOverrideCursor();
if (fwbdebug) qDebug("LibExportDialog::accept externalRefs.size()=%d",
int(externalRefs.size()) );
/*
* if externalRefs.size()!=0, then there were some references pointing
* outside of the libraries we export. Some of these references may
* point at other libraries we export, lets find these.
*/
list<FWReference*> externalRefs2;
for (list<FWReference*>::iterator i=externalRefs.begin(); i!=externalRefs.end(); ++i)
{
FWObject *tgt = (*i)->getPointer();
FWObject *tgtlib = tgt->getLibrary();
if (std::find(selectedLibs.begin(),selectedLibs.end(),tgtlib)!=selectedLibs.end()) continue;
externalRefs2.push_back(*i);
}
if (externalRefs2.size()!=0)
{
QString objlist = "";
QString s = "";
for (list<FWReference*>::iterator i=externalRefs2.begin();
i!=externalRefs2.end(); ++i)
{
FWReference *robj = *i;
FWObject *selLib = robj->getLibrary();
FWObject *pp = robj->getParent();
FWObject *tgt = robj->getPointer();
FWObject *tgtlib = tgt->getLibrary();
if (fwbdebug)
{
qDebug("LibExportDialog::accept tgt: %s pp_type: %s lib: %s",
tgt->getName().c_str(),
pp->getTypeName().c_str(),
tgtlib->getName().c_str());
}
if (std::find(selectedLibs.begin(),selectedLibs.end(),tgtlib)!=selectedLibs.end()) continue;
if (RuleElement::cast(pp)!=nullptr)
{
FWObject *fw = pp;
FWObject *rule = pp;
FWObject *ruleset = pp;
FWObject *iface = pp;
while (rule!=nullptr && Rule::cast(rule)==nullptr)
rule=rule->getParent();
while (ruleset!=nullptr && RuleSet::cast(ruleset)==nullptr)
ruleset=ruleset->getParent();
while (iface!=nullptr && Interface::cast(iface)==nullptr)
iface=iface->getParent();
while (fw!=nullptr && Firewall::cast(fw)==nullptr)
fw=fw->getParent();
s = QObject::tr("Library %1: Firewall '%2' (%3 rule #%4) uses "
"object '%5' from library '%6'")
.arg(selLib->getName().c_str())
.arg(fw->getName().c_str())
.arg(ruleset->getTypeName().c_str())
.arg(Rule::cast(rule)->getPosition())
.arg(tgt->getName().c_str())
.arg(tgtlib->getName().c_str());
} else
{
s =
QObject::tr("Library %1: Group '%2' uses object '%3' from library '%4'")
.arg(selLib->getName().c_str())
//.........这里部分代码省略.........
示例7: event
bool ProjectPanel::event(QEvent *event)
{
if (event->type() >= QEvent::User)
{
fwbUpdateEvent *ev = dynamic_cast<fwbUpdateEvent*>(event);
int event_code = event->type() - QEvent::User;
QString data_file = ev->getFileName();
int obj_id = ev->getObjectId();
FWObject *obj = db()->findInIndex(obj_id);
if (fwbdebug)
qDebug() << this
<< "rcs:"
<< rcs
<< "rcs->getFileName():"
<< QString((rcs!=NULL) ? rcs->getFileName() : "")
<< "file:"
<< data_file
<< "event:"
<< ev->getEventName()
<< "object:"
<< ((obj!=NULL) ? QString::fromUtf8(obj->getName().c_str()) : "")
<< "(" << ((obj!=NULL) ? obj->getTypeName().c_str() : "") << ")"
<< "id=" << ((obj!=NULL) ? obj->getId() : -1);
if (event_code == UPDATE_GUI_STATE_EVENT && mdiWindow != NULL)
{
m_panel->om->updateCreateObjectMenu(getCurrentLib());
ev->accept();
return true;
}
if ((rcs && rcs->getFileName() == data_file) ||
(!rcs && data_file.isEmpty()))
{
switch (event_code)
{
case RELOAD_OBJECT_TREE_EVENT:
registerTreeReloadRequest();
ev->accept();
return true;
case RELOAD_OBJECT_TREE_IMMEDIATELY_EVENT:
m_panel->om->reload();
ev->accept();
return true;
case RELOAD_RULESET_EVENT:
registerRuleSetRedrawRequest();
// update rule set title as well
//updateFirewallName();
ev->accept();
return true;
case MAKE_CURRENT_RULE_VISIBLE_IN_RULESET_EVENT:
{
RuleSetView* rsv = getCurrentRuleSetView();
if (rsv) rsv->makeCurrentRuleVisible();
ev->accept();
return true;
}
case RELOAD_RULESET_IMMEDIATELY_EVENT:
redrawRuleSets();
//reopenFirewall();
// update rule set title as well
//updateFirewallName();
ev->accept();
return true;
}
if (obj == NULL) return false;
switch (event_code)
{
case DATA_MODIFIED_EVENT:
{
// This event does not trigger any updates in the UI,
// this purely data structure update event.
FWObject *p = obj;
while (p && Firewall::cast(p)==NULL) p = p->getParent();
Firewall *f = Firewall::cast(p);
// when user locks firewall object, this code tries to
// update last_modified timestamp in it because it
// depends on itself. Dont.
if (f && !f->isReadOnly())
{
f->updateLastModifiedTimestamp();
QCoreApplication::postEvent(
mw, new updateObjectInTreeEvent(data_file, f->getId()));
}
registerModifiedObject(obj);
QCoreApplication::postEvent(mw, new updateGUIStateEvent());
ev->accept();
return true;
}
//.........这里部分代码省略.........