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


C++ ExprTree::Copy方法代码示例

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


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

示例1:

bool
caInsert( ClassAd* target, ClassAd* source, const char* attr,
		  const char* prefix )
{
	ExprTree* tree;

	if( !attr ) {
		EXCEPT( "caInsert called with NULL attribute" );
	}
	if( !target || !source ) {
		EXCEPT( "caInsert called with NULL classad" );
	}

	MyString new_attr;
	if( prefix ) {
		new_attr = prefix;
	}
	new_attr += attr;

	tree = source->LookupExpr( attr );
	if( !tree ) {
		target->Delete(new_attr.Value());
		return false;
	}
	tree = tree->Copy();
	if ( !target->Insert(new_attr.Value(), tree, false) ) {
		dprintf( D_ALWAYS, "caInsert: Can't insert %s into target classad.\n", attr );
		delete tree;
		return false;
	}
	return true;
}
开发者ID:AlainRoy,项目名称:htcondor,代码行数:32,代码来源:util.cpp

示例2: checkInputSandbox

void ParametricAd::checkInputSandbox(std::vector<std::string>& extracted){
	GLITE_STACK_TRY("ParametricAd::checkInputSandbox(std::vector<std::string>&)");
	// This vector contains all ISB string extracted Values
	unsigned int iter_i = extracted.size();
	// This Vector will replace the old InputSanbox with the extracted values
	vector<ExprTree*> isVect ;
	ExprTree* isbTree = Lookup (JDL::INPUTSB);
	if (!isbTree){ /* No inputFiles found: return */ return; }
	// These variables are needed when extracting
	const string wmpURI = (hasAttribute(JDL::WMPISB_BASE_URI))? (getString(JDL::WMPISB_BASE_URI)):"";
	const string isbURI=   (hasAttribute(JDL::ISB_BASE_URI))  ? (getString(JDL::ISB_BASE_URI)   ):"";
	Value val ;
	string isb ;
	EvaluateExpr(isbTree,val);
	inputRemotes.clear();
	switch ( val.GetType() ){
		case Value::UNDEFINED_VALUE:
			inputRemotes.push_back(isbTree->Copy());
			isVect.push_back(isbTree->Copy());
			break;
		case Value::STRING_VALUE:
			val.IsStringValue(isb);
			toBretrieved=extractFiles (JDL::INPUTSB, isb, extracted,
				lookInto_b,wmpURI,isbURI,extractedAd.get()) || toBretrieved;
			// put the extracted files back into the InputSandbox attribute
			for(;iter_i<extracted.size();iter_i++){	// Iterate ONLY over new value(s)
				val.SetStringValue(extracted[iter_i]);	// create classad Value
				isVect.push_back(Literal::MakeLiteral(val));	// Update ISB value
			}
			break;
		case Value::LIST_VALUE:{
			const ExprList *el;
			val.IsListValue( el );
			vector<ExprTree*> vectList ;
			el->GetComponents(vectList) ;
			for ( unsigned int i = 0; i< vectList.size() ; i++){
				if (vectList[i]->GetKind()!=ExprTree::LITERAL_NODE){
					// not a literal node
					inputRemotes.push_back( vectList[i]->Copy() );
					isVect.push_back(vectList[i]->Copy());
				}
				else if (vectList[i]->Evaluate(val)){
					switch (val.GetType()){
						case Value::STRING_VALUE:
							val.IsStringValue(isb);
							toBretrieved=extractFiles (JDL::INPUTSB, isb, extracted,
								lookInto_b,wmpURI,isbURI,extractedAd.get()) || toBretrieved;
							// put the extracted files back into the InputSandbox attribute
							for(;iter_i<extracted.size();iter_i++){	// Iterate ONLY over new value(s)
								val.SetStringValue(extracted[iter_i]);	// create classad Value
								isVect.push_back(Literal::MakeLiteral(val));	// Update ISB value
							}
							break;
						case Value::UNDEFINED_VALUE:
							// It's an Expression evaluated
							inputRemotes.push_back( vectList[i]->Copy() );
							isVect.push_back(vectList[i]->Copy());
							break;
						default:
							throw AdMismatchException (__FILE__,__LINE__,
							METHOD,WMS_JDLMISMATCH , JDL::INPUTSB );
					}
				}else{
					// It's an Expression not evaluated, leave it unchanged
					inputRemotes.push_back( vectList[i]->Copy() );
					isVect.push_back(vectList[i]->Copy());
				}
				val.Clear() ;
			}
		}
		break;
		default:
			throw AdMismatchException (__FILE__ , __LINE__ ,METHOD, WMS_JDLMISMATCH , JDL::INPUTSB );
			break;
	}
	classad:ExprTree* tmp_expr = ExprList::MakeExprList(isVect);
	Insert (JDL::INPUTSB , tmp_expr) ;
	GLITE_STACK_JDL_CATCH_ALL() ; //Exiting from method: remove line from stack trace
}
开发者ID:italiangrid,项目名称:jdl-api-cpp,代码行数:79,代码来源:parametricad.cpp

