memana/analyzetoolclient/commandlineengine/internal/inc/CATDataSaver.h
changeset 0 f0f2b8682603
equal deleted inserted replaced
-1:000000000000 0:f0f2b8682603
       
     1 /*
       
     2 * Copyright (c) 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 "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:  Declarations for the class CATDataSaver.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef __CATDATASAVER_H__
       
    20 #define __CATDATASAVER_H__
       
    21 
       
    22 #include <xercesc/dom/DOM.hpp>
       
    23 #include <xercesc/framework/LocalFileFormatTarget.hpp>
       
    24 #include "ATCommonDefines.h"
       
    25 
       
    26 enum element_types
       
    27 {
       
    28 	RESULT = 0,
       
    29 	RUN,
       
    30 	LEAK,
       
    31 	CALLSTACK,
       
    32 	ITEM,
       
    33 	RUN_END,
       
    34 	ERROR_IN_RUN,
       
    35 	MEM_LEAKS,
       
    36 	MEM_LEAK_MODULE,
       
    37 	HANDLE_LEAKS,
       
    38 	HANDLE_LEAK_MODULE,
       
    39 	TEST_START,
       
    40 	TEST_END,
       
    41 	SUBTEST_MEM_LEAKS,
       
    42 	SUBTEST_MEM_LEAK_MODULE,
       
    43 	LOGGING_CANCELLED,
       
    44 	SUBTEST_HANDLE_LEAKS
       
    45 };
       
    46 
       
    47 //#define CARBIDE_DATA 0
       
    48 #define XML_DATA     1
       
    49 #define TEXT_DATA    2
       
    50 
       
    51 /**
       
    52 * CATDataSaver saves analysis report data same time to basic (console) output and xml.
       
    53 */
       
    54 class CATDataSaver
       
    55 {
       
    56 
       
    57 public:
       
    58 
       
    59 	/**
       
    60 	* Constructor.
       
    61 	*/
       
    62 	CATDataSaver( void );
       
    63 
       
    64 	/**
       
    65 	* Destructor.
       
    66 	*/
       
    67 	~CATDataSaver(void);
       
    68 
       
    69 	/**
       
    70 	* Save all lines to file with given format.
       
    71 	*
       
    72 	* @param pFileName Pointer to file name.
       
    73 	* @param iDataToSave Format of data.
       
    74 	*/
       
    75 	void SaveLinesToFile( const char* pFileName, int iDataToSave );
       
    76 
       
    77 	/**
       
    78 	* Prints all saved lines to screen.
       
    79 	*/
       
    80 	void PrintLinesToScreen( void );
       
    81 
       
    82 	/**
       
    83 	* Adds saved line to first in database.
       
    84 	*/
       
    85 	void AddLineToFirst( void );
       
    86 
       
    87 	/**
       
    88 	* Adds saved line to last in database.
       
    89 	*/
       
    90 	void AddLineToLast();
       
    91 
       
    92 	/**
       
    93 	* Adds string to current line.
       
    94 	*/
       
    95 	void AddString( const char* pData, bool bSaveCarbideData = false );
       
    96 
       
    97 	/**
       
    98 	* Converts integer to string and adds it to current line.
       
    99 	*/
       
   100 	void AddInteger( int iValue, bool bSaveCarbideData = false );
       
   101 
       
   102 	/**
       
   103 	* Sets logging level.
       
   104 	* If value is invalid DEFAULT_LOGGING_LEVEL is used
       
   105 	* value must be between MIN_LOGGING_LEVEL and MAX_LOGGING_LEVEL
       
   106 	* @param iLoggingLevel Logging level.
       
   107 	*/
       
   108 	void SetLoggingLevel( int iLoggingLevel );
       
   109 
       
   110 	/**
       
   111 	* Gets logging level.
       
   112 	*
       
   113 	* @return Logging level.
       
   114 	*/
       
   115 	int GetLoggingLevel( void );
       
   116 
       
   117 	/**
       
   118 	* Sets print immediately flag.
       
   119 	*/
       
   120 	void SetPrintFlag( bool bPrintImmediately );
       
   121 
       
   122 	/**
       
   123 	* Sets data header for carbide data.
       
   124 	*/
       
   125 	void SaveCarbideDataHeader( void );
       
   126 
       
   127 	/**
       
   128 	* Initializes xercer xml parser.
       
   129 	*/
       
   130 	bool InitXML( void );
       
   131 
       
   132 	/**
       
   133 	* Writes data to xml tree.
       
   134 	*/
       
   135 	void SaveXML( string sInput, int iElementType );
       
   136 
       
   137 	/**
       
   138 	* Converts char* -> wchar_t*.
       
   139 	*/
       
   140 	static LPWSTR CharToWChar( const char* str );
       
   141 
       
   142 	/**
       
   143 	* Converts wchar_t* -> char*.
       
   144 	*/
       
   145 	static void WCharToChar( string& sInput, const WCHAR* Source );
       
   146 
       
   147 	void SetBuild( bool bUdebBuild );
       
   148 
       
   149 	void AddCarbideData( const string& sInput );
       
   150 
       
   151 	static string IntegerToString( int iValueToConvert );
       
   152 
       
   153 	//Define this class as a friend class for test class.
       
   154 	friend class CATTester;
       
   155 #ifndef MODULE_TEST
       
   156 private:
       
   157 #endif
       
   158 	vector<string> m_vLines;
       
   159 	string m_sLine;
       
   160 	string m_sCarbideDataLine;
       
   161 
       
   162 	string m_sCarbideDataHeader;
       
   163 
       
   164 	int m_iLoggingLevel;
       
   165 	int m_iRunNumber;
       
   166 	bool m_bPrintImmediately;
       
   167 	bool m_bXMLInitOk;
       
   168 	bool m_bUdebBuild;
       
   169 
       
   170 	xercesc::DOMDocument* m_pDomDoc;
       
   171 	xercesc::DOMElement* m_pRootElem;
       
   172 	xercesc::DOMElement* m_pCurrentLeakElem;
       
   173 	xercesc::DOMWriter* m_Serializer;
       
   174 	xercesc::DOMElement* m_pRunElement;
       
   175 	xercesc::DOMElement* m_pMemoryLeaks;
       
   176 	xercesc::DOMElement* m_pHandleLeaks;
       
   177 	xercesc::DOMElement* m_pCurrentSubTestElem;
       
   178 	xercesc::DOMElement* m_pSubtestMemoryLeaks;
       
   179 
       
   180 	/**
       
   181 	* Constructor.
       
   182 	*/
       
   183 	string GetStringUntilNextGivenChar( string& sInput, char cCharacter );
       
   184 
       
   185 };
       
   186 
       
   187 #endif