landmarks/locationlandmarks/localaccess/inc/EPos_CPosLmLocalOperation.h
changeset 0 667063e416a2
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/landmarks/locationlandmarks/localaccess/inc/EPos_CPosLmLocalOperation.h	Tue Feb 02 01:06:48 2010 +0200
@@ -0,0 +1,175 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:A local representation of the operation class.
+*
+*/
+
+
+#ifndef CPOSLMLOCALOPERATION_H
+#define CPOSLMLOCALOPERATION_H
+
+//  INCLUDES
+#include <EPos_CPosLmOperation.h>
+#include "epos_cposlmlocaldatabase.h"
+
+// FORWARD DECLARATION
+
+// CLASS DECLARATION
+
+/**
+* A local representation of the operation class. It provides an interface for
+* operations that are performed in small synchronous steps.
+*/
+class CPosLmLocalOperation : public CPosLmOperation
+    {
+
+    public:  // Constructors and destructor
+
+        /**
+        * Destructor.
+        */
+        IMPORT_C virtual ~CPosLmLocalOperation();
+
+    public: // New functions
+
+        /**
+        * Synchronous incremental execution of the operation. Performs a single
+        * step of the operation synchronously.
+        *
+        * Leaves with an error code if something goes wrong.
+        *
+        * @param aProgress Will be set to the progress of the operation when
+        * the step has finished.
+        * @return @p KPosLmOperationNotComplete if the step has completed but
+        *   more steps are needed before the operation has finished,
+        *   @p KErrNone if the operation has finished successfully.
+        */
+        virtual TInt NextStepL(
+        /* OUT */       TReal32& aProgress
+        ) = 0;
+
+        /**
+        * Handles any error generated by NextStepL. Will be called when
+        * NextStepL leaves. The error code is allowed to be changed, if
+        * necessary.
+        *
+        * @param aError An error code generated by NextStepL.
+        */
+        virtual void HandleError(
+        /* IN/OUT */    TInt& aError
+        ) = 0;
+
+        /**
+        * Handles a completed operation that has been successfully completed.
+        * Will be called when NextStepL returns with KErrNone.
+        *
+        * For CPosLmLocalOperation this function is empty.
+        */
+        virtual void HandleOperationCompleted();
+
+    public: // From base classes
+
+        /**
+        * From CPosLmOperation.
+        *
+        * Performs one step of the operation asynchronously.
+        *
+        * @param aStatus The request status. Will be completed when the step
+        *   has been performed. The request status will be @p KRequestPending
+        *   if the step has not completed. It will be
+        *   @p KPosLmOperationNotComplete if the step has completed but more
+        *   steps are needed before the operation has finished. The request
+        *   status will be @p KErrNone if the operation has finished
+        *   successfully. The status will be set to an error code if the
+        *   operation has failed.
+        * @param aProgress Will be set to the progress of the operation when the
+        *   step has finished.
+        */
+        IMPORT_C void NextStep(
+        /* OUT */   TRequestStatus& aStatus,
+        /* OUT */   TReal32& aProgress
+        );
+
+        /**
+        * From CPosLmOperation.
+        *
+        * Synchronous execution of the operation. Performs calls to NextStepL
+        * until the operation is completed.
+        *
+        * When this function returns, the operation has finished.
+        */
+        IMPORT_C void ExecuteL();
+
+    protected:
+
+        /**
+        * C++ default constructor.
+        * @param aDb A local database.
+        */
+        IMPORT_C CPosLmLocalOperation(
+        /* IN */        CPosLmLocalDatabase& aDb
+        );
+
+        /**
+        * Symbian 2nd phase constructor.
+        */
+        IMPORT_C void BaseConstructL();
+
+        /**
+        * Retrieves the current progress of the operation.
+        * Note: if called from the @p NextStepL function, this function returns
+        * the progress of the previous step.
+        * @return The progress of the operation.
+        */
+        TReal32 Progress();
+
+        /**
+        * Sets a lock on the database and remembers that a lock has been set.
+        *
+        * Leaves with KErrLocked if the aquired lock is not compatible with
+        * previous locks on the database.
+        *
+        * @param aLockType The type of lock to set.
+        */
+        IMPORT_C void AquireLockL(
+        /* IN  */       CPosLmLocalDatabase::TLockType aLockType
+        );
+
+        /**
+        * Releases the lock set by a previous call to AquireLockL and remembers
+        * that the lock has been released.
+        * Can be called several times, the lock is only released if a lock
+        * has been set.
+        */
+        IMPORT_C TInt ReleaseLock();
+
+    protected:  // Data
+
+        // Landmark database (no ownership).
+        CPosLmLocalDatabase* iDb;
+
+    private:    // Data
+
+        TInt iOperationStatus;
+
+        TReal32 iProgress;
+
+        TBool iHasDbLock;
+        CPosLmLocalDatabase::TLockType iLockType;
+
+    };
+
+#endif      // CPOSLMLOCALOPERATION_H
+
+// End of File