示例3: command


//.........这里部分代码省略.........
	respad.LookupInteger(ATTR_TREQ_NUM_TRANSFERS, num_transfers);

	//////////////////////////////////////////////////////////////////////////
	// Based upon the protocol I've chosen, use that method to download the
	// files. When using the FileTrans protocol, a child process on the
	// transferd side will be sending me individual job ads and then 
	// instantiating a filetransfer object for that ad.
	//////////////////////////////////////////////////////////////////////////

	dprintf(D_ALWAYS, "Receiving fileset");
	work_ad->LookupInteger(ATTR_TREQ_FTP, protocol);
	switch(protocol) {
		case FTP_CFTP: // download the files using the FileTransfer Object
			for (i = 0; i < num_transfers; i++) {

				// Grab a job ad the server is sending us so we know what
				// to receive.
				jad.initFromStream(*rsock);
				rsock->end_of_message();

				// translate the job ad by replacing the 
				// saved SUBMIT_ attributes so the download goes into the
				// correct place.
				jad.ResetExpr();
				while( jad.NextExpr(lhstr, tree) ) {
					if ( lhstr && strncasecmp("SUBMIT_",lhstr,7)==0 ) {
							// this attr name starts with SUBMIT_
							// compute new lhs (strip off the SUBMIT_)
						const char *new_attr_name = strchr(lhstr,'_');
						ExprTree * pTree;
						ASSERT(new_attr_name);
						new_attr_name++;
							// insert attribute
						pTree = tree->Copy();
						jad.Insert(new_attr_name, pTree, false);
					}
				}	// while next expr
		
				// instantiate a filetransfer object and have it accept the
				// files.
				FileTransfer ftrans;
				if ( !ftrans.SimpleInit(&jad, false, false, rsock) )
				{
					delete rsock;
					errstack->push("DC_TRANSFERD", 1, 
						"Failed to initate uploading of files.");
					return false;
				}

				// We want files to be copied to their final places, so apply
				// any filename remaps when downloading.
				if ( !ftrans.InitDownloadFilenameRemaps(&jad) ) {
					return false;
				}

				ftrans.setPeerVersion( version() );

				if ( !ftrans.DownloadFiles() ) {
					delete rsock;
					errstack->push("DC_TRANSFERD", 1, 
						"Failed to download files.");
					return false;
				}

				dprintf(D_ALWAYS | D_NOHEADER, ".");
			}	
开发者ID:emaste,项目名称:htcondor,代码行数:67,代码来源:dc_transferd.cpp

示例4: vi


//.........这里部分代码省略.........
		}
		return false;
	}

	rsock.end_of_message();

	dprintf(D_FULLDEBUG,"DCSchedd:receiveJobSandbox: "
		"%d jobs matched my constraint (%s)\n",
		JobAdsArrayLen, constraint);

		// Now read all the files via the file transfer object
	for (i=0; i<JobAdsArrayLen; i++) {
		FileTransfer ftrans;
		ClassAd job;

			// grab job ClassAd
		if ( !getClassAd(&rsock, job) ) {
			std::string errmsg;
			formatstr(errmsg, "Can't receive job ad %d from the schedd", i);

			dprintf(D_ALWAYS, "DCSchedd::receiveJobSandbox: %s\n", errmsg.c_str());

			if( errstack ) {
				errstack->push(
							   "DCSchedd::receiveJobSandbox",
							   CEDAR_ERR_GET_FAILED,
							   errmsg.c_str());
			}
			return false;
		}

		rsock.end_of_message();

			// translate the job ad by replacing the 
			// saved SUBMIT_ attributes
		job.ResetExpr();
		while( job.NextExpr(lhstr, tree) ) {
			if ( lhstr && strncasecmp("SUBMIT_",lhstr,7)==0 ) {
					// this attr name starts with SUBMIT_
					// compute new lhs (strip off the SUBMIT_)
				const char *new_attr_name = strchr(lhstr,'_');
				ExprTree * pTree;
				ASSERT(new_attr_name);
				new_attr_name++;
					// insert attribute
				pTree = tree->Copy();
				job.Insert(new_attr_name, pTree, false);
			}
		}	// while next expr

		if ( !ftrans.SimpleInit(&job,false,false,&rsock) ) {
			if( errstack ) {
				int cluster = -1, proc = -1;
				job.LookupInteger(ATTR_CLUSTER_ID,cluster);
				job.LookupInteger(ATTR_PROC_ID,proc);
				errstack->pushf(
					"DCSchedd::receiveJobSandbox",
					FILETRANSFER_INIT_FAILED,
					"File transfer initialization failed for target job %d.%d",
					cluster, proc );
			}
			return false;
		}
		// We want files to be copied to their final places, so apply
		// any filename remaps when downloading.
		if ( !ftrans.InitDownloadFilenameRemaps(&job) ) {
			return false;
		}
		if ( use_new_command ) {
			ftrans.setPeerVersion( version() );
		}
		if ( !ftrans.DownloadFiles() ) {
			if( errstack ) {
				FileTransfer::FileTransferInfo ft_info = ftrans.GetInfo();

				int cluster = -1, proc = -1;
				job.LookupInteger(ATTR_CLUSTER_ID,cluster);
				job.LookupInteger(ATTR_PROC_ID,proc);
				errstack->pushf(
					"DCSchedd::receiveJobSandbox",
					FILETRANSFER_DOWNLOAD_FAILED,
					"File transfer failed for target job %d.%d: %s",
					cluster, proc, ft_info.error_desc.Value() );
			}
			return false;
		}
	}	
		
	rsock.end_of_message();

	rsock.encode();

	reply = OK;
	rsock.code(reply);
	rsock.end_of_message();

	if(numdone) { *numdone = JobAdsArrayLen; }

	return true;
}
开发者ID:AmesianX,项目名称:htcondor,代码行数:101,代码来源:dc_schedd.cpp

