• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ udm::Object类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中udm::Object的典型用法代码示例。如果您正苦于以下问题:C++ Object类的具体用法?C++ Object怎么用?C++ Object使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: elaborate

bool __stdcall elaborate(IUnknown* currentObj)
{
	try {
		CComPtr<IMgaFCO> fcoCurrentObj;
		currentObj->QueryInterface(&fcoCurrentObj);
		if (fcoCurrentObj)
		{
			CComPtr<IMgaProject> project;
			if (SUCCEEDED(fcoCurrentObj->get_Project(&project)))
			{
				UdmGme::GmeDataNetwork dn(CyPhyML::diagram);
				dn.OpenExisting(project, Udm::CHANGES_LOST_DEFAULT, true);
				Udm::Object current = dn.Gme2Udm(fcoCurrentObj);

				CyPhyElaborate cpe;
				if (current.type() == ComponentAssembly::meta) {
					cpe.elaborate( CyPhyML::ComponentAssembly::Cast(current) );
					return true;
				} else if (current.type() == TestBench::meta) {
					cpe.elaborate( CyPhyML::TestBench::Cast(current) );
					return true;
				}
			}
		}
	} catch (udm_exception& e) {
		return false;
	}
	return false;
}
开发者ID:dyao-vu,项目名称:meta-core,代码行数:29,代码来源:UdmApp.cpp


示例2: SwitchReference

void CyPhyElaborate::SwitchReference(CyPhyML::TestBenchType tb)
{
	set<Udm::Object> bTargets = tb.GetChildObjects(CHILD_CLASS::meta);
	for (auto bTargetIt = bTargets.begin(); bTargetIt != bTargets.end(); bTargetIt++)
	{
		CHILD_CLASS bTarget = CHILD_CLASS::Cast(*bTargetIt);
		//Udm::Object bTargetCopy = btb.__impl()->createChild(Udm::NULLCHILDROLE, *referenceMeta);
		CHILD_CLASS bTargetCopy = CHILD_CLASS::Create(tb);

		TIPRefBase base;
		auto copyIt = originalObjectToCopies.find(bTarget.ref());
		if (copyIt == originalObjectToCopies.end())
		{
			throw udm_exception("Bug: could not find BallisticTarget copy");
		}
		while (copyIt != originalObjectToCopies.end())
		{
			base = TIPRefBase::Cast(copyIt->second);
			copyIt = originalObjectToCopies.find(base);
		}
		bTargetCopy.ref() = TIPRefBase::Cast(base);
		bTargetCopy.__impl()->CopyAttributesFrom(bTarget.__impl());

		// Debugging
		// std::string d1 = bTarget.getPath("/");
		// std::string d2 = bTargetCopy.getPath("/");
		//std::string d3 = TIPRefBase::Cast(base).getPath("/");
		// std::string target_type = static_cast<Udm::Object>(bTarget.ref()).type().name();
		// OutputDebugStringA("\n\n");
		// for (auto it = originalObjectToCopies.begin(); it != originalObjectToCopies.end(); ++it)
		// {
		// 	OutputDebugStringA((UdmUtil::ExtractName(it->first) + "\t" + UdmGme::UdmId2GmeId(it->first) + "\t" + UdmUtil::ExtractName(it->second) + "\n").c_str());
		// }

		SwitchConnections(bTarget, bTargetCopy, Udm::null, bTarget.GetParent());
		Udm::Object eventualTarget = bTarget;
		while (!!getReferredOrNull(eventualTarget))
		{
			eventualTarget = getReferredOrNull(eventualTarget);
		}
		// std::string d4 = eventualTarget.getPath("/");
		// std::string d5 = eventualTarget.type().name();
		// std::string d6 = getReferredOrNull(bTargetCopy).getPath("/");
		// std::string d22 = UdmGme::UdmId2GmeId(bTargetCopy.uniqueId());
		// std::string d22ref = UdmGme::UdmId2GmeId(Udm::Object(bTargetCopy.ref()).uniqueId());
		
		if (!!eventualTarget && Uml::IsDerivedFrom(eventualTarget.type(), CyPhyML::Component::meta))
			// Components are created as instances, so the RelIDs are the same
			SwitchRefportConnections(bTarget, bTargetCopy, map<Udm::Object, Udm::Object>(), *dynamic_cast<UdmGme::GmeDataNetwork*>(bTarget.__impl()->__getdn()));
		else
			// ComponentAssemblys are created with CopyObjectHierarchy, so the originalObjectToCopies map is correct
			SwitchRefportConnections(bTarget, bTargetCopy, originalObjectToCopies, *dynamic_cast<UdmGme::GmeDataNetwork*>(bTarget.__impl()->__getdn()));
		bTarget.DeleteObject();
		//bTarget.name() = std::string(bTarget.name()) + "tobedeleted";
		//std::string d7 = getReferredOrNull(bTargetCopy).getPath("/");
		//std::string d6_2 = getReferredOrNull(bTargetCopy).getPath("/");
		//std::string d22_2 = UdmGme::UdmId2GmeId(bTargetCopy.uniqueId());
		//std::string d22ref_2 = UdmGme::UdmId2GmeId(Udm::Object(bTargetCopy.ref()).uniqueId());
	}
}
开发者ID:pombredanne,项目名称:metamorphosys-desktop,代码行数:60,代码来源:CyPhyElaborate.cpp


