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