COOPY » Guide  version 0.6.5
/home/paulfitz/cvs/coopy_scm/coopy/src/libcoopy_core/include/coopy/SchemaSniffer.h
Go to the documentation of this file.
00001 #ifndef COOPY_SCHEMA_SNIFFER
00002 #define COOPY_SCHEMA_SNIFFER
00003 
00004 #include <coopy/SheetSchema.h>
00005 #include <coopy/DataSheet.h>
00006 #include <coopy/NameSniffer.h>
00007 
00008 namespace coopy {
00009   namespace store {
00010     class SchemaSniffer;
00011   }
00012 }
00013 
00014 class coopy::store::SchemaSniffer {
00015 private:
00016   SimpleSheetSchema fallback;
00017   SheetSchema *schema;
00018   const DataSheet *sheet;
00019   NameSniffer *ns;
00020   std::string name;
00021 public:
00022 
00023   SchemaSniffer() {
00024     sheet = 0;
00025     schema = 0;
00026     ns = 0;
00027   }
00028 
00029   SchemaSniffer(const DataSheet& sheet, const char *name = NULL, bool delayed = false) {
00030     this->sheet = 0;
00031     schema = 0;
00032     ns = 0;
00033     setSheet(sheet,name,delayed);
00034   }
00035 
00036   virtual ~SchemaSniffer() {
00037     if (ns) {
00038       delete ns;
00039       ns = 0;
00040     }
00041   }
00042 
00043   void setSheet(const DataSheet& sheet, const char *name = NULL, bool delayed = false) {
00044     this->sheet = &sheet;
00045     schema = 0;
00046     if (name) {
00047       this->name = name;
00048     }
00049     if (!delayed) {
00050       sniff();
00051     }
00052   }
00053 
00054   void sniff(bool force = false); 
00055   void resniff(coopy::store::SchemaSniffer& alt); 
00056 
00057   virtual SheetSchema *suggestSchema();
00058 };
00059 
00060 #endif
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines