本文整理汇总了C++中Version::isComparable方法的典型用法代码示例。如果您正苦于以下问题:C++ Version::isComparable方法的具体用法?C++ Version::isComparable怎么用?C++ Version::isComparable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Version
的用法示例。
在下文中一共展示了Version::isComparable方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dprintf
bool
ReplicatorStateMachine::replicaSelectionHandler( Version& newVersion )
{
REPLICATION_ASSERT( m_state == VERSION_DOWNLOADING || m_state == BACKUP );
dprintf( D_ALWAYS, "ReplicatorStateMachine::replicaSelectionHandler "
"started with my version = %s, #versions = %d\n",
m_myVersion.toString( ).Value( ), m_versionsList.Number( ) );
List<Version> actualVersionsList;
Version myVersionCopy = m_myVersion;
utilCopyList( actualVersionsList, m_versionsList );
// in BACKUP state compares the received version with the local one
if( m_state == BACKUP ) {
// compares the versions, taking only 'gid' and 'logicalClock' into
// account - this is the reason for making the states equal
myVersionCopy.setState( newVersion );
return ! newVersion.isComparable( myVersionCopy ) ||
newVersion > myVersionCopy;
}
/* in VERSION_DOWNLOADING state selecting the best version from the list of
* received versions according to the policy defined by
* 'replicaSelectionHandler', i.e. selecting the version with greatest
* 'logicalClock' value amongst a group of versions with the same gid
*/
actualVersionsList.Rewind( );
if( actualVersionsList.IsEmpty( ) ) {
return false;
}
Version version;
Version bestVersion;
// taking the first actual version as the best version in the meantime
actualVersionsList.Next( bestVersion );
dprintf( D_ALWAYS, "ReplicatorStateMachine::replicaSelectionHandler best "
"version = %s\n", bestVersion.toString( ).Value( ) );
while( actualVersionsList.Next( version ) ) {
dprintf( D_ALWAYS, "ReplicatorStateMachine::replicaSelectionHandler "
"actual version = %s\n", version.toString( ).Value( ) );
if( version.isComparable( bestVersion ) && version > bestVersion ) {
bestVersion = version;
}
}
actualVersionsList.Rewind( );
// compares the versions, taking only 'gid' and 'logicalClock' into
// account - this is the reason for making the states equal
myVersionCopy.setState( bestVersion );
// either when the versions are incomparable or when the local version
// is worse, the remote version must be downloaded
if( myVersionCopy.isComparable( bestVersion ) &&
myVersionCopy >= bestVersion ) {
return false;
}
newVersion = bestVersion;
dprintf( D_ALWAYS, "ReplicatorStateMachine::replicaSelectionHandler "
"best version selected: %s\n", newVersion.toString().Value());
return true;
}