MAK RTIspy API Documentation for HLA 1.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
simpleTimeStringUtil.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2004 MaK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 /*******************************************************************************
6 ** $RCSfile: simpleTimeStringUtil.h,v $ $Revision: 1.2 $ $State: Exp $
7 *******************************************************************************/
8 
9 #ifndef stringUtil_H_
10 #define stringUtil_H_
11 
12 #include <string>
13 #include <sstream>
14 #include <iomanip>
15 #include <iostream>
16 
17 using namespace std;
18 
19 // Convert narrow C string to wide string
20 inline wstring DtToWString(const char * in_val)
21 {
22  wstring temp;
23  while (*in_val != '\0')
24  temp += *in_val++;
25  return temp;
26 }
27 
28 // Convert narrow string to wide string
29 inline string DtToString(const wstring &in_val)
30 {
31  string temp;
32  wstring::const_iterator b = in_val.begin();
33  const wstring::const_iterator e = in_val.end();
34  while (b != e)
35  {
36  temp += static_cast<char>(*b);
37  ++b;
38  }
39  return temp;
40 }
41 
42 
43 inline string usage()
44 {
45  ostringstream ostr;
46  ostr << "Usage: simpletime13/1516(d) [-fedFile fedFileName][-m #Federates][-phaseLine #][-sleepTime s][-dedicated][-unManaged]"
47  << endl << endl
48 
49  << setw( 20 ) << " -fedFile "
50  << " Specify the Fed file name \n"
51  << setw ( 24 ) << " " << "Default : MAKsimple.xml/fed. \n"
52 
53  << setw( 20 ) << " -m "
54  << " Specify whether this federate is the master and if so, how many \n"
55  << setw( 24 ) << " " << "total federates it should wait for. \n"
56 
57  << setw( 20 ) << " -phaseLine "
58  << " Specify the boundary, which when this federate\n"
59  << setw( 24 ) << " " << "crosses it, it starts firing.\n"
60  << setw( 24 ) << " " << " Default is 75 units. \n"
61 
62  << setw( 20 ) << " -sleepTime "
63  << " Specify the time in ms to sleep between iterations of the main loop. \n"
64  << setw( 24 ) << " " << " Default is 850 ms. \n"
65 
66  << setw( 20 ) << " -dedicated "
67  << " Specify whether this federate is on a machine dedicated to running\n"
68  << setw( 24 ) << " "
69  << " this federate. Invalidates all sleeps and yields.\n"
70 
71  << setw( 20 ) << " -unManaged "
72  << " Specify whether this federate will respect the synchronization step\n"
73  << setw( 24 ) << " " << " before time advancing.\n"
74 
75  << endl;
76  return ostr.str();
77 }
78 
79 template< class T >
80 bool convert( const string& param,
81  const string& value,
82  T& dest )
83 {
84  istringstream convert( value );
85  convert >> dest;
86  if ( convert.fail() )
87  {
88  std::cout << "Bad Parameter Value\n"
89  << "Param: " << param
90  << "\tValue: " << value << endl;
91  return false;
92  }
93  return true;
94 }
95 
96 
97 #endif
98 

Document ID: Generated on Mon Mar 21 09:41:37 EDT 2016 from SVN revision 163228
Copyright © 2005-2015 VT MÄK Inc. All Rights Reserved (www.mak.com)