Alex Bikfalvi
SimStream Documentation
Main.cpp
00001 #include "Headers.h" 00002 #include "SimulatorPush.h" 00003 #include "SimulatorPushMulti.h" 00004 #include "SimulatorPull.h" 00005 #include "SimulatorNetUcast.h" 00006 #include "SimulatorNetMcast.h" 00007 #include "SimulatorFlow.h" 00008 #include "Rand.h" 00009 #include "Console.h" 00010 00011 #pragma warning(disable : 4996) 00012 00013 int main(int argc, char* argv[]) 00014 { 00015 #ifdef _WINDOWS 00016 // Send all reports to STDOUT 00017 _CrtSetReportMode( _CRT_WARN, _CRTDBG_MODE_FILE ); 00018 _CrtSetReportFile( _CRT_WARN, _CRTDBG_FILE_STDOUT ); 00019 //_CrtSetReportMode( _CRT_ERROR, _CRTDBG_MODE_FILE ); 00020 //_CrtSetReportFile( _CRT_ERROR, _CRTDBG_FILE_STDOUT ); 00021 _CrtSetReportMode( _CRT_ASSERT, _CRTDBG_MODE_FILE ); 00022 _CrtSetReportFile( _CRT_ASSERT, _CRTDBG_FILE_STDOUT ); 00023 #endif 00024 00025 __uint32 seed = CRand::Init(); 00026 00027 char option = 0; 00028 char* simName = ""; 00029 int argCount = argc; 00030 char** argValue = argv; 00031 00032 // Check if the simulator is selected in command line 00033 if(argc >= 3) 00034 { 00035 // If the first argument is '-s', get the simulator from the second parameter 00036 if(strcmp(argv[1], "-s") == 0) 00037 { 00038 option = argv[2][0]; 00039 simName = argv[3]; 00040 00041 // Decrease arguments by two 00042 argCount = argc - 3; 00043 argValue = argv + 3; 00044 } 00045 } 00046 00047 if(0 == option) 00048 { 00049 printf("\n\nSelect simulator or use \'-s\' switch in the command line:\ 00050 \n\t 1 - Push\ 00051 \n\t 2 - Push multi\ 00052 \n\t 3 - Pull\ 00053 \n\t 4 - Network unicast\ 00054 \n\t 5 - Network multicast\ 00055 \n\t 6 - Flow connection / congestion control\ 00056 \n\nPress a key to continue..."); 00057 option = _getch(); 00058 } 00059 else 00060 { 00061 printf("\nRandom seed: %u", seed); 00062 } 00063 00064 switch(option) 00065 { 00066 case '1': 00067 { 00068 CSimulatorPush* simulator = new CSimulatorPush(); 00069 simulator->Run(simName, argCount, argValue); 00070 delete simulator; 00071 } 00072 break; 00073 case '2': 00074 { 00075 CSimulatorPushMulti* simulator = new CSimulatorPushMulti(); 00076 simulator->Run(simName, argCount, argValue); 00077 delete simulator; 00078 } 00079 break; 00080 case '3': 00081 { 00082 CSimulatorPull* simulator = new CSimulatorPull(); 00083 simulator->Run(simName, argCount, argValue); 00084 delete simulator; 00085 } 00086 break; 00087 case '4': 00088 { 00089 CSimulatorNetUcast* simulator = new CSimulatorNetUcast(); 00090 simulator->Run(simName, argCount, argValue); 00091 delete simulator; 00092 } 00093 break; 00094 case '5': 00095 { 00096 CSimulatorNetMcast* simulator = new CSimulatorNetMcast(); 00097 simulator->Run(simName, argCount, argValue); 00098 delete simulator; 00099 } 00100 break; 00101 case '6': 00102 { 00103 CSimulatorFlow* simulator = new CSimulatorFlow(); 00104 simulator->Run(simName, argCount, argValue); 00105 delete simulator; 00106 } 00107 break; 00108 default: printf("\n\nSimulator not found."); 00109 } 00110 00111 printf("\n\n"); 00112 00113 #ifdef _WINDOWS 00114 _CrtDumpMemoryLeaks(); 00115 #endif 00116 }
Last updated: February 8, 2011