imgtools/romtools/rofsbuild/symbolgenerator.h
author Ross Qin <ross.qin@nokia.com>
Fri, 29 Oct 2010 10:03:48 +0800
changeset 670 46ea84d14897
parent 662 60be34e1b006
permissions -rw-r--r--
remove migrated template meta data files (in DFS_MCL wk42)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
655
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents: 600
diff changeset
     1
/*
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents: 600
diff changeset
     2
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents: 600
diff changeset
     3
* All rights reserved.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents: 600
diff changeset
     4
* This component and the accompanying materials are made available
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents: 600
diff changeset
     5
* under the terms of the License "Eclipse Public License v1.0"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents: 600
diff changeset
     6
* which accompanies this distribution, and is available
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents: 600
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents: 600
diff changeset
     8
*
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents: 600
diff changeset
     9
* Initial Contributors:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents: 600
diff changeset
    10
* Nokia Corporation - initial contribution.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents: 600
diff changeset
    11
*
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents: 600
diff changeset
    12
* Contributors:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents: 600
diff changeset
    13
*
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents: 600
diff changeset
    14
* Description: 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents: 600
diff changeset
    15
*
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents: 600
diff changeset
    16
*/
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents: 600
diff changeset
    17
600
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    18
#ifndef __SYMBOLGENERATOR_H__
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    19
#define __SYMBOLGENERATOR_H__
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    20
#include <queue>
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    21
#include <string>
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    22
#include <fstream>
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    23
using namespace std;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    24
#include <boost/thread/thread.hpp>
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    25
#include <boost/thread/condition.hpp>
654
7c11c3d8d025 romtools 13.2.0.1
Zheng Shen <zheng.shen@nokia.com>
parents: 600
diff changeset
    26
#include "symbolprocessunit.h"
600
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    27
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    28
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    29
struct TPlacedEntry{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    30
    string iFileName;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    31
    bool iExecutable;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    32
    TPlacedEntry(const string& aName, bool aExecutable) {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    33
        iFileName = aName;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    34
        iExecutable = aExecutable;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    35
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    36
};
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    37
class SymbolGenerator : public boost::thread {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    38
    public:
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    39
        static SymbolGenerator* GetInstance();
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    40
        static void Release();
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    41
        void SetSymbolFileName( const string& fileName );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    42
        void AddFile( const string& fileName, bool isExecutable );
654
7c11c3d8d025 romtools 13.2.0.1
Zheng Shen <zheng.shen@nokia.com>
parents: 600
diff changeset
    43
        bool HasFinished()	{ return iFinished; }
7c11c3d8d025 romtools 13.2.0.1
Zheng Shen <zheng.shen@nokia.com>
parents: 600
diff changeset
    44
        void SetFinished();
7c11c3d8d025 romtools 13.2.0.1
Zheng Shen <zheng.shen@nokia.com>
parents: 600
diff changeset
    45
        bool IsEmpty() { return iQueueFiles.empty(); }
7c11c3d8d025 romtools 13.2.0.1
Zheng Shen <zheng.shen@nokia.com>
parents: 600
diff changeset
    46
        void LockOutput() { iOutputMutex.lock(); }
7c11c3d8d025 romtools 13.2.0.1
Zheng Shen <zheng.shen@nokia.com>
parents: 600
diff changeset
    47
        void UnlockOutput() { iOutputMutex.unlock(); }
7c11c3d8d025 romtools 13.2.0.1
Zheng Shen <zheng.shen@nokia.com>
parents: 600
diff changeset
    48
        TPlacedEntry GetNextPlacedEntry();
7c11c3d8d025 romtools 13.2.0.1
Zheng Shen <zheng.shen@nokia.com>
parents: 600
diff changeset
    49
        ofstream& GetOutputFileStream() { return iSymFile; };
600
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    50
    private:
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    51
        SymbolGenerator();
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    52
        ~SymbolGenerator();
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    53
        static void thrd_func();
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    54
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    55
        queue<TPlacedEntry> iQueueFiles;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    56
        boost::mutex iMutex;
654
7c11c3d8d025 romtools 13.2.0.1
Zheng Shen <zheng.shen@nokia.com>
parents: 600
diff changeset
    57
        boost::mutex iOutputMutex;
600
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    58
        static boost::mutex iMutexSingleton;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    59
        static SymbolGenerator* iInst;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    60
        boost::condition_variable iCond;
654
7c11c3d8d025 romtools 13.2.0.1
Zheng Shen <zheng.shen@nokia.com>
parents: 600
diff changeset
    61
        bool iFinished;
600
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    62
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    63
        ofstream iSymFile;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    64
};
654
7c11c3d8d025 romtools 13.2.0.1
Zheng Shen <zheng.shen@nokia.com>
parents: 600
diff changeset
    65
class SymbolWorker{
7c11c3d8d025 romtools 13.2.0.1
Zheng Shen <zheng.shen@nokia.com>
parents: 600
diff changeset
    66
public:
7c11c3d8d025 romtools 13.2.0.1
Zheng Shen <zheng.shen@nokia.com>
parents: 600
diff changeset
    67
	SymbolWorker();
7c11c3d8d025 romtools 13.2.0.1
Zheng Shen <zheng.shen@nokia.com>
parents: 600
diff changeset
    68
	~SymbolWorker();
7c11c3d8d025 romtools 13.2.0.1
Zheng Shen <zheng.shen@nokia.com>
parents: 600
diff changeset
    69
	void operator()();
7c11c3d8d025 romtools 13.2.0.1
Zheng Shen <zheng.shen@nokia.com>
parents: 600
diff changeset
    70
private:
7c11c3d8d025 romtools 13.2.0.1
Zheng Shen <zheng.shen@nokia.com>
parents: 600
diff changeset
    71
};
600
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    72
#endif