当前位置: 首页>>代码示例>>C++>>正文


C++ MacroDefinition::addInput方法代码示例

本文整理汇总了C++中MacroDefinition::addInput方法的典型用法代码示例。如果您正苦于以下问题:C++ MacroDefinition::addInput方法的具体用法?C++ MacroDefinition::addInput怎么用?C++ MacroDefinition::addInput使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MacroDefinition的用法示例。


在下文中一共展示了MacroDefinition::addInput方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: switchNetwork

void MacroParameterNode::switchNetwork(Network *from, Network *to, boolean silently)
{
    MacroDefinition *md = from->getDefinition();
    ParameterDefinition *pd = this->getParameterDefinition();
    ParameterDefinition *dummyPd;
    int n;

    dummyPd = new ParameterDefinition(-1);
    dummyPd->setDummy(TRUE);
    dummyPd->addType(new DXType(DXType::ObjectType));

    if(this->isInput())
	md->replaceInput(dummyPd, pd);
    else
	md->replaceOutput(dummyPd, pd);

    //
    // Switch the Network pointers
    //
    this->UniqueNameNode::switchNetwork(from, to, silently);

    //
    // Make sure we are a macro
    //
    to->makeMacro(TRUE);

    md = to->getDefinition();

    if(this->isInput())
    {
	n = md->getFirstAvailableInputPosition();

	if (n <= md->getInputCount()) {
	    dummyPd = md->getInputDefinition(n);
	    ASSERT(dummyPd->isDummy());
	    md->replaceInput(pd,dummyPd);
	} else {
	    md->addInput(pd);
	}
	this->setIndex(n);
    }
    else
    {
	n = md->getFirstAvailableOutputPosition();

	if (n <= md->getOutputCount()) {
	    ParameterDefinition *dummyPd = md->getOutputDefinition(n);
	    ASSERT(dummyPd->isDummy());
	    md->replaceOutput(pd,dummyPd);
	} else {
	    md->addOutput(pd);
	}
	this->setIndex(n);
    }

    //
    // See if the input is named input_%d or output_%d
    // and if so, change it to match the possibly new index.
    //
    pd = this->getParameterDefinition();
    char buf[64];
    if (this->isInput()) {
	strcpy(buf,"input_");
    } else {
	strcpy(buf,"output_");
    }
    int buflen = strlen(buf);
    const char* current_name = pd->getNameString();
    const char* new_name = NUL(char*);
    boolean name_reset = FALSE;
    if (EqualSubstring(current_name, buf, buflen)) {
	int endint = 0;
	const char *end = &current_name[strlen(current_name)];
	if (IsInteger(current_name+buflen,endint) &&
	    ((current_name+buflen+endint) == end)) {
		sprintf(buf+buflen,"%d",this->getIndex());
		pd->setName(buf);
		name_reset = TRUE;
	}
    }

    //
    // Resolve name conflicts with other nodes using global names.
    //
    if (!name_reset) {
	int name_clash=0, i;
	if (this->isInput()) {
	    int count = to->getInputCount();
	    for (i=1 ; !name_clash && (i <= count) ; i++) {
		ParameterDefinition *opd = to->getInputDefinition(i);
		if ((i != this->getIndex()) &&
		    EqualString(current_name,opd->getNameString()))
		    name_clash = i;
	    }
	} else {
	    int count = to->getOutputCount();
	    for (i=1 ; !name_clash && (i <= count) ; i++) {
		ParameterDefinition *opd = to->getOutputDefinition(i);
		if ((i != this->getIndex()) &&
		    EqualString(current_name,opd->getNameString()))
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:opendx2,代码行数:101,代码来源:MacroParameterNode.C

示例2: ParameterDefinition

boolean
MacroParameterNode::initialize()
{
    this->UniqueNameNode::initialize();
    Network *net = this->getNetwork();
    if (!net->isMacro())
	net->makeMacro(TRUE);
    MacroDefinition *md = net->getDefinition();
    ParameterDefinition *param=NULL;

    boolean input = this->isInput();
    if (!md->isReadingNet()) {
	param = new ParameterDefinition(-1);
	param->addType(new DXType(DXType::ObjectType));
    }

    char s[100];
    if (input)
    {
	if (!md->isReadingNet()) {
	    int n = md->getFirstAvailableInputPosition();
	    param->markAsInput();
	    if (n <= md->getInputCount()) {
		ParameterDefinition *dummyPd = md->getInputDefinition(n);
		ASSERT(dummyPd->isDummy());
		md->replaceInput(param,dummyPd);
	    } else {
		md->addInput(param);
	    }
	    this->setIndex(n);
	    sprintf(s, "input_%d", this->index);
	    param->setName(s);
	    param->setDefaultValue("(no default)");
	}

	//
	// The Parameter  must have its own ParameterDefinition since
	// it may change depending upon what we are connected to.
	// FIXME: ParameterDefinition should have a dup() method.
	//
	Parameter *p = this->getOutputParameter(1);
	ParameterDefinition *pd = p->getDefinition();
#if 11
	ParameterDefinition *newpd = pd->duplicate();
#else
	ParameterDefinition *newpd = 
	    new ParameterDefinition(pd->getNameSymbol());
	List *l = pd->getTypes();
	DXType *dxt;
	for (ListIterator li(*l); dxt = (DXType*)li.getNext();)
	    newpd->addType(dxt);
	newpd->markAsOutput();
	newpd->setDefaultVisibility(pd->getDefaultVisibility());
	newpd->setViewability(pd->isViewable());
	newpd->setDescription(pd->getDescription());
	newpd->setWriteableCacheability(pd->hasWriteableCacheability());
	newpd->setDefaultCacheability(pd->getDefaultCacheability());
	if (pd->isRequired())
	    newpd->setRequired();
	else
	    newpd->setNotRequired();
	if (pd->isDefaultValue())
	    newpd->setDefaultValue(pd->getDefaultValue());
	else
	    newpd->setDescriptiveValue(pd->getDefaultValue());
#endif
	p->setDefinition(newpd);
    }
    else
    {
	if (!md->isReadingNet()) {
	    int n = md->getFirstAvailableOutputPosition();
	    param->markAsOutput();
	    if (n <= md->getOutputCount()) {
		ParameterDefinition *dummyPd = md->getOutputDefinition(n);
		ASSERT(dummyPd->isDummy());
		md->replaceOutput(param,dummyPd);
	    } else {
		md->addOutput(param);
	    }
	    this->setIndex(n);
	    sprintf(s, "output_%d", this->index);
	    param->setName(s);
	    param->setDefaultValue("(no default)");
	}

	//
	// The Parameter  must have its own ParameterDefinition since
	// it may change depending upon what we are connected to.
	// FIXME: ParameterDefinition should have a dup() method.
	//
	Parameter *p = this->getInputParameter(1);
	ParameterDefinition *pd = p->getDefinition();
#if 11
	ParameterDefinition *newpd = pd->duplicate();
#else
	ParameterDefinition *newpd =
	    new ParameterDefinition(pd->getNameSymbol());
	List *l = pd->getTypes();
	DXType *dxt;
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:opendx2,代码行数:101,代码来源:MacroParameterNode.C


注:本文中的MacroDefinition::addInput方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。