本文整理汇总了C++中Network::checkForCycle方法的典型用法代码示例。如果您正苦于以下问题:C++ Network::checkForCycle方法的具体用法?C++ Network::checkForCycle怎么用?C++ Network::checkForCycle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Network
的用法示例。
在下文中一共展示了Network::checkForCycle方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setLabelString
//
// When a Receiver gets a new label, it has to disconnect from its existing
// transmitter, and connect to the new one. This will work even if it's
// the transmitter that's changing our label.
boolean ReceiverNode::setLabelString(const char *label)
{
if (EqualString(label, this->getLabelString()))
return TRUE;
if (initializing && this->getNetwork()->isReadingNetwork())
return this->UniqueNameNode::setLabelString(label);
if (!this->verifyRestrictedLabel(label))
return FALSE;
//
// Skip the conflict check when reading in a newer style net since
// there can't be any conflict in these nets.
//
const char* conflict = NUL(char*);
if (this->getNetwork()->isReadingNetwork()) {
int net_major = this->getNetwork()->getNetMajorVersion();
int net_minor = this->getNetwork()->getNetMinorVersion();
int net_micro = this->getNetwork()->getNetMicroVersion();
int net_version = VERSION_NUMBER( net_major, net_minor, net_micro);
if (net_version < VERSION_NUMBER(3,1,1))
conflict = this->getNetwork()->nameConflictExists(this, label);
}
//
// If there is a name conflict while reading a network, it's important to try
// to continue in spite of the conflict and fix things up later. Reason: older
// versions of dx allowed the name conflict and we would like to try and fix
// things and report what happened rather than read the net incorrectly.
//
if ((conflict) && (this->getNetwork()->isReadingNetwork() == FALSE)) {
ErrorMessage("A %s with name \"%s\" already exists.", conflict, label);
return FALSE;
}
boolean found = FALSE;
List *ia = (List*)this->getInputArks(1);
if ((ia) && (ia->getSize() > 0)) {
Ark *a = (Ark*)ia->getElement(1);
int dummy;
if (EqualString(a->getSourceNode(dummy)->getLabelString(), label))
found = TRUE;
else
delete a;
}
ia = NUL(List*);
if (!found) {
List* l = this->getNetwork()->makeClassifiedNodeList(ClassTransmitterNode, FALSE);
ListIterator iterator;
Node *n;
if ((l) && (this->getNetwork()->isReadingNetwork() == FALSE)) {
//
// Before creating any Arks, check for cycles.
//
iterator.setList(*l);
while ( (n = (Node*)iterator.getNext()) ) {
if (EqualString(label, n->getLabelString())) {
Network* net = this->getNetwork();
if (net->checkForCycle(n, this)) {
ErrorMessage (
"Unable to rename Receiver \"%s\" to \"%s\"\n"
"because that would cause a cyclic connection.",
this->getLabelString(), label
);
delete l;
return FALSE;
}
}
}
}
if (l) {
iterator.setList(*l);
while ( (n = (Node*)iterator.getNext()) ) {
if (EqualString(label, n->getLabelString()))
{
found = TRUE;
// link me to transmitter
new Ark(n, 1, this, 1);
}
}
delete l;
}
}
//
// There was a name conflict because earlier versions of dx were less restrictive.
// Record the transmitter for later fixup. When the transmitter is fixed up,
// then we'll automatically get fixed up also. Caveat: if there is no transmitter
// connected, then it's cool to refuse the name because then we're not breaking
// anything.
//
//.........这里部分代码省略.........