COOPY » Guide  version 0.6.5
/home/paulfitz/cvs/coopy_scm/coopy/src/libaccess/include/coopy/AccessTextBook.h
Go to the documentation of this file.
00001 #ifndef COOPY_ACCESSTEXTBOOK
00002 #define COOPY_ACCESSTEXTBOOK
00003 
00004 #include <coopy/TextBook.h>
00005 #include <coopy/TextBookFactory.h>
00006 
00007 namespace coopy {
00008   namespace store {
00014     namespace mdb {
00015       class AccessTextBook;
00016       class AccessTextBookFactory;
00017     }
00018   }
00019 }
00020 
00024 class coopy::store::mdb::AccessTextBook : public TextBook {
00025 public:
00026   AccessTextBook();
00027   virtual ~AccessTextBook();
00028 
00029   void clear();
00030 
00031   bool read(const char *fname);
00032 
00033   virtual bool open(const Property& config);
00034   
00035   std::vector<std::string> getNames() {
00036     return names;
00037   }
00038 
00039   PolySheet readSheet(const std::string& name);
00040 
00041   virtual bool inplace() const {
00042     return true;
00043   }
00044 
00045   virtual bool canWrite() const { 
00046     return false; 
00047   }
00048 
00049   virtual bool addSheet(const SheetSchema& schema);
00050 
00051 
00052   virtual std::string desc() const {
00053     return "AccessBook";
00054   }
00055 
00056 private:
00057   void *implementation;
00058 
00059   Property config;
00060 
00061   std::vector<std::string> names;
00062 
00063   std::vector<std::string> getNamesImpl();
00064 
00065   static int uses;
00066 
00067 };
00068 
00069 
00073 class coopy::store::mdb::AccessTextBookFactory : public TextBookFactory {
00074 public:
00075   virtual std::string getName() {
00076     return "access";
00077   }
00078 
00079   virtual TextBook *open(AttachConfig& config, AttachReport& report) {
00080     AccessTextBook *book = new AccessTextBook();
00081     if (book==NULL) return NULL;
00082     if (!book->open(config.options)) {
00083       delete book;
00084       book = NULL;
00085     }
00086     if (config.shouldWrite) {
00087       if (config.prevBook!=NULL) {
00088         if (!book->copy(*config.prevBook,config.options)) {
00089           delete book;
00090           book = NULL;
00091           report.msg = "data transfer failed";
00092         }
00093       }
00094     }
00095     if (book!=NULL) {
00096       report.success = true;
00097     }
00098     return book;
00099   }
00100 };
00101 
00102 #endif
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines