Example #1
0
// This is the main component method for interpereters and plugins.
// May als be used in case of invokeable addons
STDMETHODIMP RawComponent::InvokeEx( IMgaProject *project,  IMgaFCO *currentobj,
                  IMgaFCOs *selectedobjs,  long param) {
  // Calling the user's initialization function
  if(CUdmApp::Initialize())
  {
    return S_FALSE;
  }

  CComPtr<IMgaProject>ccpProject(project);
  try
  {
    if(interactive)
    {
    CComBSTR projname;
    CComBSTR focusname = "<nothing>";
    CComPtr<IMgaTerritory> terr;
    COMTHROW(ccpProject->CreateTerritory(NULL, &terr));

    // Setting up Udm
#ifdef _DYNAMIC_META
  #ifdef _DYNAMIC_META_DOM
      // Loading the meta for the project
      UdmDom::DomDataNetwork  ddnMeta(Uml::diagram);
      Uml::Diagram theUmlDiagram;

      // Opening the XML meta of the project
      ddnMeta.OpenExisting(config.metaPath,"uml.xsd", Udm::CHANGES_LOST_DEFAULT);

      // Casting the DataNetwork to diagram
      theUmlDiagram = Uml::Diagram::Cast(ddnMeta.GetRootObject());

      // Creating the UDM diagram
      Udm::UdmDiagram udmDataDiagram;
      udmDataDiagram.dgr = &theUmlDiagram;
      udmDataDiagram.init = dummy;

  #elif defined _DYNAMIC_META_STATIC
      // Loading the meta for the project
      UdmStatic::StaticDataNetwork  dnsMeta(Uml::diagram);
      Uml::Diagram theUmlDiagram;

      // Opening the static meta of the project
      dnsMeta.OpenExisting(config.metaPath, "", Udm::CHANGES_LOST_DEFAULT);

      // Casting the DataNetwork to diagram
      theUmlDiagram = Uml::Diagram::Cast(dnsMeta.GetRootObject());

      // Creating the UDM diagram
      Udm::UdmDiagram udmDataDiagram;
      udmDataDiagram.dgr = &theUmlDiagram;
      udmDataDiagram.init = dummy;

  #else
      ASSERT((0,"Nor _DYNAMIC_META_DOM either _DYNAMIC_META_STATIC defined for dynamic loading"));
  #endif
      // Loading the project
      UdmGme::GmeDataNetwork dngBackend(udmDataDiagram);

#else
    using namespace META_NAMESPACE;

    // Loading the project
    UdmGme::GmeDataNetwork dngBackend(META_NAMESPACE::diagram);

#endif
    try
    {
      // Opening backend
      dngBackend.OpenExisting(ccpProject);


      CComPtr<IMgaFCO> ccpFocus(currentobj);
      Udm::Object currentObject;
      if(ccpFocus)
      {
        currentObject=dngBackend.Gme2Udm(ccpFocus);
      }

      set<Udm::Object> selectedObjects;

      CComPtr<IMgaFCOs> ccpSelObject(selectedobjs);

      MGACOLL_ITERATE(IMgaFCO,ccpSelObject){
        Udm::Object currObj;
        if(MGACOLL_ITER)
        {
          currObj=dngBackend.Gme2Udm(MGACOLL_ITER);
        }
       selectedObjects.insert(currObj);
      }MGACOLL_ITERATE_END;

#ifdef _ACCESS_MEMORY
      // Creating Cache
  #ifdef _DYNAMIC_META
      UdmStatic::StaticDataNetwork dnsCacheBackend(udmDataDiagram);
  #else
      UdmStatic::StaticDataNetwork dnsCacheBackend(META_NAMESPACE::diagram);
  #endif

      const Uml::Class & safeType = Uml::SafeTypeContainer::GetSafeType(dngBackend.GetRootObject().type());

      dnsCacheBackend.CreateNew("","",safeType, Udm::CHANGES_LOST_DEFAULT);

      Udm::Object nullObject(&Udm::__null);
      UdmUtil::copy_assoc_map copyAssocMap;
      copyAssocMap[currentObject]=nullObject; // currentObject may be null object

      for(set<Udm::Object>::iterator p_CurrSelObject=selectedObjects.begin();
        p_CurrSelObject!=selectedObjects.end();p_CurrSelObject++)
      {
          pair<Udm::Object const, Udm::Object> item(*p_CurrSelObject, nullObject);

          pair<UdmUtil::copy_assoc_map::iterator, bool> insRes = copyAssocMap.insert(item);

          if (!insRes.second)
          {
            ASSERT(NULL);
          }

      }

      // Copying from GME to memory
      UdmUtil::CopyObjectHierarchy(
        dngBackend.GetRootObject().__impl(),
        dnsCacheBackend.GetRootObject().__impl(),
        &dnsCacheBackend,
        copyAssocMap);

      // Searching for focus object
      Udm::Object currentObjectCache;
      UdmUtil::copy_assoc_map::iterator currObject = copyAssocMap.find(currentObject);
      if (currObject != copyAssocMap.end()) // It is in the map
      {
        currentObjectCache=currObject->second;
      }


      // Searching for selected objects
      set<Udm::Object> selectedObjectsCache;

      for( p_CurrSelObject=selectedObjects.begin();
        p_CurrSelObject!=selectedObjects.end();p_CurrSelObject++)
      {
        Udm::Object object;
        UdmUtil::copy_assoc_map::iterator currSelObjectIt = copyAssocMap.find(*p_CurrSelObject);
        if (currSelObjectIt != copyAssocMap.end()) // It is in the map
        {
          object=currSelObjectIt->second;
          selectedObjectsCache.insert(object);
        }
      }


      // Closing GME backend
      dngBackend.CloseNoUpdate();

      // Calling the main entry point
      CUdmApp::UdmMain(&dnsCacheBackend,currentObjectCache,selectedObjectsCache,param);
      // Close cache backend
      dnsCacheBackend.CloseNoUpdate();

#else
      // Calling the main entry point
      CUdmApp::UdmMain(&dngBackend,currentObject,selectedObjects,param);
      // Closing backend
      dngBackend.CloseWithUpdate();
#endif

    }
    catch(udm_exception &exc)
    {
#ifdef _META_ACCESS_MEMORY
      dnCacheBackend.CloseNoUpdate();
#endif
      // Close GME Backend (we may close it twice, but GmeDataNetwork handles it)
      dngBackend.CloseNoUpdate();

      AfxMessageBox(exc.what());
      return S_FALSE;
    }
    }
Example #2
0
void CUdmApp::UdmMain(
					 Udm::DataNetwork* p_backend,		// Backend pointer(already open!)
					 Udm::Object focusObject,			// Focus object
					 set<Udm::Object> selectedObjects,	// Selected objects
					 long param,						// Parameters
					 CComPtr<IMgaProject> mgaProject)
{
	/*char currtime[128];
	time_t now = time(0);
	struct tm* tm = localtime(&now);
	sprintf(currtime,"%02d-%02d-%04d  %02d:%02d:%02d", (tm->tm_mon + 1), tm->tm_mday, (tm->tm_year+1900), tm->tm_hour, tm->tm_min, tm->tm_sec);
	std::string ct(currtime);
*/
	std::string start_time = getTimeNow();
	try{
		CyPhyML::RootFolder cyphy_rf = CyPhyML::RootFolder::Cast(p_backend->GetRootObject());
		set<CyPhyML::CWC> cwcs;
		if(	focusObject!=Udm::null 
			&& (Uml::IsDerivedFrom(focusObject.type(), CyPhyML::CWC::meta)))
		{	
			cwcs.insert(CyPhyML::CWC::Cast(focusObject));
		}
		else
		{
			for(set<Udm::Object>::iterator i=selectedObjects.begin();i!=selectedObjects.end();++i)
			{
				Udm::Object currObj = *i;
				if(Uml::IsDerivedFrom(currObj.type(), CyPhyML::CWC::meta))
				{
					cwcs.insert(CyPhyML::CWC::Cast(currObj));					
				}

				// User has selected a Configurations container -- elaborate all CWC within.
				if(Uml::IsDerivedFrom(currObj.type(), CyPhyML::Configurations::meta))
				{
					set<CWC> s_cwc = Configurations::Cast(currObj).CWC_children();
					for (set<CWC>::const_iterator i = s_cwc.begin(); i != s_cwc.end(); i++)
					{
						cwcs.insert(*i);
					}
				}
			}
		}

		if(cwcs.empty()){
			AfxMessageBox(L"Please open a CWC model or select CWC model(s) to invoke the interpreter.");
			return;
		}

		CyPhyML::Configurations cfg_model = (*(cwcs.begin())).Configurations_parent();
		CyPhyML::DesignContainer rootDC = cfg_model.DesignContainer_parent();

		CyPhyML::Configurations cfgModel;
		bool useCurrent = true;
		bool flatten = false;
		std::string outFdr;
		
		// Hide dialog box in silent mode OR if user isn't pressing CTRL
		if (param == GME_SILENT_MODE ||
			!((GetKeyState(VK_CONTROL) & 0x8000)))
		{
			param = GME_SILENT_MODE;
		}
		if (param == GME_SILENT_MODE)
		{
			useCurrent = true;
			flatten = false;
			outFdr = "notused";
		}
		else
		{
			CConfigExportDialog cfgExDlg;
			if (cfgExDlg.DoModal()==IDOK)
			{
				useCurrent = cfgExDlg.m_useCurrent;
				flatten = cfgExDlg.m_flatten;
				outFdr = (LPCSTR)((CStringA)cfgExDlg.m_outputfdr);
			}
			else 
				return;
		}

		int idCnt = cwcs.size();	
		CStatusDialog prgDlg;
		if (param != GME_SILENT_MODE)
		{
			prgDlg.Create(IDD_PROGRESS_DIALOG);
			GetStatusDlg(&prgDlg);
			prgDlg.SetProgress("Preparing to export models...");
		}
		
		if(!useCurrent)
		{
			if (param != GME_SILENT_MODE)
			{
				prgDlg.SetRange(40*idCnt);
			}
			std::string outfileBase = outFdr+"\\"+getFileNameNoExt((LPCSTR)((CStringA)mgaPath));
			for(set<CyPhyML::CWC>::iterator i=cwcs.begin();i!=cwcs.end();++i)
			{
				CyPhyML::CWC cwc = *i;
				std::string outfile = outfileBase+"_"+(std::string)cwc.name()+".mga";					
				std::string msg ="create new CyPhy model for: "+(std::string)cwc.name()+"...";
				if (param != GME_SILENT_MODE)
				{
					prgDlg.SetProgress(CString(msg.c_str()));
				}

				Udm::SmartDataNetwork outDN(CyPhyML::diagram);
				outDN.CreateNew(outfile,"CyPhyML", CyPhyML::RootFolder::meta, Udm::CHANGES_LOST_DEFAULT);
				CyPhyML::RootFolder out_rf = CyPhyML::RootFolder::Cast(outDN.GetRootObject());
				UdmUtil::copy_assoc_map copymap;
				udmCopy(p_backend->GetRootObject().__impl(), outDN.GetRootObject().__impl(),&outDN,copymap,"mga");
			//	UdmUtil::CopyObjectHierarchy(p_backend->GetRootObject().__impl(), outDN.GetRootObject().__impl(), &outDN, copymap);		
				UdmUtil::copy_assoc_map::iterator map_it = copymap.find(cwc);
				ASSERT(map_it!=copymap.end());
				Udm::Object to_cwc_obj = (*map_it).second;
				ASSERT(to_cwc_obj.type() == CyPhyML::CWC::meta);

				if (param != GME_SILENT_MODE)
				{
					prgDlg.SetProgress(CString(msg.c_str()));
				}

				//CyPhyML::Components coms = CyPhyML::Components::Create(out_rf);
				//coms.name() = "Configurations ("+start_time+")";
				CyPhyML::ComponentAssemblies ca_rootFdr = CyPhyML::ComponentAssemblies::Create(out_rf);
				ca_rootFdr.name() = "Generated configurations";
				CyPhyML::ComponentAssemblies ca_folder_dc = CyPhyML::ComponentAssemblies::Create(ca_rootFdr);
				ca_folder_dc.name() = rootDC.name();
				CyPhyML::ComponentAssemblies ca_folder = CyPhyML::ComponentAssemblies::Create(ca_folder_dc);
				ca_folder.name() = "Configurations ("+start_time+")";
				CyPhyCAExporter dexport(ca_folder, CyPhyML::CWC::Cast(to_cwc_obj), flatten);
				dexport.showGui = param != GME_SILENT_MODE;
				dexport.createComponentAssembly();

				//outDN.SaveAs(outfile);
				outDN.CloseWithUpdate();
				
				std::string addlog("CyPhy model \"<A HREF=\""+outfile+ "\">"+outfile+"\"</A> generated for "+appendObjLink(cwc));
				GMEConsole::Console::Out::writeLine(addlog);
			}			
		}
		else
		{
			if (param != GME_SILENT_MODE)
			{
				prgDlg.SetRange(25*idCnt);
			}
			
			set<CyPhyML::ComponentAssemblies>::iterator cafdr_it;
			CyPhyML::ComponentAssemblies ca_rootFdr;
			set<CyPhyML::ComponentAssemblies> ca_fdrs = cyphy_rf.ComponentAssemblies_kind_children();
			for(cafdr_it=ca_fdrs.begin();cafdr_it!=ca_fdrs.end();++cafdr_it)
			{
				CyPhyML::ComponentAssemblies ca_fdr = *cafdr_it;
				if((std::string)ca_fdr.name()=="Generated configurations")
				{
					ca_rootFdr = ca_fdr;
					break;
				}
			}
			if(ca_rootFdr==Udm::null)
			{
				ca_rootFdr = CyPhyML::ComponentAssemblies::Create(cyphy_rf);
				ca_rootFdr.name() = "Generated configurations";
			}
		
			CyPhyML::ComponentAssemblies ca_folder_dc;
			std::string rootDC_name = rootDC.name();
			set<CyPhyML::ComponentAssemblies> ca_fdr_fdrs = ca_rootFdr.ComponentAssemblies_kind_children();
			for(cafdr_it=ca_fdr_fdrs.begin();cafdr_it!=ca_fdr_fdrs.end();++cafdr_it)
			{
				CyPhyML::ComponentAssemblies ca_fdr = *cafdr_it;
				if((std::string)ca_fdr.name()==rootDC_name)
				{
					ca_folder_dc = ca_fdr;
					break;
				}
			}
			if(ca_folder_dc==Udm::null)
			{
				ca_folder_dc = CyPhyML::ComponentAssemblies::Create(ca_rootFdr);
				ca_folder_dc.name() = rootDC_name;
			}

			CyPhyML::ComponentAssemblies ca_folder = CyPhyML::ComponentAssemblies::Create(ca_folder_dc);
			ca_folder.name() = "Configurations ("+start_time+")";

			int txCount = 0;
			for(set<CyPhyML::CWC>::iterator i=cwcs.begin();i!=cwcs.end();++i)
			{
				if (idCnt > 40 && txCount++ == 20)
				{
					txCount = 0;
					COMTHROW(mgaProject->CommitTransaction());
					COMTHROW(mgaProject->FlushUndoQueue());
					CComPtr<IMgaTerritory> terr;
					COMTHROW(mgaProject->BeginTransactionInNewTerr(TRANSACTION_GENERAL, &terr));
				}
				CyPhyML::CWC cwc = *i;
				std::string msg ="create ComponentAssembly for:"+(std::string)cwc.name()+"...";
				if (param != GME_SILENT_MODE)
				{
					prgDlg.SetProgress(CString(msg.c_str()));
				}
				try
				{
					CyPhyCAExporter dexport(ca_folder, cwc, flatten);
					dexport.showGui = param != GME_SILENT_MODE;
					dexport.createComponentAssembly();
					std::string addlog("ComponentAssembly "+appendObjLink(dexport.getComponentAssembly())+"  generated for "+appendObjLink(cwc));
					GMEConsole::Console::Out::writeLine(addlog);

								
//#ifdef _DEBUG
//					std::string end_time = getTimeNow();
//					coms.name() = "Configurations ("+start_time+"-"+end_time+")";
//#else
//					coms.name() = "Configurations ("+start_time+")";
//#endif
				}
				catch(udm_exception &exc)
				{
					ca_folder.DeleteObject();
				//	coms.DeleteObject();
					std::string addlog("ComponentAssembly for "+appendObjLink(cwc)+" has failed: "+(std::string)exc.what());
					GMEConsole::Console::Out::writeLine(addlog);
				}
				catch(...)
				{
					std::string addlog("ComponentAssembly for "+appendObjLink(cwc)+" has failed.");
					GMEConsole::Console::Out::writeLine(addlog);
				}				
			}

		}
		if (param != GME_SILENT_MODE)
		{
			prgDlg.OnFinished();
		}
	}
	catch(udm_exception &exc)
	{
		AfxMessageBox(CString(exc.what()));
		throw exc;
	}
	catch(...)
	{
		throw;
	}
}
Example #3
0
void udmCopy(ObjectImpl *p_srcRoot, ObjectImpl *p_dstRoot, DataNetwork *p_dstBackend, UdmUtil::copy_assoc_map &cam, const string &m_backend_ext, bool inside_lib = false)
{
	vector<ObjectImpl*> children = p_srcRoot->getChildren(NULL, p_srcRoot->type());
	for (vector<ObjectImpl*>::const_iterator i = children.begin(); i != children.end(); i++) 
	{

		ObjectImpl *p_srcChild = *i;

		string lib_name;
		if (!p_srcChild->getLibraryName(lib_name)) {
			p_srcChild->release();
			continue;
		}

		if (lib_name.length() == 0) 
		{ // a library with an empty lib name
			Udm::Object srcChild = p_srcChild->clone();
			lib_name = UdmUtil::ExtractName(srcChild);
			if (lib_name.length() == 0 || lib_name == "<empty string>" || lib_name == "<no name specified>")
				lib_name = "lib";
		}

		// remove file extension if it looks like a
		// backend designation
		if (lib_name.length() > 4 && lib_name[ lib_name.length() - 4 ] == '.')
			lib_name = lib_name.substr(0, lib_name.length() - 4);

		string new_lib_name = lib_name + "." + m_backend_ext;

		//new_lib_name could contain the path which is not exist

		// create datanetwork for standalone library and build map
		// from source object to standalone library object
		Udm::SmartDataNetwork libDN(CyPhyML::diagram);
		const ::Uml::Class & safe_type = ::Uml::SafeTypeContainer::GetSafeType(p_srcChild->type());
		libDN.CreateNew(new_lib_name, "CyPhyML", safe_type, Udm::CHANGES_LOST_DEFAULT);
		Object p_root = libDN.GetRootObject();
		ObjectImpl *p_libRoot = p_root.__impl();

		// copy, including nested libraries
		UdmUtil::copy_assoc_map lib_cam;
		udmCopy(p_srcChild, p_libRoot, &libDN, lib_cam, m_backend_ext, true);
		lib_cam.insert( make_pair(p_srcChild->clone(), p_libRoot->clone()) );
		libDN.SaveAs(new_lib_name);


		// attach library to destination host and build map
		// from standalone library object to private copy object
		// (the map already has a mapping from src root to dst root)
		Udm::t_lib_to_copy_impl_map lib_copy_impl_cam;
		ObjectImpl *p_newLibRoot = p_dstRoot->AttachLibrary(p_libRoot, new_lib_name, &lib_copy_impl_cam);

		// we need a new map with Object elements instead of ObjectImpl* elements
		UdmUtil::copy_assoc_map lib_copy_cam;
		for (Udm::t_lib_to_copy_impl_map::const_iterator i = lib_copy_impl_cam.begin(); i != lib_copy_impl_cam.end(); i++) {
			lib_copy_cam.insert( make_pair(i->first, i->second) );
		}


		// map from source to library private copy
		for (UdmUtil::copy_assoc_map::const_iterator i = lib_cam.begin(); i != lib_cam.end(); i++) {
			UdmUtil::copy_assoc_map::const_iterator fi = lib_copy_cam.find(i->second);
			if (fi == lib_copy_cam.end())
				throw udm_exception("object not found in map");
			cam.insert( make_pair(i->first, fi->second) );
		}

		libDN.CloseNoUpdate();

		cam.insert( make_pair(p_srcChild, p_newLibRoot) );
	}

	UdmUtil::CopyOpts opts = { true, inside_lib };
	UdmUtil::CopyObjectHierarchy(p_srcRoot, p_dstRoot, p_dstBackend, cam, opts);
}
// This is the main component method for interpereters and plugins. 
// May als be used in case of invokeable addons
STDMETHODIMP RawComponent::InvokeEx( IMgaProject *project,  IMgaFCO *currentobj,  
									IMgaFCOs *selectedobjs,  long param) 
{
	CUdmApp udmApp;
	// Calling the user's initialization function
	if(udmApp.Initialize())
	{
		return S_FALSE;
	}

	CComPtr<IMgaProject>ccpProject(project);

	try
	{
		// Setting up the console
		GMEConsole::Console::setupConsole(ccpProject);
		GMEConsole::Console::clear();

		char tmpbuf[128];
		_strdate_s(tmpbuf,128);
		std::string date(tmpbuf);
		_strtime_s(tmpbuf,128);
		std::string time(tmpbuf);

		GMEConsole::Console::writeLine(date + " " + time + " Starting CyPhyElaborate Tester Interpreter", MSG_INFO);


	  if(interactive)
	  {
		CComBSTR projname;
		CComBSTR focusname = "<nothing>";
		CComPtr<IMgaTerritory> terr;
		//COMTHROW(ccpProject->CreateTerritory(NULL, &terr));
		//COMTHROW(ccpProject->BeginTransaction(terr));

		// Setting up Udm
#ifdef _DYNAMIC_META
	#ifdef _DYNAMIC_META_DOM
			// Loading the meta for the project
			UdmDom::DomDataNetwork  ddnMeta(Uml::diagram);
			Uml::Diagram theUmlDiagram;

			// Opening the XML meta of the project
			ddnMeta.OpenExisting(META_PATH,"uml.dtd", Udm::CHANGES_LOST_DEFAULT);

			// Casting the DataNetwork to diagram
			theUmlDiagram = Uml::Diagram::Cast(ddnMeta.GetRootObject());

			// Creating the UDM diagram
			Udm::UdmDiagram udmDataDiagram;
			udmDataDiagram.dgr = &theUmlDiagram;
			udmDataDiagram.init = dummy;

	#elif defined _DYNAMIC_META_STATIC
			// Loading the meta for the project
			Udm::SmartDataNetwork  dnsMeta(Uml::diagram);
			Uml::Diagram theUmlDiagram;

			// Opening the static meta of the project
			dnsMeta.OpenExisting(META_PATH, "", Udm::CHANGES_LOST_DEFAULT);

			// Casting the DataNetwork to diagram
			theUmlDiagram = Uml::Diagram::Cast(dnsMeta.GetRootObject());

			// Creating the UDM diagram
			Udm::UdmDiagram udmDataDiagram;
			udmDataDiagram.dgr = &theUmlDiagram;
			udmDataDiagram.init = dummy;

	#else
			#error "Neither _DYNAMIC_META_DOM or _DYNAMIC_META_STATIC defined for dynamic loading"
	#endif
			// Loading the project
			UdmGme::GmeDataNetwork dngBackend(udmDataDiagram);

#else
		using namespace META_NAMESPACE;

		// Loading the project
		UdmGme::GmeDataNetwork dngBackend(META_NAMESPACE::diagram);

#endif
		try
		{
			long status;
			COMTHROW(ccpProject->get_ProjectStatus(&status));
			if (!(status & 8))
				COMTHROW(ccpProject->BeginTransactionInNewTerr(TRANSACTION_NON_NESTED, &terr));

            try {
            // Opening backend if it is not already opened
            dngBackend.OpenExisting(ccpProject, Udm::CHANGES_LOST_DEFAULT, true);


			CComPtr<IMgaFCO> ccpFocus(currentobj);
			Udm::Object currentObject;
			if(ccpFocus)
			{
				currentObject=dngBackend.Gme2Udm(ccpFocus);
			}

			std::set<Udm::Object> selectedObjects;

			CComPtr<IMgaFCOs> ccpSelObject(selectedobjs);

			MGACOLL_ITERATE(IMgaFCO,ccpSelObject){
				Udm::Object currObj;
				if(MGACOLL_ITER)
				{
					currObj=dngBackend.Gme2Udm(MGACOLL_ITER);
				}
			 selectedObjects.insert(currObj);
			}MGACOLL_ITERATE_END;

#ifdef _ACCESS_MEMORY
			// Creating Cache
	#ifdef _DYNAMIC_META
			Udm::SmartDataNetwork dnsCacheBackend(udmDataDiagram);
	#else
			Udm::SmartDataNetwork dnsCacheBackend(META_NAMESPACE::diagram);
	#endif

			const Uml::Class & safeType = Uml::SafeTypeContainer::GetSafeType(dngBackend.GetRootObject().type());

			dnsCacheBackend.CreateNew("tmp.mem","",safeType, Udm::CHANGES_LOST_DEFAULT);

			Udm::Object nullObject(&Udm::_null);
			UdmUtil::copy_assoc_map copyAssocMap;
			copyAssocMap[currentObject]=nullObject; // currentObject may be null object

			std::set<Udm::Object>::iterator p_CurrSelObject;
			for(p_CurrSelObject=selectedObjects.begin();
				p_CurrSelObject!=selectedObjects.end();p_CurrSelObject++)
			{
					std::pair<Udm::Object const, Udm::Object> item(*p_CurrSelObject, nullObject);

					std::pair<UdmUtil::copy_assoc_map::iterator, bool> insRes = copyAssocMap.insert(item);

					if (!insRes.second)
					{
						assert(false);
					}

			}

			// Copying from GME to memory
			UdmUtil::CopyObjectHierarchy(
				dngBackend.GetRootObject().__impl(),
				dnsCacheBackend.GetRootObject().__impl(),
				&dnsCacheBackend,
				copyAssocMap);

			// Searching for focus object
			Udm::Object currentObjectCache;
			UdmUtil::copy_assoc_map::iterator currObject = copyAssocMap.find(currentObject);
			if (currObject != copyAssocMap.end()) // It is in the map
			{
				currentObjectCache=currObject->second;
			}


			// Searching for selected objects
			std::set<Udm::Object> selectedObjectsCache;

			for( p_CurrSelObject=selectedObjects.begin();
				p_CurrSelObject!=selectedObjects.end();p_CurrSelObject++)
			{
				Udm::Object object;
				UdmUtil::copy_assoc_map::iterator currSelObjectIt = copyAssocMap.find(*p_CurrSelObject);
				if (currSelObjectIt != copyAssocMap.end()) // It is in the map
				{
					object=currSelObjectIt->second;
					selectedObjectsCache.insert(object);
				}
			}


			// Closing GME backend
			dngBackend.CloseNoUpdate();

			// Calling the main entry point
			CUdmApp::UdmMain(&dnsCacheBackend,currentObjectCache,selectedObjectsCache,param);
			// Close cache backend
			dnsCacheBackend.CloseNoUpdate();

#else
			// Calling the main entry point
			udmApp.UdmMain(&dngBackend,currentObject,selectedObjects,param);
			traceability = std::move(udmApp.traceability);
			// Closing backend
			dngBackend.CloseWithUpdate();
			if (!(status & 8))
				ccpProject->CommitTransaction();
			} catch (...) {
				if (!(status & 8))
					ccpProject->AbortTransaction();
				throw;
			}
#endif

		}
		catch(udm_exception &exc)
		{
#ifdef _META_ACCESS_MEMORY
			dnCacheBackend.CloseNoUpdate();
#endif
			// Close GME Backend (we may close it twice, but GmeDataNetwork handles it)
			dngBackend.CloseNoUpdate();
			//COMTHROW(ccpProject->AbortTransaction());

			GMEConsole::Console::Error::writeLine(exc.what());
			return S_FALSE;
		}
	  }