Dataspace.h

00001 /* 
00002    EyeDB Object Database Management System
00003    Copyright (C) 1994-2008 SYSRA
00004    
00005    EyeDB is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Lesser General Public
00007    License as published by the Free Software Foundation; either
00008    version 2.1 of the License, or (at your option) any later version.
00009    
00010    EyeDB is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Lesser General Public License for more details.
00014    
00015    You should have received a copy of the GNU Lesser General Public
00016    License along with this library; if not, write to the Free Software
00017    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA 
00018 */
00019 
00020 /*
00021    Author: Eric Viara <viara@sysra.com>
00022 */
00023 
00024 
00025 #ifndef _EYEDB_DATASPACE_H
00026 #define _EYEDB_DATASPACE_H
00027 
00028 namespace eyedb {
00029 
00035   class Database;
00036 
00037   class Dataspace {
00038 
00039   public:
00044     Database *getDatabase() {return db;}
00045 
00050     const Database *getDatabase() const {return db;}
00051 
00056     const char *getName() const {return name;}
00057 
00062     bool isValid() const;
00063 
00068     unsigned short getId() const {return id;}
00069 
00075     const Datafile **getDatafiles(unsigned int &_datafile_cnt) const {
00076       _datafile_cnt = datafile_cnt;
00077       return datafiles;
00078     }
00079 
00085     Status getCurrentDatafile(const Datafile *&datafile) const;
00086 
00092     Status setCurrentDatafile(const Datafile *datafile);
00093 
00098     Status remove() const;
00099 
00105     Status rename(const char *newname) const;
00106 
00113     Status update(const Datafile **datafiles, unsigned int datafile_cnt) const;
00114 
00115     static const short DefaultDspid;
00116 
00117   private:
00118     Dataspace(Database *_db, unsigned short _id, const char *_name,
00119               const Datafile **_datafiles, unsigned int _datafile_cnt) :
00120       db(_db), id(_id), name(strdup(_name)), datafiles(_datafiles),
00121       datafile_cnt(_datafile_cnt), cur_datafile(0) { }
00122 
00123     static char **makeDatid(const Datafile **, unsigned int);
00124     static void freeDatid(char **, unsigned int);
00125 
00126     Database *db;
00127     unsigned short id;
00128     char *name;
00129     const Datafile **datafiles;
00130     unsigned int datafile_cnt;
00131     const Datafile *cur_datafile;
00132 
00133     ~Dataspace();
00134 
00135     friend class Database;
00136   };
00137 
00138   std::ostream& operator<<(std::ostream&, const Dataspace &);
00139 
00144 }
00145 
00146 #endif

Generated on Mon Dec 22 18:15:53 2008 for eyedb by  doxygen 1.5.3