示例3: getTopArchetype

Udm::Object SFUtils::getTopArchetype( Udm::Object object ) {
    if ( object == Udm::null ) return object;

    Udm::Object archetype = object.archetype();
    while( archetype != Udm::null ) {
        object = archetype;
        archetype = object.archetype();
    }
    return object;
}
开发者ID:pombredanne,项目名称:metamorphosys-desktop,代码行数:10,代码来源:utils.cpp


示例4: getContainingFunctionScope

std::string SFManager::getContainingFunctionScope( Udm::Object object ) {

	while(  !Udm::IsDerivedFrom( object.type(), SFC::Program::meta )  ) {
		if (  Udm::IsDerivedFrom( object.type(), SFC::Function::meta )  ) {
			return SFC::Function::Cast( object ).scope();
		}

		object = object.GetParent();
	}

	return "";
}
开发者ID:pombreda,项目名称:metamorphosys-desktop,代码行数:12,代码来源:SFManager.cpp


示例5: getTopLevelInstance

Udm::Object SFUtils::getTopLevelInstance( Udm::Object object ) {
    if ( object == Udm::null ) return Udm::null;

    Udm::Object parent = object.GetParent();

    Udm::Object archetype = parent.archetype();
    while( archetype != Udm::null ) {
        if (  ( object = object.archetype() ) == Udm::null  ) return Udm::null;
        parent = archetype;
        archetype = parent.archetype();
    }
    return object;
}
开发者ID:pombredanne,项目名称:metamorphosys-desktop,代码行数:13,代码来源:utils.cpp


示例6: getStateAncestors

	static StateVector getStateAncestors( SLSF::State state ) {
		StateVector stateVector;
		stateVector.push_back( state );

		Udm::Object object = state.GetParent();
		while( object.type() == SLSF::State::meta ) {
			state = SLSF::State::Cast( object );
			stateVector.push_back( state );
			object = state.GetParent();
		}

		return stateVector;
	}
开发者ID:pombreda,项目名称:metamorphosys-desktop,代码行数:13,代码来源:SFManager.hpp


示例7: initVar

void SFManager::initVar( SFC::CompoundStatement compoundStatement, SFC::Var var ) {
	Udm::Object object = Udm::Object::Cast( var );
	if ( object.type() != SFC::LocalVar::meta ) return;
	SFC::LocalVar localVar = SFC::LocalVar::Cast( var );

	SFC::DT dt = localVar.dt();
	std::string name = localVar.name();
	if ( dt.type() == SFC::Struct::meta ) {
		initVarAux( compoundStatement, localVar, name );
		return;
	}

	std::string initial = localVar.initial();
	if ( initial.empty() ) initial = "0";
	::mstat2SFC( compoundStatement, name + " = " + initial, true, true );
}
开发者ID:pombreda,项目名称:metamorphosys-desktop,代码行数:16,代码来源:SFManager.cpp


示例8:

CComPtr<IMgaFCO> Udm2MgaFCO(Udm::Object& o)
{
	o.isLibObject(); // will throw if o is Udm::null
	CComPtr<IUnknown> pUnk;
	pUnk.Attach(UdmGme::Udm2Gme(o));
	CComQIPtr<IMgaFCO> pFCO = pUnk;
	return pFCO.p;
}
开发者ID:pombredanne,项目名称:metamorphosys-desktop,代码行数:8,代码来源:CyPhyElaborate.cpp


