imgtools/imgcheck/src/main.cpp
changeset 590 360bd6b35136
parent 0 044383f39525
equal deleted inserted replaced
588:c7c26511138f 590:360bd6b35136
    30 Global pointers declaration.
    30 Global pointers declaration.
    31 
    31 
    32 @internalComponent
    32 @internalComponent
    33 @released
    33 @released
    34 */
    34 */
    35 CmdLineHandler* cmdInput = KNull;
    35 CmdLineHandler* cmdInput = 0;
    36 ImgCheckManager* imgCheckerPtr = KNull;
    36 ImgCheckManager* imgCheckerPtr = 0;
    37 
    37 
    38 /**
    38 /**
    39 Function to delete the created instances
    39 Function to delete the created instances
    40 
    40 
    41 @internalComponent
    41 @internalComponent
    42 @released
    42 @released
    43 */
    43 */
    44 
    44 
    45 void DeleteInstances()
    45 void DeleteInstances() {
    46 {
    46 	if(imgCheckerPtr){
    47 	DELETE(imgCheckerPtr);
    47 		delete imgCheckerPtr;
    48 	DELETE(cmdInput);
    48 		imgCheckerPtr = 0 ;
       
    49 	}
       
    50 	if(cmdInput){
       
    51 		delete cmdInput;
       
    52 		cmdInput = 0 ;
       
    53 	}
    49 }
    54 }
    50 
    55 
    51 /**
    56 /**
    52 Main function for imgcheck Tool, invokes ImgCheckManager public functions
    57 Main function for imgcheck Tool, invokes ImgCheckManager public functions
    53 to carry out the validation and to generate report.
    58 to carry out the validation and to generate report.
    58 @param argc - commandline argument count
    63 @param argc - commandline argument count
    59 @param argv - argument variables
    64 @param argv - argument variables
    60 
    65 
    61 @return - returns Exit status success or failure
    66 @return - returns Exit status success or failure
    62 */
    67 */
    63 int main(int argc,char* argv[])
    68 int main(int argc,char* argv[]) {
    64 {
    69 	try {
    65 	try
    70 		cmdInput = new CmdLineHandler(); 
    66 	{
    71 		if(cmdInput == 0) {
    67 		cmdInput = new CmdLineHandler();
       
    68 		if(cmdInput == KNull)
       
    69 		{
       
    70 			throw ExceptionReporter(NOMEMORY, __FILE__, __LINE__);
    72 			throw ExceptionReporter(NOMEMORY, __FILE__, __LINE__);
    71 		}
    73 		}
    72 		ReturnType val = cmdInput->ProcessCommandLine(argc,argv);
    74 		ReturnType val = cmdInput->ProcessCommandLine(argc,argv);
    73 
    75 
    74 		int ret = 0;
    76 		int ret = 0;
    75 		switch(val)
    77 		switch(val) {
    76 		{
       
    77 			case EQuit:
    78 			case EQuit:
    78 				ret = EXIT_SUCCESS;
    79 				ret = EXIT_SUCCESS;
    79 				break;
    80 				break;
    80 	
    81 	
    81 			case ESuccess:
    82 			case ESuccess:
    82 				imgCheckerPtr = new ImgCheckManager(cmdInput);
    83 				imgCheckerPtr = new ImgCheckManager(cmdInput);
    83 				if(imgCheckerPtr == KNull)
    84 				if(imgCheckerPtr == 0) {
    84 				{
       
    85 					throw ExceptionReporter(NOMEMORY, __FILE__, __LINE__);
    85 					throw ExceptionReporter(NOMEMORY, __FILE__, __LINE__);
    86 				}
    86 				} 
    87 				imgCheckerPtr->CreateObjects();
    87 				imgCheckerPtr->CreateObjects();  
    88 				imgCheckerPtr->Execute();
    88 				imgCheckerPtr->Execute();  
    89 				imgCheckerPtr->FillReporterData();
    89 				imgCheckerPtr->FillReporterData();  
    90 				imgCheckerPtr->GenerateReport();
    90 				imgCheckerPtr->GenerateReport();  
    91 				break;
    91 				break;
    92 			
    92 			
    93 			case EFail:
    93 			case EFail:
    94 				ret = EXIT_FAILURE;
    94 				ret = EXIT_FAILURE;
    95 				break;
    95 				break;
    96 		}
    96 		}
    97 		DeleteInstances();
    97 		DeleteInstances();
    98 		ExceptionImplementation::DeleteInstance();
    98 		ExceptionImplementation::DeleteInstance();
    99 		return ret;
    99 		return ret;
   100 	}
   100 	}
   101     catch(ExceptionReporter& aExceptionReport)
   101     catch(ExceptionReporter& aExceptionReport) {
   102 	{
       
   103 		aExceptionReport.Report();
   102 		aExceptionReport.Report();
   104 		ExceptionImplementation::DeleteInstance();
   103 		ExceptionImplementation::DeleteInstance();
   105 		DeleteInstances();
   104 		DeleteInstances();
   106 		return EXIT_FAILURE;
   105 		return EXIT_FAILURE;
   107 	}
   106 	}