home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 Mobile / Chip_Mobile_2001.iso / palm / business / printcar / printcar.exe / src / CardRecord.h < prev    next >
C/C++ Source or Header  |  2000-06-10  |  2KB  |  84 lines

  1. //
  2. //  $Id: CardRecord.h,v 1.4 2000/06/10 00:19:40 sergey Exp $
  3. //
  4.  
  5. #ifndef _CardRecord_h_
  6. #define _CardRecord_h_
  7.  
  8. #include "DB/RecordType.h"
  9.  
  10. namespace DB { class ResourceDatabase; }
  11.  
  12.  
  13. //
  14. // This is the Card record class.
  15. // All the data of it's instance loaded from the resource database.
  16. //
  17. // Card record encoded in the resources database as a sequence of resources.
  18. // Each record' resources begins with the number module 10. For instance:
  19. //
  20. //  rec #1:
  21. //      5000: strRes, name
  22. //      5001: strRes, script
  23. //      5002: bitmapRes, image
  24. //      5003: strRes, libScriptID
  25. //
  26. //  ...
  27. //  rec #N:
  28. //      50N0: strRes, name
  29. //      50N1: strRes, script
  30. //      50N2: bitmapRes, image
  31. //
  32. //  ...
  33. //  lib script:
  34. //      4001: strRes, libScript
  35. //
  36. class CardRecord
  37. {
  38. public:
  39.     CardRecord();
  40.     ~CardRecord();
  41.  
  42. private:
  43.     CardRecord(const CardRecord&);
  44.     CardRecord& operator =(const CardRecord&);
  45.  
  46. // operations
  47. public:
  48.     // Record index is a relative offset from the "base" resource number in the Card DB.
  49.     bool load(int recordIndex, const DB::ResourceDatabase& cardDb);
  50.  
  51. // attributes
  52.  
  53.     const char* name() const        { return _name.data(); }
  54.     const char* script() const      { return _script.data(); }
  55.     BitmapPtr image() const         { return _image.data(); }
  56.  
  57.     // Some cards could use some "library" scripts.
  58.     // In case of this method returns non null we must execute it before the "main" card script
  59.     const char* libScript() const   { return _libScript.data(); }
  60.  
  61. // utilities
  62.  
  63.     // Calculates amount of card records in the Card DB.
  64.     static int countRecords(const DB::ResourceDatabase& cardDb);
  65.  
  66. // implementation
  67. private:
  68.     void loadImage(const DB::ResourceDatabase& cardDb, int cardID);
  69.     bool loadLibScript(const DB::ResourceDatabase& cardDb, int cardID);
  70.  
  71. // data members
  72. private:
  73.     typedef DB::RecordType<const char*> StringResource;
  74.     typedef DB::RecordType<BitmapPtr>   BitmapResource;
  75.  
  76.     StringResource _name;
  77.     StringResource _script;
  78.     BitmapResource _image;
  79.  
  80.     StringResource _libScript;
  81. };
  82.  
  83. #endif  // _CardRecord_h_
  84.