main_8c-source.html
来自「仿真人工智能是指用人工的方法和技术」· HTML 代码 · 共 219 行 · 第 1/2 页
HTML
219 行
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"><title>main.C Source File</title><link href="doxygen.css" rel="stylesheet" type="text/css"></head><body bgcolor="#ffffff"><!-- Generated by Doxygen 1.2.12 --><center><a class="qindex" href="index.html">Main Page</a> <a class="qindex" href="hierarchy.html">Class Hierarchy</a> <a class="qindex" href="annotated.html">Compound List</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="functions.html">Compound Members</a> <a class="qindex" href="globals.html">File Members</a> </center><hr><h1>main.C</h1><a href="main_8C.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <font class="comment">/*</font>00002 <font class="comment">Copyright (c) 2000,2001, Jelle Kok, University of Amsterdam</font>00003 <font class="comment">All rights reserved.</font>00004 <font class="comment"></font>00005 <font class="comment">Redistribution and use in source and binary forms, with or without </font>00006 <font class="comment">modification, are permitted provided that the following conditions are met:</font>00007 <font class="comment"></font>00008 <font class="comment">1. Redistributions of source code must retain the above copyright notice, this </font>00009 <font class="comment">list of conditions and the following disclaimer. </font>00010 <font class="comment"></font>00011 <font class="comment">2. Redistributions in binary form must reproduce the above copyright notice, </font>00012 <font class="comment">this list of conditions and the following disclaimer in the documentation </font>00013 <font class="comment">and/or other materials provided with the distribution. </font>00014 <font class="comment"></font>00015 <font class="comment">3. Neither the name of the University of Amsterdam nor the names of its </font>00016 <font class="comment">contributors may be used to endorse or promote products derived from this </font>00017 <font class="comment">software without specific prior written permission. </font>00018 <font class="comment"></font>00019 <font class="comment">THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" </font>00020 <font class="comment">AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE </font>00021 <font class="comment">IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE </font>00022 <font class="comment">DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE </font>00023 <font class="comment">FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL </font>00024 <font class="comment">DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR </font>00025 <font class="comment">SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER </font>00026 <font class="comment">CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, </font>00027 <font class="comment">OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE </font>00028 <font class="comment">OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</font>00029 <font class="comment">*/</font>00045 <font class="preprocessor">#include "<a class="code" href="SenseHandler_8h.html">SenseHandler.h</a>"</font>00046 <font class="preprocessor">#include "<a class="code" href="Player_8h.html">Player.h</a>"</font>00047 <font class="preprocessor">#include "<a class="code" href="Parse_8h.html">Parse.h</a>"</font>00048 <font class="preprocessor">#include <string.h></font> <font class="comment">// needed for strcpy</font>00049 <font class="preprocessor">#include <pthread.h></font> <font class="comment">// needed for pthread_create</font>00050 <font class="preprocessor">#include <stdlib.h></font> <font class="comment">// needed for exit</font>00051 <a name="l00052"></a><a class="code" href="main_8C.html#a0">00052</a> <font class="keyword">extern</font> <a class="code" href="classLogger.html">Logger</a> <a class="code" href="main_8C.html#a0">Log</a>; 00053 <font class="keywordtype">void</font> <a class="code" href="main_8C.html#a1">printOptions</a>( );00054 <a name="l00059"></a><a class="code" href="main_8C.html#a2">00059</a> <font class="keywordtype">int</font> <a class="code" href="main_8C.html#a2">main</a>( <font class="keywordtype">int</font> argc, <font class="keywordtype">char</font> * argv[] )00060 {00061 pthread_t listen, sense;00062 <a class="code" href="classServerSettings.html">ServerSettings</a> ss;00063 <a class="code" href="classPlayerSettings.html">PlayerSettings</a> ps;00064 00065 <font class="comment">// define variables for command options and initialize with default values</font>00066 <font class="keywordtype">char</font> strTeamName[<a class="code" href="SoccerTypes_8h.html#a8">MAX_TEAM_NAME_LENGTH</a>] = <font class="stringliteral">"UvA_Trilearn"</font>;00067 <font class="keywordtype">int</font> iPort = ss.<a class="code" href="classServerSettings.html#a110">getPort</a>();00068 <font class="keywordtype">int</font> iMinLogLevel = 0;00069 <font class="keywordtype">int</font> iMaxLogLevel = 0;00070 <font class="keywordtype">char</font> strHost[128] = <font class="stringliteral">"localhost"</font>;00071 <font class="keywordtype">double</font> dVersion = 7.04;00072 <font class="keywordtype">int</font> iMode = 0;00073 <font class="keywordtype">char</font> strFormations[128] = <font class="stringliteral">"formations.conf"</font>;00074 <font class="keywordtype">int</font> iNr = 1;00075 <font class="keywordtype">int</font> iReconnect = -1;00076 <font class="keywordtype">bool</font> bInfo = <font class="keyword">false</font>;00077 <font class="keywordtype">bool</font> bSuppliedLogFile = <font class="keyword">false</font>;00078 ofstream os;00079 00080 <font class="comment">// read in all the command options and change the associated variables</font>00081 <font class="comment">// assume every two values supplied at prompt, form a duo</font>00082 <font class="keywordtype">char</font> * str;00083 <font class="keywordflow">for</font>( <font class="keywordtype">int</font> i = 1 ; i < argc ; i = i + 2 )00084 {00085 <font class="comment">// help is only option that does not have to have an argument</font>00086 <font class="keywordflow">if</font>( i + 1 >= argc && strncmp( argv[i], <font class="stringliteral">"-help"</font>, 3 ) != 0 )00087 {00088 cout << <font class="stringliteral">"Need argument for option: "</font> << argv[i] << endl;00089 exit( 0 );00090 }00091 <font class="comment">// read a command option</font>00092 <font class="keywordflow">if</font>( argv[i][0] == <font class="charliteral">'-'</font> && strlen( argv[i] ) > 1)00093 {00094 <font class="keywordflow">switch</font>( argv[i][1] )00095 {00096 <font class="keywordflow">case</font> <font class="charliteral">'?'</font>: <font class="comment">// print help</font>00097 <a class="code" href="main_8C.html#a1">printOptions</a>( );00098 exit(0);00099 <font class="keywordflow">break</font>;00100 <font class="keywordflow">case</font> <font class="charliteral">'c'</font>: <font class="comment">// clientconf file</font>00101 <font class="keywordflow">if</font>( ps.<a class="code" href="classGenericValues.html#a7">readValues</a>( argv[i+1], <font class="stringliteral">":"</font> ) == <font class="keyword">false</font> )00102 cerr << <font class="stringliteral">"Error in reading client file: "</font> << argv[i+1] << endl;00103 <font class="keywordflow">break</font>;00104 <font class="keywordflow">case</font> <font class="charliteral">'f'</font>: <font class="comment">// formations file</font>00105 strcpy( strFormations, argv[i+1] );00106 <font class="keywordflow">break</font>;00107 <font class="keywordflow">case</font> <font class="charliteral">'h'</font>: <font class="comment">// host server or help</font>00108 <font class="keywordflow">if</font>( strlen( argv [i]) > 2 && argv[i][2] == <font class="charliteral">'e'</font> )00109 {00110 <a class="code" href="main_8C.html#a1">printOptions</a>( );00111 exit(0);00112 }00113 <font class="keywordflow">else</font>00114 strcpy( strHost, argv[i+1] );00115 <font class="keywordflow">break</font>;00116 <font class="keywordflow">case</font> <font class="charliteral">'i'</font>: <font class="comment">// info 1 0</font>00117 str = &argv[i+1][0];00118 bInfo = (<a class="code" href="classParse.html#d1">Parse::parseFirstInt</a>( &str ) == 1 ) ? <font class="keyword">true</font> : <font class="keyword">false</font> ;00119 <font class="keywordflow">break</font>;00120 <font class="keywordflow">case</font> <font class="charliteral">'l'</font>: <font class="comment">// loglevel int[..int]</font>00121 str = &argv[i+1][0];
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?