void createCWCReference(CyPhyML::DesignContainer &container)
{
	if(container == cfgs_model.parent()) return;

	set<CyPhyML::CWCReference> cwcrefs = container.CWCReference_kind_children();
	for(set<CyPhyML::CWCReference>::iterator i=cwcrefs.begin();i!=cwcrefs.end();++i)
	{
		CyPhyML::Configurations cfgmodels = (*i).ref();
		if(cfgmodels == cfgs_model)
			return;
	}

	string tmp = container.name();
	if(!container.isInstance())
	{
		CyPhyML::CWCReference cwc_ref = CyPhyML::CWCReference::Create(container);
		cwc_ref.name() = "configurations ref";
		cwc_ref.ref() = cfgs_model;
	}
	else
	{
		cfg_model.DeleteObject();
		throw udm_exception((string)container.name()+" cannot be instance model.");
	}
}
void addSelectedEntity(set<CyPhyML::DesignEntity>& allEntities, set<CyPhyML::DesignEntity>* curEntities, const CyPhyML::DesignEntity& selectedCom, const CyPhyML::DesignContainer& parent)
{
	CyPhyML::DesignContainer groupBaseType = parent;
	if(groupBaseType.isInstance() || groupBaseType.isSubtype()) {
		groupBaseType = CyPhyML::DesignContainer::Cast(groupBaseType.Archetype());
		while(groupBaseType.isInstance() || groupBaseType.isSubtype()) {
			groupBaseType = CyPhyML::DesignContainer::Cast(groupBaseType.Archetype());
		}
	}
	curEntities->insert(groupBaseType);
	allEntities.insert(groupBaseType);
	set<CyPhyML::DesignEntity> rootChildren = groupBaseType.DesignEntity_kind_children();
	for(set<CyPhyML::DesignEntity>::iterator rootChIt = rootChildren.begin(); rootChIt != rootChildren.end(); ++rootChIt) {
		CyPhyML::DesignEntity rootChild = *rootChIt;
		if(componentFollowsFromInTypeInstanceHierarchy(selectedCom, rootChild)) {
			curEntities->insert(rootChild);
			allEntities.insert(rootChild);
		}
	}
}