示例#1
0
bool CreateDesertConstraintSet(ConstraintSet &cs, UdmDesertMap &des_map, DesertUdmMap &inv_des_map )
{
	bool ret = true;
	Constraint ct;
	Element owner;
	long cts_id;
	set<Constraint> ct_set = cs.Constraint_children();
	set<Constraint>::iterator ct_iterator;

	ASSERT(!ct_set.empty());
	//create constraint set
	cts_id = CreateConstraintSet(utf82cstring((string)cs.name()));
	DoMap(cs, des_map, inv_des_map, cts_id);


	for(ct_iterator = ct_set.begin(); ct_iterator != ct_set.end(); ct_iterator++)
	{
		//get owner element
		ct = *(ct_iterator);
		owner = ct.context();
		std::string aa = owner.name();
		
		//lookup in the map 
		long owner_id = GetID(owner, des_map);

		//create constraint
		
		long ct_id = CreateConstraint(utf82cstring((string)ct.name()),
						cts_id, 
						owner_id, 
						utf82cstring((string)ct.expression()));
		/*
		long ct_id = CreateConstraint(((string)ct.name()).c_str(), 
						cts_id, 
						owner_id, 
						((string)ct.expression()).c_str(),
						ct.id(),
						ct.externalID());
		*/
		if(ct_id==-1) ret = false;
		DoMap(ct, des_map, inv_des_map,  ct_id);

	}//eo for (ct_iterator)
	return ret;
};//eo bool CreateDesertConstrainSet