MAK RTIspy API Documentation for HLA 1.3
simpleTimeStringUtil.h
Go to the documentation of this file.
00001 /*******************************************************************************
00002 ** Copyright (c) 2004 MaK Technologies, Inc.
00003 ** All rights reserved.
00004 *******************************************************************************/
00005 /*******************************************************************************
00006 ** $RCSfile: simpleTimeStringUtil.h,v $ $Revision: 1.2 $ $State: Exp $
00007 *******************************************************************************/
00008 
00009 #ifndef stringUtil_H_
00010 #define stringUtil_H_
00011 
00012 #include <string>
00013 #include <sstream>
00014 #include <iomanip>
00015 #include <iostream>
00016 
00017 using namespace std;
00018 
00019 // Convert narrow C string to wide string
00020 inline wstring DtToWString(const char * in_val)
00021 {
00022    wstring temp;
00023    while (*in_val != '\0')
00024    temp += *in_val++;
00025    return temp;
00026 }
00027 
00028 // Convert narrow string to wide string
00029 inline string DtToString(const wstring &in_val)
00030 {
00031    string temp;
00032    wstring::const_iterator b = in_val.begin();
00033    const wstring::const_iterator e = in_val.end();
00034    while (b != e)
00035    {
00036       temp += static_cast<char>(*b);
00037       ++b;
00038    }
00039    return temp;
00040 }
00041 
00042 
00043 inline string usage()
00044 {
00045    ostringstream ostr;
00046    ostr << "Usage: simpletime13/1516(d) [-fedFile fedFileName][-m #Federates][-phaseLine #][-sleepTime s][-dedicated][-unManaged]"
00047         << endl << endl
00048 
00049         << setw( 20 ) << " -fedFile "
00050         << " Specify the Fed file name \n"
00051         << setw ( 24 ) << " " << "Default : MAKsimple.xml/fed. \n"     
00052       
00053         << setw( 20 ) << " -m "
00054         << " Specify whether this federate is the master and if so, how many \n"
00055         << setw( 24 ) << " " << "total federates it should wait for. \n"
00056 
00057         << setw( 20 ) << " -phaseLine "
00058         << " Specify the boundary, which when this federate\n"
00059         << setw( 24 ) << " " << "crosses it, it starts firing.\n"
00060         << setw( 24 ) << " " << "  Default is 75 units. \n"
00061 
00062         << setw( 20 ) << " -sleepTime "
00063         << " Specify the time in ms to sleep between iterations of the main loop. \n"
00064         << setw( 24 ) << " " << "  Default is 850 ms. \n"
00065             
00066         << setw( 20 ) << " -dedicated "
00067         << " Specify whether this federate is on a machine dedicated to running\n"
00068         << setw( 24 ) << " " 
00069         << " this federate.  Invalidates all sleeps and yields.\n"
00070                 
00071         << setw( 20 ) << " -unManaged "
00072         << " Specify whether this federate will respect the synchronization step\n"
00073         << setw( 24 ) << " " << " before time advancing.\n"
00074 
00075         << endl; 
00076    return ostr.str();
00077 }
00078 
00079 template< class T > 
00080 bool convert( const string& param,
00081              const string& value,
00082              T& dest )
00083 {
00084    istringstream convert( value );
00085    convert >> dest;
00086    if ( convert.fail() )
00087    {
00088       std::cout << "Bad Parameter Value\n"
00089          << "Param: " << param
00090          << "\tValue: " << value << endl;
00091       return false;
00092    }
00093    return true;
00094 }
00095 
00096 
00097 #endif
00098 

Document ID: Generated on Thu Jun 14 14:15:04 EDT 2012 from SVN revision 116116
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)