ocrsrv_stub/inc/ocrsharedata.h
changeset 0 0ce1b5ce9557
equal deleted inserted replaced
-1:000000000000 0:0ce1b5ce9557
       
     1 /*
       
     2 * Copyright (c) 2002 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:  Shared data definitions
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef OCRSHAREDATA_H
       
    20 #define OCRSHAREDATA_H
       
    21 
       
    22 // INCLUDES FILES
       
    23 #include <ocrcommon.h>
       
    24 
       
    25 // DATA TYPES
       
    26 
       
    27 /** Request definitions between main thread and child thread */
       
    28 enum TEngineCmd
       
    29     {
       
    30     ECmdInvalid = 0,                    // Invalid  
       
    31     ECmdLayout,                         // Layout
       
    32     ECmdRecognize,                      // Recognize
       
    33     ECmdRecognizeBlock,                 // Recognize block
       
    34     ECmdRecognizeSpecialRegion,         // Recognize special region
       
    35     ECmdSetLanguage,                    // Set language 
       
    36     ECmdGetLanguage,                    // Get language 
       
    37     ECmdRefresh,                        // Refresh
       
    38     ECmdExit,                           // Exit
       
    39     ECmdLayoutComplete,                 // Layout complete
       
    40     ECmdRecognizeComplete,              // Recognize complete
       
    41     ECmdRecognizeBlockComplete,         // Recognize block complete
       
    42     ECmdRecognizeSpecialRegionComplete, // Recognize special region complete
       
    43     ECmdRecogProcess,                   // Recognize progress
       
    44     ECmdIsLanguageSupported             // Just if supporting the language
       
    45     };
       
    46 
       
    47 // FORWARD DECLARATIONS
       
    48 class CEngineAdaptor;
       
    49 class EngineThread;
       
    50 
       
    51 // CLASS DECLARATION
       
    52 
       
    53 /**
       
    54  *  Shared data between threads
       
    55  *
       
    56  *  Wrapper class for share data between main thread and child thread
       
    57  *
       
    58  *  @lib ocrsrv.lib
       
    59  *  @since S60 v3.1
       
    60  */
       
    61 class CShareData : public CBase
       
    62     {
       
    63     friend class CEngineAdaptor;
       
    64     friend class EngineThread;
       
    65 
       
    66 public:  // Constructors and destructor
       
    67 
       
    68     /**
       
    69     * Symbian Two-phased constructor.
       
    70     */
       
    71     static CShareData* NewL();
       
    72     
       
    73     /**
       
    74     * C++ Default Destructor.
       
    75     */
       
    76    virtual ~CShareData();
       
    77 
       
    78 public: // New functions
       
    79 
       
    80     /**
       
    81     * Enter Share Section
       
    82     * @since S60 v3.1
       
    83     * @return None
       
    84     */
       
    85     inline void EnterShareSection();
       
    86 
       
    87     /**
       
    88     * Leave Share Section
       
    89     * @since S60 v3.1
       
    90     * @return None
       
    91     */
       
    92     inline void LeaveShareSection();
       
    93     
       
    94 private:
       
    95 
       
    96     /**
       
    97     * C++ default constructor
       
    98     */
       
    99     CShareData();
       
   100 
       
   101     /**
       
   102     * Default Symbian 2nd phase constructor
       
   103     */
       
   104     void ConstructL();
       
   105 
       
   106 private:    // Data
       
   107 
       
   108     /**
       
   109     * Share data mutex
       
   110     */
       
   111     RMutex iShareMutex;
       
   112     
       
   113     /**
       
   114     * Notifier for the shared data
       
   115     */
       
   116     RSemaphore iNotifier;
       
   117     
       
   118     /**
       
   119     * Save active language information
       
   120     */
       
   121     RArray<TInt> iActiveLanguage;
       
   122     
       
   123     /**
       
   124     * Save installed language information
       
   125     */
       
   126     RArray<TInt> iInstalledLanguage;
       
   127 
       
   128     /**
       
   129     * Command sent to child thread
       
   130     */
       
   131     TEngineCmd iCmd;
       
   132     
       
   133     /**
       
   134     * Command sent from child thread to main thread
       
   135     */
       
   136     TEngineCmd iCmdRet;
       
   137 
       
   138     /** 
       
   139     * Recognized first block's pointer (Own)
       
   140     */
       
   141     TOCRBlockInfo* iFirstBlock;
       
   142     
       
   143     /**
       
   144     * Information of selected blocks
       
   145     */
       
   146     TOCRBlockInfo* iSelectedBlocks;
       
   147     
       
   148     /**
       
   149     * Information of text region
       
   150     */
       
   151     TOCRTextRgnInfo* iTextRgnInfo;                                       
       
   152                      
       
   153     /**
       
   154     * Number of blocks recognized
       
   155     */                   
       
   156     TInt iBlockCount;
       
   157 
       
   158     /**
       
   159     * OCR binary image (Own)
       
   160     */
       
   161     HBufC8* iBinaryImage;
       
   162     
       
   163     /**
       
   164     * Handle to the image
       
   165     */
       
   166     TInt iImageHandle;
       
   167 
       
   168     /**
       
   169     * Layout setting
       
   170     */
       
   171     TOCRLayoutSetting iLayoutSettings;
       
   172     
       
   173     /**
       
   174     * Recognzie setting
       
   175     */
       
   176     TOCRRecognizeSetting iRecognizeSettings;
       
   177     
       
   178     /**
       
   179     * Layout block information
       
   180     */
       
   181     TOCRLayoutBlockInfo iLayoutInfo;
       
   182     
       
   183     /**
       
   184     * Region information
       
   185     */
       
   186     TRegionInfo iRegionInfo;
       
   187 
       
   188     /**
       
   189     * Cancel flag
       
   190     */
       
   191     TBool iCanceled;
       
   192 
       
   193     /**
       
   194     * Main thread id
       
   195     */
       
   196     TThreadId iMainThreadId;
       
   197 
       
   198     /** 
       
   199     * Percent of the progress
       
   200     */
       
   201     TUint iPercent;
       
   202 
       
   203     /**
       
   204     * Error code from the engine
       
   205     */
       
   206     TInt iError;
       
   207 
       
   208     /**
       
   209     * Pointer to Active object's status variable (Not Own)
       
   210     */
       
   211     TRequestStatus* iActiveStatus;
       
   212     
       
   213     /**
       
   214     * Pointer to normal status variable (Not Own)
       
   215     */
       
   216     TRequestStatus* iRequestStatus;
       
   217     
       
   218     /**
       
   219     * Name of the target dll
       
   220     */
       
   221     TFileName iTargetDll;
       
   222     };
       
   223 
       
   224 // -----------------------------------------------------------------------------
       
   225 // CShareData::EnterShareSection
       
   226 // Description : Enter share section
       
   227 // -----------------------------------------------------------------------------
       
   228 //
       
   229 inline void CShareData::EnterShareSection()
       
   230     {
       
   231     iShareMutex.Wait();
       
   232     }
       
   233 
       
   234 // -----------------------------------------------------------------------------
       
   235 // CShareData::LeaveShareSection
       
   236 // Description : Leave share section
       
   237 // -----------------------------------------------------------------------------
       
   238 //
       
   239 inline void CShareData::LeaveShareSection()
       
   240     {
       
   241     iShareMutex.Signal();
       
   242     }
       
   243     
       
   244 #endif      // OCRSHAREDATA_H   
       
   245             
       
   246 // End of File