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


C++ ObjectRef::code方法代码示例

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


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

示例1: cache

void SqlBackendTest::cache()
{
	QMap<int,OidType> list;
	int maxObjects = 100;

	Manager::self()->reset();
	Manager::self()->setMaxObjects( maxObjects );

	// Check modified objects are not freed
	ObjectRef<Article> a = Article::create();
	a->setCode( "Code1" );
	for ( int i = 0; i < maxObjects * 2; ++i ) {
		ObjectRef<CustomerOrder> o1 = CustomerOrder::create();
		list[i*3] = o1->oid();
		ObjectRef<Customer> c1 = Customer::create();
		list[i*3+1] = c1->oid();
		o1->setCustomer( c1 );
		ObjectRef<Article> a1 = Article::create();
		list[i*3+2] = a1->oid();
		o1->articles()->add( a1 );
	}
	CHECK( a->code(), QString( "Code1" ) );

	// Check when commiting object cache is purged to maxObjects
	CHECK( Manager::self()->commit(), true );
	CHECK( Manager::self()->objects().count(), maxObjects );
	CHECK( Manager::self()->relations().count(), maxObjects );
	CHECK( Manager::self()->collections().count(), maxObjects );

	// Check data has been saved correctly to DB
	for ( int i = 0; i < maxObjects * 2; ++i ) {
		QSqlCursor cursor( "customerorder" );
		cursor.select( "dboid = " + oidToString( list[i*3] ) );
		CHECK( cursor.next(), true );
		CHECK( variantToOid( cursor.value( "customer_customerorder" ) ), list[i*3 + 1] );
		CHECK( cursor.next(), false );

		cursor.setName( "article" );
		cursor.select( "dboid = " + oidToString( list[i*3+2] ) );
		CHECK( cursor.next(), true );
		CHECK( cursor.next(), false );

		cursor.setName( "customer" );
		cursor.select( "dboid = " + oidToString( list[i*3+1] ) );
		CHECK( cursor.next(), true );
		CHECK( cursor.next(), false );

		cursor.setName( "article_customerorder" );
		cursor.select( "article = " + oidToString( list[i*3+2] ) + " AND customerorder = " + oidToString( list[i*3] ) );
		CHECK( cursor.next(), true );
		CHECK( cursor.next(), false );
	}
	
	// Can we still reach article 1?
	CHECK( a->code(), QString( "Code1" ) );
	
	// Ensure we're still under maxObjects
	CHECK( Manager::self()->objects().count(), maxObjects );
	CHECK( Manager::self()->relations().count(), maxObjects );
	CHECK( Manager::self()->collections().count(), maxObjects );
}
开发者ID:BackupTheBerlios,项目名称:kandau-svn,代码行数:61,代码来源:sqlbackendtest.cpp


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