示例9: Visit_OS

void ElementVisitor::Visit_OS( const ESMoL::OS & os ) {

	// STRONG ASSUMPTION -- we have already visited the parent and created a semantics entry for it.
	Udm::Object obj = os.parent();
	Semantics::Node sNode = IndexKeeper::Inst()->Lookup< Semantics::Node >( obj.uniqueId() );
	//get os specific values
	std::string str;		
	try {
		str = os.TickResolution();
		sNode.tickresolutionsecs() = TimeStr2secs( str );
	}
	catch ( ConversionErr &err ) {
		std::cout << _contextTracker.GetContext() << " Node resolution :" << err._what << std::endl;
	}
	try {
		str = os.ContextSwitchTime();
		sNode.ctxtswitchsecs() = TimeStr2secs(str);
	}
	catch ( ConversionErr &err ) {
		std::cout << _contextTracker.GetContext() << " Node context switch time :" << err._what << std::endl;
	}
	try {
		str = os.ISROverheadTime();
		sNode.isrohdsecs() = TimeStr2secs(str);
	}
	catch ( ConversionErr &err ) {
		std::cout << _contextTracker.GetContext() << " ISR overhead time :" << err._what << std::endl;
	}
	try {
		str = os.SendOverheadTime();
		sNode.sndohdsecs() = TimeStr2secs(str);
	}
	catch ( ConversionErr &err ) {
		std::cout << _contextTracker.GetContext() << " Node send overhead :" << err._what << std::endl;
	}
	try {
		str = os.RecvOverheadTime();
		sNode.rcvohdsecs() = TimeStr2secs(str);
	}
	catch ( ConversionErr &err ) {
		std::cout << _contextTracker.GetContext() << " Node receive overhead :" << err._what << std::endl;
	}

	sNode.maxtasknum() = os.MaxTaskNumber();
	sNode.schedalgorithm() = os.SchedulingAlgorithm();
}
开发者ID:pombreda,项目名称:metamorphosys-desktop,代码行数:46,代码来源:ElementVisitor.cpp


示例10: getAllInstanceEquivalent

SFUtils::ObjectSet SFUtils::getAllInstanceEquivalent( Udm::Object object ) {

	Udm::Object archetype = getTopArchetype( object );
	if ( archetype == Udm::null ) return ObjectSet();

	ObjectList objectList;
	/*objectList.push_back( archetype );
	for( ObjectList::iterator oblItr = objectList.begin() ; oblItr != objectList.end() ; (void)++oblItr ) {*/
		ObjectSet objectSet =archetype.instances();
		for(ObjectSet::iterator obj_it=objectSet.begin();obj_it!=objectSet.end();++obj_it)
		{
			if(isFromSameSignalFlowModel(*obj_it))
				objectList.push_back(*obj_it);
		}
//		objectList.insert( objectList.end(), objectSet.begin(), objectSet.end() );
	//}
	return ObjectSet( objectList.begin(), objectList.end() );
}
开发者ID:pombredanne,项目名称:metamorphosys-desktop,代码行数:18,代码来源:utils.cpp


示例11: copyDataflows

void copyDataflows( ESMoL::ModelsFolder inputModelsFolder, ESMoL::ModelsFolder outputModelsFolder ) {

	getPortList().clear();
	getPortMap().clear();

	DataflowVector dataflowVector = inputModelsFolder.Dataflow_kind_children();
	for( DataflowVector::iterator dfvItr = dataflowVector.begin() ; dfvItr != dataflowVector.end() ; ++dfvItr ) {
		ESMoL::Dataflow inputDataflow = *dfvItr;
		ESMoL::Dataflow outputDataflow = ESMoL::Dataflow::Create( outputModelsFolder );
		outputDataflow.name() = inputDataflow.name();
		copySubsystems_flatten( inputDataflow, outputDataflow );
	}

	for( PortList::iterator ptlItr = getPortList().begin() ; ptlItr != getPortList().end() ; ++ptlItr ) {

		ESMoL::Port inputDstPort = *ptlItr;

		LineSet lineSet = inputDstPort.srcLine();
		if ( lineSet.empty() ) continue;
		ESMoL::Line line = *lineSet.begin();
		ESMoL::Port inputSrcPort = line.srcLine_end();
		lineSet = inputSrcPort.srcLine();
		while( getPortMap().find( inputSrcPort ) == getPortMap().end() && !lineSet.empty() ) {
			line = *lineSet.begin();
			inputSrcPort = line.srcLine_end();
			lineSet = inputSrcPort.srcLine();
		}

		PortMap::iterator ptmItr = getPortMap().find( inputDstPort );
		if ( ptmItr == getPortMap().end() ) {
			std::cerr << "Warning: port not in PortMap" << std::endl;
			continue;
		}
		ESMoL::Port outputDstPort = ptmItr->second;

		ptmItr = getPortMap().find( inputSrcPort );
		if ( ptmItr == getPortMap().end() ) {
			std::cerr << "Warning: port not in PortMap" << std::endl;
			continue;
		}
		ESMoL::Port outputSrcPort = ptmItr->second;

		Udm::Object lineParent = outputSrcPort.GetParent();
		if (  Udm::IsDerivedFrom( outputSrcPort.type(), ESMoL::OutPort::meta )  ) lineParent = lineParent.GetParent();

		ESMoL::Line outputLine = ESMoL::Line::Create( lineParent );
		outputLine.srcLine_end() = outputSrcPort;
		outputLine.dstLine_end() = outputDstPort;
	}
}
开发者ID:pombreda,项目名称:metamorphosys-desktop,代码行数:50,代码来源:esmolflatten.cpp


