本文整理汇总了C++中udm::Object::type方法的典型用法代码示例。如果您正苦于以下问题:C++ Object::type方法的具体用法?C++ Object::type怎么用?C++ Object::type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类udm::Object
的用法示例。
在下文中一共展示了Object::type方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: 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 "";
}
示例3: 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());
}
}
示例4: 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;
}
示例5: 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 );
}
示例6: 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(""));
}
示例7: 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>");
}
示例8: 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);
}
}
示例9: getNameUmlAttributeMap
std::string UdmComparator::ObjectName::operator()( Udm::Object udmObject ) {
static StringSet reportedClassNameSet;
Uml::Class umlClass = udmObject.type();
Uml::Attribute umlNameAttribute;
UmlClassNameAttributeMap::iterator cnmItr = _umlClassNameAttributeMap.find( umlClass );
if ( cnmItr != _umlClassNameAttributeMap.end() ) {
umlNameAttribute = cnmItr->second;
} else {
NameUmlAttributeMap nameUmlAttributeMap = getNameUmlAttributeMap( umlClass );
NameUmlAttributeMap::iterator numItr = nameUmlAttributeMap.find( "name" );
if ( numItr != nameUmlAttributeMap.end() ) {
umlNameAttribute = numItr->second;
} else {
numItr = nameUmlAttributeMap.find( "Name" );
if ( numItr != nameUmlAttributeMap.end() ) {
umlNameAttribute = numItr->second;
} else if ( static_cast< std::string >( umlClass.stereotype() ) != "Connection" ) {
std::string className = umlClass.name();
if ( reportedClassNameSet.find( className ) == reportedClassNameSet.end() ) {
std::cerr << "WARNING: Class \"" << className << "\" has no \"[Nn]ame\" attribute." << std::endl << std::endl;
reportedClassNameSet.insert( className );
}
return "";
}
}
_umlClassNameAttributeMap.insert( std::make_pair( umlClass, umlNameAttribute ) );
}
std::string udmObjectName = "";
if ( umlNameAttribute != Udm::null ) {
udmObjectName = udmObject.getStringAttr( umlNameAttribute );
if ( umlClass.stereotype() == "Connection" && udmObjectName == static_cast< std::string >( umlClass.name() ) ) {
udmObjectName = "";
}
}
if ( udmObjectName == "" && umlClass.stereotype() == "Connection" ) {
UmlAssociationRoleSet umlAssociationRoleSet = getAllUmlAssociationRoles( umlClass );
for( UmlAssociationRoleSet::iterator arsItr = umlAssociationRoleSet.begin() ; arsItr != umlAssociationRoleSet.end() ; ++arsItr ) {
UdmObjectSet udmObjectSet = udmObject.getAssociation( *arsItr, Udm::TARGETFROMCLASS );
for( UdmObjectSet::iterator uosItr = udmObjectSet.begin() ; uosItr != udmObjectSet.end() ; ++uosItr ) {
if ( !udmObjectName.empty() ) udmObjectName += ":";
udmObjectName += (*this)(*uosItr);
}
}
if ( umlNameAttribute != Udm::null ) {
udmObject.setStringAttr( umlNameAttribute, udmObjectName );
}
}
Udm::Object udmObjectParent = udmObject.GetParent();
if ( udmObjectParent != Udm::null ) {
const auto& it = ObjectNameCache.find(udmObjectParent);
if (it != ObjectNameCache.end())
{
udmObjectName = it->second + "/" + udmObjectName;
}
else
{
udmObjectName = operator()( udmObjectParent ) + "/" + udmObjectName;
}
}
return udmObjectName;
}
示例10: compareNodeAux
bool UdmComparator::compareNodeAux( Udm::Object udmObject1, Udm::Object udmObject2 ) {
bool retval = true;
_udmObjectMap.insert( std::make_pair( udmObject1, udmObject2 ) );
const Uml::Class ¨Class1 = udmObject1.type();
const Uml::Class ¨Class2 = udmObject2.type();
if ( umlClass1 != umlClass2 ) {
std::cerr << "Classes of objects \"" << udmObject1.getPath( "/" ) << "\" and \"" << udmObject2.getPath( "/" ) << "\" do not match!" << std::endl << std::endl;
return false;
}
getObjectNameSingleton().ObjectNameCache.insert(std::make_pair(udmObject1, getObjectNameSingleton()(udmObject1)));
getObjectNameSingleton().ObjectNameCache.insert(std::make_pair(udmObject2, getObjectNameSingleton()(udmObject2)));
UmlAttributeSet umlAttributeSet = _classNameFilter.filterUmlAttributeSet( umlClass1 );
for( UmlAttributeSet::iterator uasItr = umlAttributeSet.begin() ; uasItr != umlAttributeSet.end() ; ++uasItr ) {
Uml::Attribute umlAttribute = *uasItr;
std::string umlAttributeName = umlAttribute.name();
std::string value1, value2;
std::string umlAttributeType = umlAttribute.type();
if ( umlAttributeType == "Boolean" ) {
value1 = boost::lexical_cast< std::string >( udmObject1.getBooleanAttr( umlAttribute ) );
value2 = boost::lexical_cast< std::string >( udmObject2.getBooleanAttr( umlAttribute ) );
} else if ( umlAttributeType == "Integer" ) {
value1 = boost::lexical_cast< std::string >( udmObject1.getIntegerAttr( umlAttribute ) );
value2 = boost::lexical_cast< std::string >( udmObject2.getIntegerAttr( umlAttribute ) );
} else if ( umlAttributeType == "Real" ) {
value1 = boost::lexical_cast< std::string >( udmObject1.getRealAttr( umlAttribute ) );
value2 = boost::lexical_cast< std::string >( udmObject2.getRealAttr( umlAttribute ) );
} else {
value1 = udmObject1.getStringAttr( umlAttribute );
value2 = udmObject2.getStringAttr( umlAttribute );
}
if ( value1 != value2 ) {
Report::get_singleton().incrementDifferences( udmObject1 );
std::cerr << "Value of \"" << umlAttributeName << "\" attribute value differs for \"" << udmObject1.getPath( "/" ) << "\" objects: \"" << value1 << "\" vs. \"" << value2 << "\"" << std::endl << std::endl;
retval = false;
}
}
UdmObjectSet udmObjectSet1 = _classNameFilter.filterUdmObjectSet( udmObject1.GetChildObjects() );
UdmObjectSet udmObjectSet2 = _classNameFilter.filterUdmObjectSet( udmObject2.GetChildObjects() );
if ( udmObjectSet1.size() != udmObjectSet2.size() ) {
std::cerr << "\"" << udmObject1.getPath( "/" ) << "\" objects have a different number of children: " << udmObjectSet1.size() << "," << udmObjectSet2.size() << std::endl << std::endl;
tallyChildrenClasses( udmObjectSet1, udmObjectSet2 );
retval = false;
}
udmObjectSet1 = _classNameFilter.filterConnections( udmObjectSet1 );
udmObjectSet2 = _classNameFilter.filterConnections( udmObjectSet2 );
UdmChildObjectSet udmChildObjectSet1;
udmChildObjectSet1.rehash(udmObjectSet1.size());
std::copy(udmObjectSet1.begin(), udmObjectSet1.end(), std::inserter(udmChildObjectSet1, udmChildObjectSet1.begin()));
if ( udmChildObjectSet1.size() != udmObjectSet1.size() ) {
std::cerr << "Object \"" << udmObject1.getPath( "/" ) << "\" in the first model has children that cannot be distinguished (duplicate name?)." << std::endl << std::endl;
retval = false;
}
UdmChildObjectSet udmChildObjectSet2;
udmChildObjectSet2.rehash(udmObjectSet2.size());
std::copy(udmObjectSet2.begin(), udmObjectSet2.end(), std::inserter(udmChildObjectSet2, udmChildObjectSet2.begin()));
if ( udmChildObjectSet2.size() != udmObjectSet2.size() ) {
std::cerr << "Object \"" << udmObject2.getPath( "/" ) << "\" in the second model has children that cannot be distinguished (duplicate name?)." << std::endl << std::endl;
retval = false;
}
UdmChildObjectSet::iterator ucsItr1 = udmChildObjectSet1.begin();
for (; ucsItr1 != udmChildObjectSet1.end(); ++ucsItr1) {
UdmChildObjectSet::iterator ucsItr2 = udmChildObjectSet2.find(*ucsItr1);
if (ucsItr2 == udmChildObjectSet2.end()) {
std::cerr << "No corresponding object for \"" << ucsItr1->object.getPath( "/" ) << "\" in first model found in second model." << std::endl;
Report::get_singleton().incrementDifferences( udmObject1 );
retval = false;
continue;
}
if (compareNodeAux(ucsItr1->object, ucsItr2->object) == false) {
retval = false;
Report::get_singleton().addToDifferences( udmObject1 );
}
udmChildObjectSet2.erase(ucsItr2);
}
UdmChildObjectSet::iterator ucsItr2 = udmChildObjectSet2.begin();
for (; ucsItr2 != udmChildObjectSet2.end(); ++ucsItr2) {
std::cerr << "No corresponding object for \"" << ucsItr2->object.getPath( "/" ) << "\" in second model found in first model." << std::endl;
Report::get_singleton().incrementDifferences( udmObject1 );
retval = false;
}
// if ( !retval ) return false;
//.........这里部分代码省略.........