examples/Base/SemaphoreExample/inc/CDatabase.h

00001 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
00002 // All rights reserved.
00003 // License: "Symbian Foundation License v1.0" to Symbian Foundation
00004 // members and "Symbian Foundation End User License Agreement v1.0"
00005 // to non-members at the URL
00006 // "http://www.symbianfoundation.org/legal/licencesv10.html".
00007 //
00008 // Initial Contributors:
00009 // Nokia Corporation - initial contribution.
00010 //
00011 // Contributors:
00012 //
00013 // Description:
00014 // Contains the definition of the CDatabase class.
00015 //
00016 #ifndef CDATABASE_H_
00017 #define CDATABASE_H_
00018 
00019 #include <e32cons.h>
00020 #include <e32base.h>  //Used for CBase.
00021 #include <d32dbms.h>  //Used for RDbDatabase class.
00022 #include <s32file.h>  //Used for CFileStore class.
00023 
00028 class CDatabase : public CBase
00029 {
00030 public:
00031     static CDatabase* NewL();
00032     virtual ~CDatabase();
00033     
00034     //Method to create a database.
00035     void CreateDatabaseL();
00036     //Method to read the database. 
00037     void ReadfromDatabaseL();
00038     //Method to write into the database.
00039     void WritetoDatabaseL();
00040     
00041     //The callback function for ReaderThread associated with the CPeriodic object.
00042     static TInt PeriodicReadL(TAny* aPtr);
00043     //The periodic function to read the database. 
00044     void PeriodicReadFuncL();
00045     
00046     //The callback function for WriterThread associated with the CPeriodic object.
00047     static TInt PeriodicWriteL(TAny* aPtr);
00048     //The periodic function to write into the database.
00049     void PeriodicWriteFuncL();
00050 
00051 protected: 
00052     void ConstructL();
00053 
00054 private: 
00055     RFs iFsSession; //file session object.
00056     RDbStoreDatabase iDatabase; //database object.
00057     TFileName iDbname;
00058     
00059     //CPeriodic object to periodically read/write to the DB.
00060     CPeriodic* iPeriodic; 
00061     
00062     CConsoleBase* iConsole; 
00063     
00064     #ifdef USE_SEMAPHORE
00065     //Semaphore which schedules order of execution.  
00066     RSemaphore iSemWrite; 
00067     #endif
00068 };
00069 
00070 #endif /*CDATABASE_H_*/

Generated by  doxygen 1.6.2