O'Reilly logo

Palm Programming: The Developer's Guide by Julie McKeehan, Neil Rhodes

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Sales Conduit Based on Generic Conduit

Warning

This sample was based on an early beta version of the Generic Conduit and may not compile with the version available to you. For a more current version of the sample, see http://www.oreilly.com/ catalog/palmprog/.

CSalesPCMgr

We have derived a new class from CPcMgr, because we want to support the same a tab-delimited text format we used with the alternative conduit classes. Here is our new class:

class CSalesPcMgr: public CPcMgr
{
public:
    CSalesPcMgr(CPLogging *pLogging, char *szDbName, 
      TCHAR *pFileName = NULL, TCHAR *pDirName = NULL, 
      DWORD dwGenericFlags,
      eSyncTypes syncType = eDoNothing);

protected:
    virtual long StoreDB(void);
    virtual long RetrieveDB(void);
};

CSalesPCMgr constructor

Our constructor just initializes the base class:

CSalesPcMgr::CSalesPcMgr(CPLogging *pLogging, char *szDbName, 
   TCHAR *pFileName, TCHAR *pDirName, 
   DWORD dwGenericFlags, eSyncTypes syncType)
   :CPcMgr(pLogging, szDbName, pFileName, pDirName, dwGenericFlags,
      syncType)
{
}

StoreDB function

Our StoreDB routine writes the list of records in text-delimited format:

long CSalesPcMgr::StoreDB(void) { if ( !m_bNeedToSave) { // if no changes, don't waste time saving return 0; } long retval = OpenDB(); if (retval) return GEN_ERR_UNABLE_TO_SAVE; for (DWORD dwIndex = 0; (dwIndex < m_dwMaxRecordCount) && (!retval); dwIndex++){ if (!m_pRecordList[dwIndex]) // if there is no record, skip ahead continue; retval = WriteRecord(m_hFile, m_pRecordList[dwIndex]); if (retval != 0){ ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required