示例5: hstartd

void
VMRegister::requestHostClassAds(void)
{
	// find host startd daemon
	if( !m_vm_host_daemon )
		m_vm_host_daemon = vmapi_findDaemon( m_vm_host_name, DT_STARTD);

	if( !m_vm_host_daemon ) {
		dprintf( D_FULLDEBUG, "Can't find host(%s) Startd daemon\n", m_vm_host_name );
		return;
	}

	ClassAd query_ad;
	query_ad.SetMyTypeName(QUERY_ADTYPE);
	query_ad.SetTargetTypeName(STARTD_ADTYPE);
	query_ad.Assign(ATTR_REQUIREMENTS, true);

	char *addr = m_vm_host_daemon->addr();
	Daemon hstartd(DT_STARTD, addr);
	ReliSock ssock;

	ssock.timeout( VM_SOCKET_TIMEOUT );
	ssock.encode();

	if( !ssock.connect(addr) ) {
		dprintf( D_FULLDEBUG, "Failed to connect to host startd(%s)\n to get host classAd", addr);
		return;
	}

	if(!hstartd.startCommand( QUERY_STARTD_ADS, &ssock )) {
		dprintf( D_FULLDEBUG, "Failed to send QUERY_STARTD_ADS command to host startd(%s)\n", addr);
		return;
	}

	if( !query_ad.put(ssock) ) {
		dprintf(D_FULLDEBUG, "Failed to send query Ad to host startd(%s)\n", addr);
	}

	if( !ssock.end_of_message() ) {
		dprintf(D_FULLDEBUG, "Failed to send query EOM to host startd(%s)\n", addr);
	}

	// Read host classAds
	ssock.timeout( VM_SOCKET_TIMEOUT );
	ssock.decode();
	int more = 1, num_ads = 0;
	ClassAdList adList;
	ClassAd *ad;

	while (more) {
		if( !ssock.code(more) ) {
			ssock.end_of_message();
			return;
		}

		if(more) {
			ad = new ClassAd;
			if( !ad->initFromStream(ssock) ) {
				ssock.end_of_message();
				delete ad;
				return;
			}

			adList.Insert(ad);
			num_ads++;
		}
	}

	ssock.end_of_message();

	dprintf(D_FULLDEBUG, "Got %d classAds from host\n", num_ads);

	// Although we can get more than one classAd from host machine, 
	// we use only the first one classAd
	adList.Rewind();
	ad = adList.Next();

#if !defined(WANT_OLD_CLASSADS)
	ad->AddTargetRefs( TargetJobAttrs );
#endif

	// Get each Attribute from the classAd
	// added "HOST_" in front of each Attribute name
	const char *name;
	ExprTree *expr;

	ad->ResetExpr();
	while( ad->NextExpr(name, expr) ) {
		MyString attr;
		attr += "HOST_";
		attr += name;

		// Insert or Update an attribute to host_classAd in a VMRegister object
		ExprTree * pTree = expr->Copy();
		host_classad->Insert(attr.Value(), pTree, true);
	}
}
开发者ID:emaste,项目名称:htcondor,代码行数:97,代码来源:VMRegister.cpp


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