示例12:

//
// Visit_PackageFile_i
//
void Stub_Generator::
Visit_PackageFile_i  (const Udm::Object & obj)
{
  // Gather all the necessary elements.
  std::set <CHAOS::Event> events = Udm::ChildrenAttr <CHAOS::Event> (obj.__impl (), Udm::NULLCHILDROLE);
  for (auto event : events)
    event.Accept (*this);

  // Write the output stream generators.
  std::set <CHAOS::Aggregate> aggrs = Udm::ChildrenAttr <CHAOS::Aggregate> (obj.__impl (), Udm::NULLCHILDROLE);
  for (auto aggr : aggrs)
    aggr.Accept (*this);

  std::set <CHAOS::Collection> colls = Udm::ChildrenAttr <CHAOS::Collection> (obj.__impl (), Udm::NULLCHILDROLE);
  for (auto coll : colls)
    coll.Accept (*this);

  std::set <CHAOS::Package> packages =
    Udm::ChildrenAttr <CHAOS::Package> (obj.__impl (), Udm::NULLCHILDROLE);

  for (auto package : packages)
    package.Accept (*this);
}
开发者ID:SEDS,项目名称:CUTS,代码行数:26,代码来源:Stub_Generator.cpp


示例13: Visit_PackageFile_i

  void Visit_PackageFile_i (const Udm::Object & obj)
  {
    // Visit all the packages.
    std::vector <CHAOS::Package> packages =
      Udm::ChildrenAttr <CHAOS::Package> (obj.__impl (), Udm::NULLCHILDROLE);

    for (auto package : packages)
      package.Accept (*this);

    // Does this level contain any events.
    std::vector <CHAOS::Event> events =
      Udm::ChildrenAttr <CHAOS::Event> (obj.__impl (), Udm::NULLCHILDROLE);

    if (!events.empty () && !this->has_events_)
      this->has_events_ = true;

    // Visit all the components.
    std::vector <CHAOS::Component> components =
      Udm::ChildrenAttr <CHAOS::Component> (obj.__impl (), Udm::NULLCHILDROLE);

    for (auto component : components)
      component.Accept (*this);
  }
开发者ID:SEDS,项目名称:CUTS,代码行数:23,代码来源:Stub_Generator.cpp


示例14: osg

//
// Visit_PackageFile_i
//
void CUTS_BE_TCPIP_Stub_Source_Generator::
Visit_PackageFile_i  (const Udm::Object & obj)
{
  CUTS_BE_TCPIP::Output_Stream_Source_Generator osg (this->outfile_);
  CUTS_BE_TCPIP::Input_Stream_Source_Generator isg (this->outfile_);

  // Gather all the necessary elements.
  std::set <CHAOS::Event> events = Udm::ChildrenAttr <CHAOS::Event> (obj.__impl (), Udm::NULLCHILDROLE);
  std::set <CHAOS::Aggregate> aggrs = Udm::ChildrenAttr <CHAOS::Aggregate> (obj.__impl (), Udm::NULLCHILDROLE);
  std::set <CHAOS::Collection> colls = Udm::ChildrenAttr <CHAOS::Collection> (obj.__impl (), Udm::NULLCHILDROLE);

  // Write the output stream generators.
  for (auto aggr : aggrs)
    aggr.Accept (osg);

  for (auto event : events)
    event.Accept (osg);

  for (auto coll : colls)
    coll.Accept (osg);

  // Write the input stream generators.
  for (auto aggr : aggrs)
    aggr.Accept (isg);

  for (auto event : events)
    event.Accept (isg);

  for (auto coll : colls)
    coll.Accept (isg);

  std::set <CHAOS::Package> packages =
    Udm::ChildrenAttr <CHAOS::Package> (obj.__impl (), Udm::NULLCHILDROLE);

  for (auto package : packages)
    package.Accept (*this);
}
开发者ID:SEDS,项目名称:CUTS,代码行数:40,代码来源:Stub_Source_Generator.cpp


