当前位置: 首页>>代码示例>>C++>>正文


C++ Object::getRealAttr方法代码示例

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


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

示例1: compareNodeAux

bool UdmComparator::compareNodeAux( Udm::Object udmObject1, Udm::Object udmObject2 ) {

	bool retval = true;

	_udmObjectMap.insert(  std::make_pair( udmObject1, udmObject2 )  );

	const Uml::Class &umlClass1 = udmObject1.type();
	const Uml::Class &umlClass2 = 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;
//.........这里部分代码省略.........
开发者ID:dyao-vu,项目名称:meta-core,代码行数:101,代码来源:UdmComparator.cpp


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