@brief The main function of the sample This is the main function of the sample. Its purpose is to be the starting point for the sample and according to the command line arguments, to decide which sample behavior to use. @ingroup UserSelectionMain
| 52 | /// sample and according to the command line arguments, to decide which sample behavior to use. |
| 53 | /// @ingroup UserSelectionMain |
| 54 | int main(int argc, char** argv) |
| 55 | { |
| 56 | SampleManager* pSampleManager=NULL; // will hold the sample manager which initializes and runs the sample |
| 57 | if(argc>1) |
| 58 | { |
| 59 | // check if the argument is asking for help... |
| 60 | if(xnOSStrCmp(argv[1],"--help")==0 || |
| 61 | xnOSStrCmp(argv[1],"-help")==0 || |
| 62 | xnOSStrCmp(argv[1],"/help")==0 || |
| 63 | xnOSStrCmp(argv[1],"\\help")==0 || |
| 64 | xnOSStrCmp(argv[1],"?")==0 || |
| 65 | xnOSStrCmp(argv[1],"--?")==0 || |
| 66 | xnOSStrCmp(argv[1],"-?")==0 || |
| 67 | xnOSStrCmp(argv[1],"/?")==0 || |
| 68 | xnOSStrCmp(argv[1],"\\?")==0) |
| 69 | { |
| 70 | UsageAndExit(argv[0]); |
| 71 | } |
| 72 | |
| 73 | // go over the arguments and see if we have the '-s' switch. If so it means we |
| 74 | // are going to choose the selector type. |
| 75 | for(int i=1; i<argc-1; i++) |
| 76 | { |
| 77 | if(xnOSStrCmp(argv[i],"-s")==0) |
| 78 | { |
| 79 | if(xnOSStrCmp(argv[i+1],"ClosestSelector")==0) |
| 80 | { |
| 81 | // we are in the option '-s ClosestSelector N'. |
| 82 | if(argc<=i+2 || strlen(argv[i+2])>2) |
| 83 | { |
| 84 | UsageAndExit(argv[0]); // either there is no N at all or it is more than 1 digit |
| 85 | } |
| 86 | XnUInt32 n=argv[i+2][0]-'0'; // translate digit to number |
| 87 | pSampleManager=XN_NEW(ClosestSampleManager,n); // choose ClosestSelector with n |
| 88 | } |
| 89 | else if(xnOSStrCmp(argv[i+1],"SingleWave")==0) |
| 90 | { |
| 91 | // option is '-s SingleWave' |
| 92 | pSampleManager=XN_NEW(SingleWaveSampleManager); |
| 93 | } |
| 94 | else if(xnOSStrCmp(argv[i+1],"MultipleWave")==0) |
| 95 | { |
| 96 | // option is '-s SingleWave N' |
| 97 | if(argc<=i+2 || strlen(argv[i+2])>2) |
| 98 | { |
| 99 | UsageAndExit(argv[0]); // either there is no N at all or it is more than 1 digit |
| 100 | } |
| 101 | XnUInt32 n=argv[i+2][0]-'0'; // translate digit to number |
| 102 | pSampleManager=XN_NEW(MultipleWaveSampleManager,n); |
| 103 | } |
| 104 | else |
| 105 | { |
| 106 | // an illegal option was used... |
| 107 | UsageAndExit(argv[0]); |
| 108 | } |
| 109 | break; // we found the switch so we ignore all others |
| 110 | } |
| 111 | } |
nothing calls this directly
no test coverage detected