示例15: extractPortType

CString ModelHandler::extractPortType(Udm::Object portObj)
{
	// whenever the connected port found is derived from DataPort then extract type from the enum attribute of the dstPort
	if(Udm::IsDerivedFrom(portObj.type(), SignalFlow::DataPort::meta))
	{
		return CString(((string) SignalFlow::DataPort::Cast(portObj).DataType()).c_str()).Trim();
	}
	// whenever the connected Port is derived from SF_Port then find the contained TypeRef Port to get the type
	else if(Udm::IsDerivedFrom(portObj.type(), Simulink::SF_Port::meta) ||
			Udm::IsDerivedFrom(portObj.type(), Simulink::SFStateDE::meta) ||
			Udm::IsDerivedFrom(portObj.type(), Simulink::StateDE::meta)
		)
	{
		// find type from the contained type ref
		set<Udm::Object> typerefSet = portObj.GetChildObjects(Simulink::TypeBaseRef::meta);
		// a port can have only a single type
		if(typerefSet.size() == 1)
		{
			Simulink::TypeBaseRef typeBaseRef = Simulink::TypeBaseRef::Cast(*(typerefSet.begin()));
			try
			{
				return CString(((string) Simulink::SF_Matrix::Cast(typeBaseRef.getReferencedObject()).Type()).c_str()).Trim();
			} catch(udm_exception e)
			{
				throw udm_exception(_T("Simulink::TypeBaseRef is currently allowed to refer to objects of only Simulink::SF_Matrix type! @[OBJECT:]") +
									MyUdmUtil::getHyperLinkPath_StdString(typeBaseRef));
			}
		}
		else if(typerefSet.size() > 1)
		{
			throw udm_exception(MyUdmUtil::getHyperLinkPath_StdString(portObj) + _T(" contains more than 1 Simulink::TypeBaseRef type objects. "));
		}
	}
	// the portObj is an InputSignalInterface of a ModelicaComponent
	else if(portObj.type().name() == "InputSignalInterface")
	{
		return CString(((string) InputSignalInterface::Cast(portObj).Class()).c_str()).Trim();
	}
	// the portObj is an OutputSignalInterface of a ModelicaComponent
	else if(portObj.type().name() == "OutputSignalInterface")
	{
		return CString(((string) OutputSignalInterface::Cast(portObj).Class()).c_str()).Trim();
	}
	// the portObj is a ParameterRef of a ModelicaComponent
	else if(portObj.type().name() == "ParameterRef")
	{
		return CString(((string) ParameterRef::Cast(portObj).Class()).c_str()).Trim();
	}

	return CString(_T(""));
}
开发者ID:pombredanne,项目名称:metamorphosys-desktop,代码行数:51,代码来源:ModelHandler.cpp


示例16: ExtractName

string CUdmApp::ExtractName(Udm::Object ob)
{
	Uml::Class cls= ob.type();				
	set<Uml::Attribute> attrs=cls.attributes();		
	
	// Adding parent attributes
	set<Uml::Attribute> aattrs=Uml::AncestorAttributes(cls);
	attrs.insert(aattrs.begin(),aattrs.end());

	for(set<Uml::Attribute>::iterator ai = attrs.begin();ai != attrs.end(); ai++)
	{
		if(string(ai->type())=="String")
		{
			string str=ai->name();
			if(str=="name")
			{
				string value=ob.getStringAttr(*ai);
				if(value.empty())value="<empty string>";
				return value;
			}			
		}				
	}	
	return string("<no name specified>");
}
开发者ID:DOCGroup,项目名称:CoSMIC,代码行数:24,代码来源:UdmApp.cpp


