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

Document ID: Generated on Sun Jul 20 16:15:30 EDT 2025 from SVN revision 277985
Copyright © 2005-2025 MAK Technologies Inc. All Rights Reserved (www.mak.com)