imgtools/romtools/rofsbuild/symbolgenerator.h
changeset 708 0757c2976f96
parent 707 ccd52fece6ff
parent 706 5221386d044b
child 709 1ec2202bb75b
equal deleted inserted replaced
707:ccd52fece6ff 708:0757c2976f96
     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 struct TPlacedEntry{
       
    30     string iFileName;
       
    31     bool iExecutable;
       
    32     TPlacedEntry(const string& aName, bool aExecutable) {
       
    33         iFileName = aName;
       
    34         iExecutable = aExecutable;
       
    35     }
       
    36 };
       
    37 class SymbolGenerator : public boost::thread {
       
    38     public:
       
    39         static SymbolGenerator* GetInstance();
       
    40         static void Release();
       
    41         void SetSymbolFileName( const string& fileName );
       
    42         void AddFile( const string& fileName, bool isExecutable );
       
    43         bool HasFinished()	{ return iFinished; }
       
    44         void SetFinished();
       
    45         bool IsEmpty() { return iQueueFiles.empty(); }
       
    46         void LockOutput() { iOutputMutex.lock(); }
       
    47         void UnlockOutput() { iOutputMutex.unlock(); }
       
    48         TPlacedEntry GetNextPlacedEntry();
       
    49         ofstream& GetOutputFileStream() { return iSymFile; };
       
    50     private:
       
    51         SymbolGenerator();
       
    52         ~SymbolGenerator();
       
    53         static void thrd_func();
       
    54 
       
    55         queue<TPlacedEntry> iQueueFiles;
       
    56         boost::mutex iMutex;
       
    57         boost::mutex iOutputMutex;
       
    58         static boost::mutex iMutexSingleton;
       
    59         static SymbolGenerator* iInst;
       
    60         boost::condition_variable iCond;
       
    61         bool iFinished;
       
    62 
       
    63         ofstream iSymFile;
       
    64 };
       
    65 class SymbolWorker{
       
    66 public:
       
    67 	SymbolWorker();
       
    68 	~SymbolWorker();
       
    69 	void operator()();
       
    70 private:
       
    71 };
       
    72 #endif