imgtools/imglib/symbolutil/symbolgenerator.h
changeset 695 46ca13b54f56
child 714 e5a58c351011
equal deleted inserted replaced
694:c3fbb20e86f0 695:46ca13b54f56
       
     1 /*
       
     2 * Copyright (c) 2010 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 *
       
    16 */
       
    17 
       
    18 #ifndef __SYMBOLGENERATOR_H__
       
    19 #define __SYMBOLGENERATOR_H__
       
    20 #include <queue>
       
    21 #include <string>
       
    22 #include <fstream>
       
    23 using namespace std;
       
    24 #include <boost/thread/thread.hpp>
       
    25 #include <boost/thread/condition.hpp>
       
    26 #include "symbolprocessunit.h"
       
    27 
       
    28 
       
    29 enum TSymbolType {
       
    30 	ESymCommon = 0,
       
    31 	ESymBsym ,
       
    32 };
       
    33 enum TImageType {
       
    34 	ERomImage = 0,
       
    35 	ERofsImage,
       
    36 	EUnknownType,
       
    37 };
       
    38 
       
    39 
       
    40 class SymbolGenerator : public boost::thread {
       
    41     public:
       
    42         static SymbolGenerator* GetInstance();
       
    43         static void Release();
       
    44         void SetSymbolFileName( const string& fileName );
       
    45         void AddFile( const string& fileName, bool isExecutable );
       
    46 	void AddEntry(const TPlacedEntry& aEntry);
       
    47         bool HasFinished()	{ return iFinished; }
       
    48         void SetFinished();
       
    49         bool IsEmpty() { return iQueueFiles.empty(); }
       
    50         void LockOutput() { iOutputMutex.lock(); }
       
    51         void UnlockOutput() { iOutputMutex.unlock(); }
       
    52         TPlacedEntry GetNextPlacedEntry();
       
    53         ofstream& GetOutputFileStream() { return iSymFile; };
       
    54         void AppendMapFileInfo(MapFileInfo& aMapFileInfo) { iMapFileInfoSet.push_back(aMapFileInfo); }
       
    55         void FlushSymbolFileContent();
       
    56 	void SetImageType(TImageType aImageType) {	iImageType = aImageType; };
       
    57 	TImageType GetImageType() {	return iImageType; };
       
    58     private:
       
    59         SymbolGenerator();
       
    60         ~SymbolGenerator();
       
    61         static void thrd_func();
       
    62 
       
    63         queue<TPlacedEntry> iQueueFiles;
       
    64         boost::mutex iMutex;
       
    65         boost::mutex iOutputMutex;
       
    66         static boost::mutex iMutexSingleton;
       
    67         static SymbolGenerator* iInst;
       
    68         boost::condition_variable iCond;
       
    69         bool iFinished;
       
    70         TSymbolType iSymbolType;
       
    71 	TImageType iImageType;
       
    72 
       
    73         ofstream iSymFile;
       
    74         MapFileInfoSet iMapFileInfoSet;
       
    75 };
       
    76 class SymbolWorker{
       
    77 public:
       
    78 	SymbolWorker();
       
    79 	~SymbolWorker();
       
    80 	void operator()();
       
    81 private:
       
    82 };
       
    83 class PageCompressWorker {
       
    84 public:
       
    85 	PageCompressWorker(TCompressedHeaderInfo* aHeaderInfo, char* aChar);
       
    86 	~PageCompressWorker();
       
    87 	void operator()();
       
    88 	static TCompressedHeaderInfo * pHeaderInfo;
       
    89 	static int currentPage;
       
    90 	static boost::mutex m_mutex;
       
    91 	static int m_error;
       
    92 	static char* iChar;
       
    93 };
       
    94 #endif