本文整理汇总了C++中Country::GetInstanceId方法的典型用法代码示例。如果您正苦于以下问题:C++ Country::GetInstanceId方法的具体用法?C++ Country::GetInstanceId怎么用?C++ Country::GetInstanceId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Country
的用法示例。
在下文中一共展示了Country::GetInstanceId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Find
//-----------------------------------------------------------------
//
// METHOD:
// Country* Country::Find( RTI::ObjectHandle objectId )
//
// PURPOSE:
// Looks through the extent to find the Country instance
// with the passed in object Id.
//
// RETURN VALUES:
// Pointer to country object that has the specified
// ObjectHandle.
//
// HISTORY:
// 1) Created 11/6/96
// 2) Updated to RTI 1.3 3/26/98
//
//-----------------------------------------------------------------
Country* Country::Find( RTI::ObjectHandle objectId )
{
Country *pCountry = NULL;
for ( unsigned int i = 0; i < Country::ms_extentCardinality; i++ )
{
pCountry = Country::ms_countryExtent[ i ];
if ( pCountry && pCountry->GetInstanceId() == objectId ) {
break;
} else {
pCountry = NULL;
}
}
return pCountry;
}
示例2:
//-----------------------------------------------------------------
//
// METHOD:
// Country::~Country()
//
// PURPOSE:
// Virtual destructor. Frees memory allocated for m_name and
// removes this instance from the extent.
//
// Note: Removing an element from the extent causes the array
// to be collapsed so as to not have any gaps. Some
// elements will have new indices within the extent
// after this occurs.
//
// RETURN VALUES:
// None.
//
// HISTORY:
// 1) Created 11/6/96
// 2) Updated to RTI 1.3 3/26/98
//
//-----------------------------------------------------------------
Country::~Country()
{
Country *pCountry = NULL;
unsigned int ndx = 0;
//-----------------------------------------------------------------
// Find the position in the extent for this instance. The
// zero'th position always hold the local instance.
//-----------------------------------------------------------------
for ( ndx = 0; ndx < Country::ms_extentCardinality; ndx++ )
{
pCountry = Country::ms_countryExtent[ ndx ];
if ( pCountry && pCountry->GetInstanceId() == this->GetInstanceId() )
{
break;
}
}
if ( pCountry )
{
//-----------------------------------------------------------------
// First thing to do is move the rest of the Country objects
// one position up in the collection and then reduce the
// cardinality by one.
//-----------------------------------------------------------------
for ( unsigned int i=ndx; (i < Country::ms_extentCardinality)
&& (Country::ms_countryExtent[ i ] != NULL); i++ )
{
Country::ms_countryExtent[ i ] = Country::ms_countryExtent[ i+1 ];
}
Country::ms_extentCardinality = Country::ms_extentCardinality - 1;
//-----------------------------------------------------------------
// If the instance was found in the 0th position then this is the
// local Country instance so we should delete it from the federation
// execution.
//-----------------------------------------------------------------
if ( ms_rtiAmb && ndx==0 )
{
//-----------------------------------------------------------------
// this call returns an event retraction handle but we don't
// support event retraction so no need to store it.
//-----------------------------------------------------------------
(void) ms_rtiAmb->deleteObjectInstance( this->GetInstanceId(),
this->GetLastTimePlusLookahead(),
NULL );
}
else
{
//-----------------------------------------------------------------
// Otherwise, this is a remote object that removeObject was called
// on.
//-----------------------------------------------------------------
//We don't need to do anything here
}
}
delete [] m_name;
}