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


C++ Country::GetInstanceId方法代码示例

本文整理汇总了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;
}
开发者ID:huidesign,项目名称:Projects,代码行数:35,代码来源:Country.cpp

示例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;
}
开发者ID:huidesign,项目名称:Projects,代码行数:83,代码来源:Country.cpp


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