本文整理汇总了C++中udm::Object::getAssociation方法的典型用法代码示例。如果您正苦于以下问题:C++ Object::getAssociation方法的具体用法?C++ Object::getAssociation怎么用?C++ Object::getAssociation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类udm::Object
的用法示例。
在下文中一共展示了Object::getAssociation方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: compareNodeAux
//.........这里部分代码省略.........
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;
UmlAssociationRoleSet umlAssociationRoleSet = getAllUmlAssociationRoles( umlClass1 );
for( UmlAssociationRoleSet::iterator arsItr = umlAssociationRoleSet.begin() ; arsItr != umlAssociationRoleSet.end() ; ++arsItr ) {
Uml::AssociationRole umlAssociationRole = *arsItr;
UdmObjectSet udmObjectSet1 = _classNameFilter.filterUdmObjectSet( udmObject1.getAssociation( Uml::theOther( umlAssociationRole ) ) );
UdmObjectSet udmObjectSet2 = _classNameFilter.filterUdmObjectSet( udmObject2.getAssociation( Uml::theOther( umlAssociationRole ) ) );
if ( udmObjectSet1.size() != udmObjectSet2.size() ) {
std::cerr << "Objects \"" << udmObject1.getPath( "/" ) << "\" and \"" << udmObject2.getPath( "/" ) << "\"" << std::endl;
std::cerr << "have a different number of \"" << umlAssociationRole.name() << "\" associations: " << udmObjectSet1.size() << " vs. " << udmObjectSet2.size() << std::endl << std::endl;
retval = false;
}
UdmAssociationObjectSet udmAssociationObjectSet1;
udmAssociationObjectSet1.rehash(udmObjectSet1.size());
std::copy(udmObjectSet1.begin(), udmObjectSet1.end(), std::inserter(udmAssociationObjectSet1, udmAssociationObjectSet1.begin()));
if ( udmAssociationObjectSet1.size() != udmObjectSet1.size() ) {
std::cerr << "Object \"" << udmObject1.getPath( "/" ) << "\" has \"" << umlAssociationRole.name() << "\" associated objects that cannot be distinguished (probably due to duplicate name)." << std::endl << std::endl;
retval = false;
}
UdmAssociationObjectSet udmAssociationObjectSet2;
udmAssociationObjectSet2.rehash(udmObjectSet2.size());
std::copy(udmObjectSet2.begin(), udmObjectSet2.end(), std::inserter(udmAssociationObjectSet2, udmAssociationObjectSet2.begin()));
if ( udmAssociationObjectSet2.size() != udmObjectSet2.size() ) {
std::cerr << "Object \"" << udmObject2.getPath( "/" ) << "\" has \"" << umlAssociationRole.name() << "\" associated objects that cannot be distinguished (probably due to duplicate name)." << std::endl << std::endl;
retval = false;
}
UdmAssociationObjectSet::iterator ucsItr1 = udmAssociationObjectSet1.begin();
for( ; ucsItr1 != udmAssociationObjectSet1.end(); ++ucsItr1 ) {
UdmAssociationObjectSet::iterator ucsItr2 = udmAssociationObjectSet2.find(*ucsItr1);
if ( ucsItr2 == udmAssociationObjectSet2.end()) {
std::cerr << "In first model, \"" << udmObject1.getPath( "/" ) << "\" has a \"" << umlAssociationRole.name() << "\" association object \"" << ucsItr1->object.getPath( "/" ) << "\", but not in the second model." << std::endl;