本文整理汇总了C++中Country::GetName方法的典型用法代码示例。如果您正苦于以下问题:C++ Country::GetName方法的具体用法?C++ Country::GetName怎么用?C++ Country::GetName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Country
的用法示例。
在下文中一共展示了Country::GetName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: throw
void HwFederateAmbassador::provideAttributeValueUpdate (
RTI::ObjectHandle theObject, // supplied C1
const RTI::AttributeHandleSet& theAttributes) // supplied C4
throw (
RTI::ObjectNotKnown,
RTI::AttributeNotKnown,
RTI::AttributeNotOwned,
RTI::FederateInternalError)
{
//-----------------------------------------------------------------
// Find the Country instance this request is for.
//-----------------------------------------------------------------
Country *pCountry = Country::Find( theObject );
if ( pCountry )
{
//-----------------------------------------------------------------
// Touch the appropriate attribute values in this country
// instance so that the get updated next cycle.
//-----------------------------------------------------------------
RTI::AttributeHandle attrHandle;
//-----------------------------------------------------------------
// We need to iterate through the AttributeHandleSet
// to extract each AttributeHandle. Based on the type
// specified ( the value returned by getHandle() ) we need to
// set the status of whether we should send this type of data.
//-----------------------------------------------------------------
for (unsigned int i = 0; i < theAttributes.size(); i++ )
{
attrHandle = theAttributes.getHandle( i );
if ( attrHandle == Country::GetPopulationRtiId() )
{
// Touch population so that it gets update next cycle
pCountry->SetPopulation( pCountry->GetPopulation() );
}
else if ( attrHandle == Country::GetNameRtiId() )
{
// Touch name so that it gets update next cycle
pCountry->SetName( pCountry->GetName() );
}
}
}
}
示例2: hw_main
int hw_main(int argc, char *argv[])
{
double PreviousPopulation[100];
const char *exeName = argv[0]; // Name of executable process
char *const fedExecName = "HelloWorld"; // Name of the Federation Execution
Country *myCountry = NULL; // Pointer to Federate's Country
int numberOfTicks(100);
long timeManaged = 1;
int loopCounter = 0;
for (; loopCounter < 100; ++loopCounter)
{
PreviousPopulation[loopCounter] = 0.0;
}
loopCounter = 0;
//////////////////////////////////////////////////////////////////////////
// Make sure executable is provided with correct number of arguments
//////////////////////////////////////////////////////////////////////////
if (argc < 3)
{
printUsage(exeName);
return -1;
}
else if (!argv[1] && !argv[2] && (argc == 3 || !argv[3]))
{
printUsage(exeName);
}
else
{
myCountry = new Country(argv[1], argv[2]);
if (argc > 3)
{
numberOfTicks = atoi(argv[3]);
}
if (argc > 4)
{
timeManaged = 0;
}
}
try
{
//////////////////////////////////////////////////////////////////////////
// Create RTI objects
// The federate communicates to the RTI through the RTIambassador
// object and the RTI communicates back to the federate through
// the FederateAmbassador object.
//////////////////////////////////////////////////////////////////////////
RTI::RTIambassador rtiAmb; // libRTI provided
HwFederateAmbassador fedAmb; // User-defined
// Named value placeholder for the federates handle -
// we don't really use this in HelloWorld but some
// services and MOM might need it - if we were to use them.
RTI::FederateHandle federateId;
#if defined(WIN32)
struct _timeb tb;
_ftime(&tb);
cout << myCountry->GetName() << " " << tb.time << " "
<< tb.millitm * 1000 << " START" << endl;
#elif defined(VXWORKS)
struct timespec tp;
clock_gettime(CLOCK_REALTIME, &tp);
cout << myCountry->GetName() << " " << tp.tv_sec << " "
<< tp.tv_nsec / 1000L << " START" << endl;
#else
static struct timeval tp;
gettimeofday(&tp, NULL);
cout << myCountry->GetName() << " "
<< tp.tv_sec << " "
<< tp.tv_usec << " "
<< "START\n";
#endif
RTI::Boolean Jointed = RTI::RTI_FALSE;
int numTries = 0;
while (!Jointed && (numTries++ < 20))
{
//////////////////////////////////////////////////////////////////////////
// Create Federation Execution
//////////////////////////////////////////////////////////////////////////
try
{
cout << "FED_HW: CREATING FEDERATION EXECUTION" << endl;
rtiAmb.createFederationExecution(fedExecName, "HelloWorld.fed");
cout << "FED_HW: SUCCESSFUL CREATE FEDERATION EXCUTIN" << endl;
}
catch (RTI::FederationExecutionAlreadyExists &e)
{
cerr << "FED_HW: Note: Federation execution already exists."
<< e << endl;
}
//.........这里部分代码省略.........
示例3: hw_main
int hw_main(int argc, char *argv[])
{
double PreviousPopulation[100];
const char* exeName = argv[0]; // Name of executable process
char* const fedExecName = "HelloWorld"; // Name of the Federation Execution
Country* myCountry = NULL; // Pointer to Federate's Country
int numberOfTicks( 100 );
long TimeManaged = 1;
int loopCounter = 0;
for(;loopCounter < 100; ++loopCounter)
{
PreviousPopulation[loopCounter] = 0.0;
}
loopCounter = 0;
//------------------------------------------------------
// Make sure executable is provided with correct number
// of arguments.
//------------------------------------------------------
if (argc < 3)
{
printUsage( exeName );
return -1;
}
else if ( !argv[1] && !argv[2] && (argc == 3 || !argv[3]) )
{
printUsage( exeName );
return -1;
}
else
{
myCountry = new Country( argv[1], argv[2] );
if ( argc > 3 )
{
numberOfTicks = atoi( argv[3] );
}
if ( argc > 4 )
{
TimeManaged = 0;
}
}
try
{
//------------------------------------------------------
// Create RTI objects
//
// The federate communicates to the RTI through the RTIambassador
// object and the RTI communicates back to the federate through
// the FederateAmbassador object.
//------------------------------------------------------
RTI::RTIambassador rtiAmb; // libRTI provided
HwFederateAmbassador fedAmb; // User-defined
// Named value placeholder for the federates handle -
// we don't really use this in HelloWorld but some
// services and MOM might need it - if we were to use them.
RTI::FederateHandle federateId;
#if defined(WIN32)
struct _timeb tb;
_ftime(&tb);
cout << myCountry->GetName() << " " << tb.time << " " <<
tb.millitm * 1000 << " START" << endl;
#elif defined(VXWORKS)
struct timespec tp;
clock_gettime(CLOCK_REALTIME, &tp);
cout << myCountry->GetName() << " " << tp.tv_sec << " " <<
tp.tv_nsec / 1000L << " START" << endl;
#else
static struct timeval tp;
gettimeofday(&tp, NULL);
cout << myCountry->GetName() << " "
<< tp.tv_sec << " "
<< tp.tv_usec << " "
<< "START\n";
#endif
RTI::Boolean Joined = RTI::RTI_FALSE;
int numTries = 0;
//------------------------------------------------------
// Here we loop around the joinFederationExecution call
// until we try to many times or the Join is successful.
//
// The federate that successfully CREATES the federation
// execution will get to the join call before the
// FedExec is initializes and will be unsuccessful at
// JOIN call. In this loop we catch the
// FederationExecutionDoesNotExist exception to
// determine that the FedExec is not initialized and to
//.........这里部分代码省略.........