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){ ...

Get Palm Programming: The Developer's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.