COOPY » Guide  version 0.6.5
/home/paulfitz/cvs/coopy_scm/coopy/src/libcoopy_full/include/coopy/ShortTextBook.h
Go to the documentation of this file.
00001 #ifndef COOPY_SHORTTEXTBOOK
00002 #define COOPY_SHORTTEXTBOOK
00003 
00004 #include <coopy/TextBook.h>
00005 #include <coopy/CsvSheet.h>
00006 #include <coopy/TextBookFactory.h>
00007 #include <coopy/Dbg.h>
00008 
00009 namespace coopy {
00010   namespace store {
00011     class ShortTextBook;
00012   }
00013 }
00014 
00020 class coopy::store::ShortTextBook : public TextBook {
00021 public:
00022   std::string name;
00023   int provides;
00024   CsvSheet sheet;
00025 
00026   ShortTextBook() : name(coopy_get_default_table_name()) {
00027     provides = 0;
00028   }
00029 
00030   virtual std::vector<std::string> getNames() {
00031     std::vector<std::string> result;
00032     result.push_back(name);
00033     return result;
00034   }
00035 
00036   virtual PolySheet readSheet(const std::string& name) {
00037     if (name==this->name) {
00038       return PolySheet(&sheet,false);
00039     }
00040     return PolySheet();
00041   }
00042 
00043   virtual bool open(const Property& config);
00044 
00045   virtual PolySheet provideSheet(const SheetSchema& schema) {
00046     if (provides==0) {
00047       provides++;
00048       name = schema.getSheetName();
00049       if (sheet.applySchema(schema)) {
00050         PolySheet s = readSheet(name);
00051         if (s.isValid()) {
00052           sheet.setSchema(Poly<SheetSchema>(schema.clone(),true));
00053           return s;
00054         }
00055         return s;
00056       }
00057     }
00058     return PolySheet();
00059   }
00060 
00061   virtual std::string desc() const {
00062     return "CsvBook";
00063   }
00064 
00065   virtual bool namedSheets() const {
00066     return false;
00067   }
00068 };
00069 
00070 #endif
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines