rasdaman complete source
dbmddset.hh
Go to the documentation of this file.
1 /*
2 * This file is part of rasdaman community.
3 *
4 * Rasdaman community is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * Rasdaman community is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with rasdaman community. If not, see <http://www.gnu.org/licenses/>.
16 *
17 * Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann /
18 rasdaman GmbH.
19 *
20 * For more information please see <http://www.rasdaman.org>
21 * or contact Peter Baumann via <baumann@rasdaman.com>.
22 */
23 #ifndef _MDDSET_HH_
24 #define _MDDSET_HH_
25 
26 class MDDSet;
27 class OId;
28 class EOId;
29 class r_Error;
30 class DBMDDObj;
31 class CollectionType;
32 
33 #include "reladminif/lists.h"
34 #include "mddid.hh"
36 #include "reladminif/dbref.hh"
37 
38 //@ManMemo: Module: {\bf mddif}
39 /*@Doc:
40  MDDSet is the persistent class for collections of MDD objects.
41 
42  Each instance of MDDSet represents a collection stored in the base
43  DBMS.
44 
45  This class should only be used by DBMDDColl.
46 */
47 
52 class DBMDDSet : public DBNamedObject
53 {
54 public:
55  DBMDDSet(const char* name, const CollectionType* type) throw (r_Error);
56  /*@Doc:
57  creates a new set
58  */
59 
60  DBMDDSet(const char* name, const OId& id, const CollectionType* type) throw (r_Error);
61  /*@Doc:
62  creates a new set
63  */
64 
65  static DBMDDSetId getDBMDDSet(const char* name) throw (r_Error);
66 
67  static DBMDDSetId getDBMDDSet(const OId& id) throw (r_Error);
68 
69  static bool deleteDBMDDSet(const OId& id);
70  /*@Doc:
71  returns succes
72  */
73 
74  static bool deleteDBMDDSet(const char* name);
75  /*@Doc:
76  returns succes
77  */
78 
79  virtual void printStatus(unsigned int level = 0, std::ostream& stream = std::cout) const;
80 
81  virtual void setPersistent(bool state) throw (r_Error);
82  /*@Doc:
83  throws r_Error when the mdd set may not be made persistent.
84  */
85 
86  void insert(DBMDDObjId newObj);
87  /*@Doc:
88  Inserts an object into the MDD Collection.
89  The persistent reference count of this DBMDDObj is updated.
90  */
91 
92  DBMDDObjIdIter* newIterator() const;
93  /*@Doc:
94  Returns a new iterator for this collection.
95  */
96 
97  unsigned int getCardinality() const;
98  /*@Doc:
99  Returns the number of elements in the collection.
100  */
101 
102  void remove(DBMDDObjId& obj);
103  /*@Doc:
104  Removes an object from the MDD Collection.
105  The persistent reference count of this DBMDDObj is updated.
106  */
107 
108  void removeAll();
109  /*@Doc:
110  Removes all objects from the MDD Collection.
111  The persistent reference count of the DBMDDObjs is updated.
112  */
113 
114  void releaseAll();
115  /*@Doc:
116  Releases all dynamic memory used by this collection.
117  */
118 
119  bool contains_element(const DBMDDObjId& elem) const;
120  /*@Doc:
121  */
122 
123  virtual ~DBMDDSet( );
124  /*@Doc:
125  */
126 
127  void deleteName();
128  /*@Doc:
129  sets the name of this object to a null string.
130  used by DatabaseIf::destroyRoot
131  */
132 
133  virtual r_Bytes getMemorySize() const;
134  /*@Doc:
135  */
136 
137  const CollectionType* getCollType() const;
138  /*@Doc:
139  Returns the collectiontype of this entry.
140  */
141 
142 protected:
143  friend class ObjectBroker;
144 
145  typedef std::set<DBMDDObjId, std::less<DBMDDObjId> > DBMDDObjIdSet;
146 
147  DBMDDSet(const OId& id) throw (r_Error);
148  /*@Doc:
149  gets an existing coll from the db
150  */
151 
152  virtual void updateInDb() throw(r_Error);
153  /*@Doc:
154  */
155 
156  virtual void insertInDb() throw(r_Error);
157  /*@Doc:
158  */
159 
160  virtual void readFromDb() throw(r_Error);
161  /*@Doc:
162  */
163 
164  virtual void deleteFromDb() throw(r_Error);
165  /*@Doc:
166  */
167 
168 private:
169  DBMDDObjIdSet mySet;
170  /*@Doc:
171  Memory representation of the list of oids of DBMDDObjs.
172  */
173 
174  const CollectionType* collType;
175  /*@Doc:
176  Pointer to the collectiontype.
177  */
178 };
179 
180 #endif
void insert(DBMDDObjId newObj)
Definition: dbnamedobject.hh:40
virtual r_Bytes getMemorySize() const
static bool deleteDBMDDSet(const OId &id)
Definition: eoid.hh:52
virtual void insertInDb()
const CollectionType * getCollType() const
DBMDDObjIdIter * newIterator() const
Definition: dbmddobj.hh:65
Definition: dbobjectiditerator.hh:30
Definition: objectbroker.hh:71
virtual void printStatus(unsigned int level=0, std::ostream &stream=std::cout) const
virtual ~DBMDDSet()
Definition: oidif.hh:67
virtual void updateInDb()
void releaseAll()
bool contains_element(const DBMDDObjId &elem) const
unsigned int getCardinality() const
std::set< DBMDDObjId, std::less< DBMDDObjId > > DBMDDObjIdSet
Definition: dbmddset.hh:145
Definition: relcatalogif/collectiontype.hh:59
static DBMDDSetId getDBMDDSet(const char *name)
Definition: dbmddset.hh:52
DBMDDSet(const char *name, const CollectionType *type)
virtual void readFromDb()
virtual void setPersistent(bool state)
void deleteName()
Definition: dbobject.hh:29
virtual void deleteFromDb()
void removeAll()