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(e) [-fedFile <fedFileName>][-m <#>][-phaseLine <#>][-sleepTime <#>][-dedicated]\n"
47  " [-unManaged][-advanceTimeWith <serviceName>][-available][-lookAhead <#>][-timeIncrement <#>]"
48  << endl << endl
49 
50  << setw(35) << std::left << "-fedFile <fedFileName>"
51  << "The FED file name.\n"
52  << setw(35) << std::right << " " << std::left
53  << "Default: MAKsimple.xml/fed.\n"
54  << endl
55 
56  << setw(35) << "-m <numberOfFederates>"
57  << "Whether this federate is the master and how many total federates are needed to synchronize.\n"
58  << endl
59 
60  << setw(35) << "-phaseLine <numberUnits>"
61  << "The open fire boundary, which when this federate crosses it, it is free to fire.\n"
62  << setw(35) << std::right << " " << std::left
63  << "Default: 550 units.\n"
64  << endl
65 
66  << setw(35) << "-sleepTime <milliseconds>"
67  << "The time in milliseconds to sleep between iterations of the main loop. \n"
68  << setw(35) << std::right << " " << std::left
69  << "Default: 850 ms. \n"
70  << endl
71 
72  << setw(35) << "-dedicated"
73  << "Execute as if this federate is on a dedicated machine for running this federate.\n"
74  << setw(35) << std::right << " " << std::left
75  << "Disables all sleeps and yields.\n"
76  << endl
77 
78  << setw(35) << "-unManaged"
79  << "Ignore the synchronization step before advancing time.\n"
80  << endl
81 
82  << setw(35) << "-advanceTimeWith <rtiAmbService>"
83  << "The time advance service: timeAdvanceRequest, nextMessageRequest, flushQueue. \n"
84  << setw(35) << std::right << " " << std::left
85  << "Default: timeAdvanceRequest. \n"
86  << endl
87 
88  << setw(35) << "-available"
89  << "Use the available option of time advance service.\n"
90  << endl
91 
92  << setw(35) << "-lookAhead <seconds>"
93  << "The lookahead time in seconds.\n"
94  << setw(35) << std::right << " " << std::left
95  << "Default: 1.0 s. \n"
96  << endl
97 
98  << setw(35) << "-timeIncrement <seconds>"
99  << "The increment to advance time in seconds.\n"
100  << setw(35) << std::right << " " << std::left
101  << "Default: 5.0 s. \n"
102  << endl
103 
104  << endl;
105  return ostr.str();
106 }
107 
108 template< class T >
109 bool convert( const string& param,
110  const string& value,
111  T& dest )
112 {
113  istringstream convert( value );
114  convert >> dest;
115  if ( convert.fail() )
116  {
117  std::cout << "Bad Parameter Value\n"
118  << "Param: " << param
119  << "\tValue: " << value << endl;
120  return false;
121  }
122  return true;
123 }
124 
125 
126 #endif
127 
std::string DtToString(const std::wstring &in_val)
Definition: rtiSimpleStringUtil.h:22
bool convert(const string &param, const string &value, T &dest)
Definition: simpleTimeStringUtil.h:109
std::string usage()
Definition: simpleDDMStringUtil.h:47
std::wstring DtToWString(const char *in_val)
Definition: rtiSimpleStringUtil.h:13

Document ID: Generated on Mon Sep 7 15:40:32 EDT 2020 from SVN revision 217499
Copyright © 2005-2020 MAK Technologies Inc. All Rights Reserved (www.mak.com)