本文整理汇总了C++中View::ClassAdInserted方法的典型用法代码示例。如果您正苦于以下问题:C++ View::ClassAdInserted方法的具体用法?C++ View::ClassAdInserted怎么用?C++ View::ClassAdInserted使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类View
的用法示例。
在下文中一共展示了View::ClassAdInserted方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: View
bool View::
InsertSubordinateView( ClassAdCollection *coll, ClassAd *viewInfo )
{
View *newView = new View( this );
ViewMembers::iterator vmi;
string key;
ClassAd *ad;
string name;;
if( !newView ) {
CondorErrno = ERR_MEM_ALLOC_FAILED;
CondorErrMsg = "";
return( false );
}
if( viewInfo ) {
viewInfo->EvaluateAttrString( ATTR_VIEW_NAME, name );
newView->evalEnviron.ReplaceLeftAd( viewInfo );
}
newView->SetViewName( name );
if( !coll->RegisterView( name, newView ) ) {
CondorErrMsg += "; failed to insert new view";
delete newView;
return( false );
}
subordinateViews.push_front( newView );
// insert current view content into new view
for( vmi = viewMembers.begin( ); vmi != viewMembers.end( ); vmi++ ) {
vmi->GetKey( key );
if( ( ad = coll->GetClassAd( key ) ) == NULL ) {
CLASSAD_EXCEPT( "internal error: classad %s in view but not in collection",
key.c_str( ) );
}
if( !newView->ClassAdInserted( coll, key, ad ) ) {
CondorErrMsg += "; failed to insert content into new view";
return( false );
}
}
return( true );
}
示例2: makePartitionSignature
bool View::
ClassAdModified( ClassAdCollection *coll, const string &key,
ClassAd *mad )
{
bool match, wasMember, sameRank, rval = true;
Value rankValue, oldAdRank, equal;
MemberIndex::iterator itr = memberIndex.find( key );
// check if classad is currently a member of this view
if( itr == memberIndex.end( ) ) {
wasMember = false;
} else {
wasMember = true;
((ViewMember) *(itr->second)).GetRankValue( oldAdRank );
}
// evaluate constraint and get new rank value
evalEnviron.ReplaceRightAd( mad );
match = evalEnviron.EvaluateAttrBool("RightMatchesLeft",match) && match;
if( !evalEnviron.EvaluateAttr( "LeftRankValue", rankValue ) ) {
rankValue.SetUndefinedValue( );
}
evalEnviron.RemoveRightAd( );
if( wasMember && match ) {
string sig;
// was and still is a member; check if rank has changed
Operation::Operate( Operation::IS_OP, rankValue, oldAdRank, equal );
if( !equal.IsBooleanValue( sameRank ) || !sameRank ) {
// rank changed ... need to re-order
ViewMember vm;
// remove old view member ...
vm.SetRankValue( oldAdRank );
vm.SetKey(key);
viewMembers.erase( vm );
// re-insert with new rank value and update member index
vm.SetRankValue( rankValue );
memberIndex[key] = viewMembers.insert( vm );
}
// check if the signature has changed
sig = makePartitionSignature( mad );
if( sig != oldAdSignature ) {
PartitionedViews::iterator mi;
View *newPartition;
// yes ... remove from old partition and insert into new
if( !oldAdSignature.empty( ) ) {
mi = partitionedViews.find( oldAdSignature );
if( mi == partitionedViews.end( ) ) {
// partition of ad not found; some internal error
CLASSAD_EXCEPT( "internal error: partition of classad with "
"signature %s not found", oldAdSignature.c_str( ) );
}
// delete from old partition
mi->second->ClassAdDeleted( coll, key, mad );
}
// is there a partition with the new signature?
if( !sig.empty( ) ) {
mi = partitionedViews.find( sig );
if( mi != partitionedViews.end( ) ) {
// yes ... insert into this partition
if( !mi->second->ClassAdInserted(coll, key, mad) ) {
CondorErrMsg+="; failed to relocate ad on modification";
return( false );
}
} else {
// no ... create a new partition
if( ( newPartition = new View( this ) ) == 0 ) {
oldAdSignature.erase( oldAdSignature.begin( ),
oldAdSignature.end( ) );
CondorErrno = ERR_MEM_ALLOC_FAILED;
CondorErrMsg = "";
return( false );
}
if( !coll->RegisterView( viewName+":"+sig, newPartition ) ){
delete newPartition;
CondorErrMsg += "; failed to create new partition for "
" modified ad";
return( false );
}
newPartition->SetViewName( viewName + ":" + sig );
if( !newPartition->ClassAdInserted(coll, key, mad) ) {
CondorErrMsg+="; failed to relocate ad on modification";
return( false );
}
partitionedViews[sig] = newPartition;
}
}
}
// send modification notification to all subordinate children
SubordinateViews::iterator xi;
for( xi=subordinateViews.begin( ); xi!=subordinateViews.end( ); xi++ ){
if( !(*xi)->ClassAdModified( coll, key, mad ) ) {
return( false );
}
}
} else if( !wasMember && match ) {
//.........这里部分代码省略.........