示例17: isFromSameSignalFlowModel

bool SFUtils::isFromSameSignalFlowModel(Udm::Object obj)
{
	Udm::Object obj_parent = obj.GetParent();
	while(obj_parent.type()!=SLSF_ROOT::RootFolder::meta)
	{
		if(obj_parent.type()==SLSF_ROOT::SimulinkWrapper::meta)
		{
			SLSF_ROOT::SimulinkWrapper sfmodel = SLSF_ROOT::SimulinkWrapper::Cast(obj_parent);
			if(sfmodel==rootSFModel) 
				return true;
			else
				return false;
		}
		obj_parent = obj_parent.GetParent();
	}
	return false;
}
开发者ID:pombredanne,项目名称:metamorphosys-desktop,代码行数:17,代码来源:utils.cpp


示例18: MakeObjectHyperlink

	std::string Formatter::MakeObjectHyperlink(const std::string & text, const Udm::Object& object)
	{
		ostringstream ostr;
		ostr <<"<a href=\"mga:" << UdmGme::UdmId2GmeId(object.uniqueId()) << "\">" << text << "</a>";
		return ostr.str();
	}
开发者ID:pombredanne,项目名称:metamorphosys-desktop,代码行数:6,代码来源:UdmFormatter.cpp


示例19: expand

