imgtools/imgcheck/src/main.cpp
changeset 0 044383f39525
child 590 360bd6b35136
equal deleted inserted replaced
-1:000000000000 0:044383f39525
       
     1 /*
       
     2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 * Begining of imgcheck tool.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 /**
       
    21  @file
       
    22  @internalComponent
       
    23  @released
       
    24 */
       
    25 
       
    26 #include "imgcheckmanager.h"
       
    27 #include "exceptionreporter.h"
       
    28 
       
    29 /**
       
    30 Global pointers declaration.
       
    31 
       
    32 @internalComponent
       
    33 @released
       
    34 */
       
    35 CmdLineHandler* cmdInput = KNull;
       
    36 ImgCheckManager* imgCheckerPtr = KNull;
       
    37 
       
    38 /**
       
    39 Function to delete the created instances
       
    40 
       
    41 @internalComponent
       
    42 @released
       
    43 */
       
    44 
       
    45 void DeleteInstances()
       
    46 {
       
    47 	DELETE(imgCheckerPtr);
       
    48 	DELETE(cmdInput);
       
    49 }
       
    50 
       
    51 /**
       
    52 Main function for imgcheck Tool, invokes ImgCheckManager public functions
       
    53 to carry out the validation and to generate report.
       
    54 
       
    55 @internalComponent
       
    56 @released
       
    57 
       
    58 @param argc - commandline argument count
       
    59 @param argv - argument variables
       
    60 
       
    61 @return - returns Exit status success or failure
       
    62 */
       
    63 int main(int argc,char* argv[])
       
    64 {
       
    65 	try
       
    66 	{
       
    67 		cmdInput = new CmdLineHandler();
       
    68 		if(cmdInput == KNull)
       
    69 		{
       
    70 			throw ExceptionReporter(NOMEMORY, __FILE__, __LINE__);
       
    71 		}
       
    72 		ReturnType val = cmdInput->ProcessCommandLine(argc,argv);
       
    73 
       
    74 		int ret = 0;
       
    75 		switch(val)
       
    76 		{
       
    77 			case EQuit:
       
    78 				ret = EXIT_SUCCESS;
       
    79 				break;
       
    80 	
       
    81 			case ESuccess:
       
    82 				imgCheckerPtr = new ImgCheckManager(cmdInput);
       
    83 				if(imgCheckerPtr == KNull)
       
    84 				{
       
    85 					throw ExceptionReporter(NOMEMORY, __FILE__, __LINE__);
       
    86 				}
       
    87 				imgCheckerPtr->CreateObjects();
       
    88 				imgCheckerPtr->Execute();
       
    89 				imgCheckerPtr->FillReporterData();
       
    90 				imgCheckerPtr->GenerateReport();
       
    91 				break;
       
    92 			
       
    93 			case EFail:
       
    94 				ret = EXIT_FAILURE;
       
    95 				break;
       
    96 		}
       
    97 		DeleteInstances();
       
    98 		ExceptionImplementation::DeleteInstance();
       
    99 		return ret;
       
   100 	}
       
   101     catch(ExceptionReporter& aExceptionReport)
       
   102 	{
       
   103 		aExceptionReport.Report();
       
   104 		ExceptionImplementation::DeleteInstance();
       
   105 		DeleteInstances();
       
   106 		return EXIT_FAILURE;
       
   107 	}
       
   108 }