aknlayoutcompiler/src/MLCompData2LayPerf.cpp
changeset 0 f58d6ec98e88
child 1 b700e12870ca
equal deleted inserted replaced
-1:000000000000 0:f58d6ec98e88
       
     1 /*
       
     2 * Copyright (c) 2006 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:  
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // disable "identifier was truncated to '255' characters in the browser information" warning
       
    21 #pragma warning (disable:4786)
       
    22 
       
    23 // disable "decorated name length exceeded, name was truncated"
       
    24 #pragma warning (disable:4503)
       
    25 
       
    26 #include <cdlcompilertoolkit/cdltkprocess.h>
       
    27 #include <fstream>
       
    28 #include <iostream>
       
    29 #include <algorithm>
       
    30 
       
    31 #include "LayoutCompilerErr.h"
       
    32 #include "MLCompDataParse.h"
       
    33 #include "MLAttributesParse.h"
       
    34 #include "MLCompData2LayPerf.h"
       
    35 #include "MLCompDataLayPerfWriter.h"
       
    36 
       
    37 typedef LayoutProcessArgsErr<MLCompDataToLayPerf> MLCompDataToLayPerfArgsErr;
       
    38 
       
    39 const string KCompDataFileNameSuffix("compData");
       
    40 const string KAttributesFileNameSuffix("attributes");
       
    41 
       
    42 //------------------------------------
       
    43 // class MLCompDataToLayPerf
       
    44 //------------------------------------
       
    45 int MLCompDataToLayPerf::Process(const vector<string>& args)
       
    46 	{
       
    47 	if (args.size() != 6)
       
    48 		throw MLCompDataToLayPerfArgsErr();
       
    49 
       
    50     int arg = 2;
       
    51 	string cdlName = args[arg++];
       
    52 
       
    53 	CCdlTkCdlFileParser parser(cdlName);
       
    54 	auto_ptr<CCdlTkInterface> iface(parser.LoadAndParse(true));
       
    55 
       
    56 	int numLayouts = args.size() - 4;
       
    57 	if (numLayouts < 1)
       
    58 		throw MLCompDataToLayPerfArgsErr();
       
    59 
       
    60 	TMLCompData* mergedLayout = NULL;
       
    61 	TMLAttributes* mergedAttribs = NULL;
       
    62     for(int ii = 0; ii < numLayouts; ii++)
       
    63         {
       
    64 		string layoutName = args[arg++];
       
    65 		string attribsName = CdlTkUtil::Replace(KCompDataFileNameSuffix, KAttributesFileNameSuffix, layoutName);
       
    66 
       
    67 		auto_ptr<TMLCompDataParseLayout> layoutParse = TMLCompDataParseLayout::Parse(layoutName);
       
    68 		auto_ptr<TMLCompData> layout(layoutParse.get());
       
    69 		layoutParse.release();
       
    70 
       
    71 		auto_ptr<TMLAttributesParse> attribsParse = TMLAttributesParse::Parse(attribsName);
       
    72 		auto_ptr<TMLAttributes> attribs(attribsParse.get());
       
    73 		attribsParse.release();
       
    74 
       
    75 		if (mergedLayout || mergedAttribs)
       
    76 			{
       
    77 			// first we merge the components and the attributes
       
    78 			mergedLayout->MergeComponents(*layout);
       
    79 			mergedAttribs->Merge(*attribs);
       
    80 			}
       
    81 		else
       
    82 			{
       
    83 			// first time around
       
    84 			mergedLayout = layout.get();
       
    85 			mergedAttribs = attribs.get();
       
    86 			}
       
    87         layout.release();
       
    88 		attribs.release();
       
    89         }
       
    90 
       
    91 	mergedLayout->iAttributes = mergedAttribs; // transfer ownership
       
    92 
       
    93 	// once merged, we can compile the tables
       
    94     mergedLayout->Compile();
       
    95 
       
    96 
       
    97 	string destLayout = args[arg++];
       
    98 	MLCompDataToLayPerf layPerf(cdlName, *iface, *mergedLayout, destLayout);
       
    99 	layPerf.WriteLayout();
       
   100 
       
   101 	return 0;
       
   102 	}
       
   103 
       
   104 void MLCompDataToLayPerf::ShowHelp(ostream& stream)
       
   105 	{
       
   106 	stream << "MLCompData2LayPerf <layout.cdl> (<MLCompDataName>)+ <layPerf.cpp> " << endl;
       
   107 	stream << "MLCompData2LayPerf ..\\cdl\\AknLayoutScalable_Avkon.cdl ..\\xml\\pdp_av_dbl_prt\\display_eur_compData.xml ..\\xml\\pdl_av_dbl_lsc\\display_eur_compData.xml ..\\generated\\LayPerf_AknLayoutScalable_Avkon.cpp " << endl;
       
   108 	stream << "  This converts a CDL file into a specialised format for inclusion in the LayPerfScalable2 test app." << endl;
       
   109 	stream << "  LayPerfScalable2 runs on the device, calling each API that would be generated from the CDL file." << endl;
       
   110 	}
       
   111 
       
   112 MLCompDataToLayPerf::MLCompDataToLayPerf(const string& aCdlName, CCdlTkInterface& aInterface, TMLCompData& aSourceLayout, const string& aDestLayoutName)
       
   113     :	
       
   114 	iCdlName(aCdlName),
       
   115 	iInterface(aInterface), 
       
   116 	iLayout(aSourceLayout),
       
   117 	iDestLayoutName(aDestLayoutName)
       
   118 	{
       
   119 	}
       
   120 
       
   121 void MLCompDataToLayPerf::WriteLayout()
       
   122 	{
       
   123 	TMLCompDataLayPerfWriter writer(iInterface, iLayout, iDestLayoutName);
       
   124 	writer.Write(iCdlName);
       
   125 	}
       
   126