ComponentAssembly CyPhyElaborate::expand(const ComponentAssembly& ca, string ID_Prefix, std::set<Udm::Object> expandedInThisStack) {
	log("expand(CA)",ca.getPath());
	expandedInThisStack.insert(ca);

	set<ComponentAssembly> caKids = ca.ComponentAssembly_kind_children();
	for (set<ComponentAssembly>::const_iterator i = caKids.begin(); i != caKids.end(); i++) {
		if (i->isSubtype() || i->isInstance())
		{
			DetachFromArchetype(*i);
		}
		expand(*i, "", expandedInThisStack);
	}
	
	set<ComponentRef> crToElaborate = ca.ComponentRef_kind_children();
	// For each of these, replace the reference with an instance. Then replicate all connections.
	for (set<ComponentRef>::const_iterator i = crToElaborate.begin(); i != crToElaborate.end(); i++) {
		ComponentRef cri(*i);
		ComponentAssembly parent = cri.ComponentAssembly_parent();
		
		DesignElement cType = DesignElement::Cast(cri.ref());
		
		if (cType != Udm::null)
		{
			DesignElement instance;
			if (cType.type() == Component::meta)
			{
				instance = Component::Cast(cType).CreateInstance(parent);
				// traceability: save this component
				addCopy(instance, cType);
				addCopy(instance, cri);
				
				// Copy InstanceGUID
				string newInstanceGUID = ID_Prefix;
				newInstanceGUID.append(cri.InstanceGUID());
				(Component::Cast(instance)).InstanceGUID() = newInstanceGUID;

				set<Object> children = instance.GetChildObjects();
				for (auto childIt = children.begin(); childIt != children.end(); childIt++)
				{
					// traceability: save all child objects of a component
					addCopy(*childIt, (*childIt).archetype());
					addAllObjectsToTraceability(*childIt);

					SwitchConnections(childIt->archetype(), *childIt, cri, ca);
				}
				// TODO: cannot test this, since connections of this type is not possible
				SwitchConnections(cri, instance, Udm::null, parent);

				// DY: 9/9/11 - copy registry value from ref to instance
				this->copyCADPropertyRegistry2Inst(cri, CyPhyML::Component::Cast(instance));
			}
			else if (expandedInThisStack.find(cType) == expandedInThisStack.end())
			{
				map<Object, Object> cam;
				deque<Object> queue;
				queue.push_back(cType);
				while (queue.size() > 0)
				{
					Object o = queue.front();
					queue.pop_front();
                    Udm::Object referred = getReferredOrNull(o);
					if (referred)
					{
						set<Object> refCompChildren = referred.GetChildObjects();
						for_each(refCompChildren.begin(), refCompChildren.end(), [&](const Object& o) { cam[o] = o; });
					}
					set<Object> qChildren = o.GetChildObjects();
					std::copy(qChildren.begin(), qChildren.end(), back_inserter(queue));
				}
				// instance = ComponentAssembly::Create(parent);
				instance = DesignElement::Cast(parent.CreateObject(cType.type()));
				UdmUtil::CopyObjectHierarchy(cType.__impl(), instance.__impl(), parent.__impl()->__getdn(), cam);

				set<Object> children = cType.GetChildObjects();
				for (auto childIt = children.begin(); childIt != children.end(); childIt++)
				{
					auto to = cam.find(*childIt);
					if (to == cam.end())
						throw udm_exception();
					//if (_ExtractName(to->second) != _ExtractName(*childIt))
					//	throw udm_exception();
					SwitchConnections(*childIt, to->second, cri, parent);
				}
				addCopies(cam);
				// TODO: cannot test this, since connections of this type is not possible
				//SwitchConnections(cri, instance, Udm::null, parent);				
				expand(ComponentAssembly::Cast(instance), ID_Prefix + static_cast<std::string>(cri.InstanceGUID()), expandedInThisStack);
			} else {
				throw udm_exception(std::string("ComponentAssembly '") + static_cast<std::string>(cType.name())
					+ "' cannot contain a ComponentRef to itself");
			}
			instance.name() = cri.name();
			// Copy layout information as well.
			string pos = cri.position();
			if (pos == "")
				instance.position() = "0,0";
			else
				instance.position() = pos;

			// If "ID" is non-zero, copy it too.
//.........这里部分代码省略.........
开发者ID:pombredanne,项目名称:metamorphosys-desktop,代码行数:101,代码来源:CyPhyElaborate.cpp


示例20: UdmMain

void CUdmApp::UdmMain(
					 Udm::DataNetwork* p_backend,		// Backend pointer(already open!)
					 Udm::Object focusObject,			// Focus object
					 std::set<Udm::Object> selectedObjects,	// Selected objects
					 long param)						// Parameters
{	

	// TODO: Your Code Comes Here...

	try
	{
		if (param == 128)
		{
			automated_expand = true;
			ConsoleMessagesOn = false;
		}
		set<Udm::Object> mySet;
		if (focusObject) {
			mySet.insert(focusObject);
		} else {
			for (set<Udm::Object>::const_iterator i = selectedObjects.begin(); i != selectedObjects.end(); i++)
				mySet.insert(*i);
		}

		bool expand = automated_expand;
		bool collapse = automated_collapse;
		if (!automated_expand && !automated_collapse) {
			int result = IDYES; // collapse is broken MessageBoxA(NULL, "Yes to expand, No to collapse", "Operation", MB_YESNO);
			if (result == IDYES)
				expand = true;
			else if (result == IDNO)
				collapse = true;
		}
		
		CyPhyElaborate cpe;

		for (std::set<Udm::Object>::const_iterator i = mySet.begin(); i != mySet.end(); i++) {
			Udm::Object oi(*i);

			if (oi.type() == ComponentAssembly::meta) {
				if (expand)
				{
					cpe.elaborate( CyPhyML::ComponentAssembly::Cast(oi) );
					for (set<Udm::Object>::const_iterator j = cpe.cr_null_ref_set.begin(); j != cpe.cr_null_ref_set.end(); j++)
						GMEConsole::Console::writeLine("ComponentRef [" + (string)(CyPhyML::ComponentRef::Cast(*j).name()) + "] is null!" , MSG_WARNING);
				}
				else if (collapse)
					; // cpe.collapse( CyPhyML::ComponentAssembly::Cast(oi) );
			} else if (Udm::IsDerivedFrom(focusObject.type(), TestBenchType::meta)) {
				if (expand)
				{
					cpe.elaborate(TestBenchType::Cast(oi));
				}
				else if (collapse)
				{
					; // cpe.collapse(TestBenchType::Cast(oi));
				}
			}
		}
		traceability.Attach(new CyPhyElaborateTraceability(std::unique_ptr<std::map<Udm::Object, Udm::Object> >(std::move(cpe.copiedObjectsToOriginals))));
	}
	catch (udm_exception &exc)
	{
		GMEConsole::Console::writeLine("Udm exception occured! Exception description: " + (std::string)exc.what(), MSG_ERROR);
        msg_exception = exc.what();
        throw exc;
	}
	catch (...)
	{
		GMEConsole::Console::writeLine("Non-Udm exception occured.", MSG_ERROR);
	}
}
开发者ID:dyao-vu,项目名称:meta-core,代码行数:72,代码来源:UdmApp.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ udp::endpoint类代码示例发布时间:2022-05-31
下一篇:
C++ ublas::vector类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap