rasdaman client API  10.6.3
The Array Analytics Engine: Datacubes at Your Fingertips
collection.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 
24 #ifndef _D_COLLECTION_
25 #define _D_COLLECTION_
26 
27 #include "rasodmg/object.hh"
28 
29 template <class T>
30 class r_Iterator;
31 
32 //@ManMemo: Module: {\bf rasodmg}
42 template <class T>
43 class r_Collection : public r_Object
44 {
45  friend class r_Iterator<T>;
46 
47 public:
51  r_Collection(const r_Collection<T> &collection);
53  virtual ~r_Collection();
54 
56  virtual void r_deactivate();
57 
59  unsigned long cardinality() const;
60 
62  bool is_empty() const;
64  bool is_ordered() const;
66  bool allows_duplicates() const;
67 
69  bool contains_element(const T &element) const;
71  virtual void insert_element(const T &element, int no_modification = 0);
78  virtual void remove_element(const T &element);
80  void remove_all();
81 
83  const r_Collection<T> &operator=(const r_Collection<T> &collection);
84 
87 
90 
91  //@Man: Methods for database communication (internal use only):
93 
96  virtual void insert_obj_into_db();
97 
99  virtual void insert_obj_into_db(const char *)
100  {
101  ;
102  };
109  virtual void update_obj_in_db();
110 
112 
113 
114 protected:
116  struct CNode
117  {
119  T *elem;
120  };
121 
122  //@Man: Methods/Attributes for maintainance of removed objects
124 
128 
132 
134 
135 
136  //@Man: Attributes storing some state information
138  int isOrdered;
144  unsigned long card;
146 
147 
148  // Normally, we would have used the following class to implement the
149  // internal structure of a r_Collection. But for RPC's sake, we use
150  // a simple structure. (RPC is not able to transfer C++ objects.)
151  //
152  // template <class T>
153  // class CNode
154  // {
155  // public:
156  // CNode();
157  // CNode( const CNode& cnode );
158  // ~CNode();
159  //
160  // inline CNode* get_next() const;
161  // inline void set_next( const CNode& cnode );
162  // inline T* get_elem() const;
163  // inline void set_elem( const T& element);
164  //
165  // private:
166  // CNode* next;
167  // T* elem;
168  // }
169 
170  //@Man: Methods for manipulating CNode lists
172 
175  void add_node(CNode *&root, const T &element);
177  bool remove_node(CNode *&root, const T &element);
179  void remove_all_nodes(CNode *&root);
181  void init_node_list(CNode *&root);
182 
184 
185 
188 };
189 
190 class r_GMarray;
191 extern template class r_Collection<r_GMarray *>;
192 class r_Ref_Any;
193 extern template class r_Collection<r_Ref_Any>;
194 
195 template <typename T>
196 class r_Ref;
197 class r_Object;
198 extern template class r_Collection<r_Ref<r_Object>>;
199 extern template class r_Collection<r_Ref<r_GMarray>>;
200 
201 struct GenRefElement;
202 extern template class r_Collection<GenRefElement *>;
203 
204 #endif
Basic class of a collection.
Definition: collection.hh:44
void add_node(CNode *&root, const T &element)
virtual void update_obj_in_db()
The method has no functionality in this class.
void init_node_list(CNode *&root)
const r_Type * get_element_type_schema()
get base type schema
const r_Collection< T > & operator=(const r_Collection< T > &collection)
assignment operator
int isOrdered
Definition: collection.hh:140
CNode * removed_objects
pointer to list of removed elements
Definition: collection.hh:131
unsigned long card
Definition: collection.hh:144
void remove_all()
removes all elements
int allowsDuplicates
Definition: collection.hh:142
r_Collection(const r_Collection< T > &collection)
copy constructor
bool remove_node(CNode *&root, const T &element)
CNode * coll
pointer to collection elements
Definition: collection.hh:187
void remove_all_nodes(CNode *&root)
virtual void insert_element(const T &element, int no_modification=0)
inserts an alement at the beginning
bool allows_duplicates() const
tells if the collections allowes duplicates or not
r_Collection()
default constructor
virtual ~r_Collection()
virtual destructor
virtual void r_deactivate()
it is called when an object leaves transient memory
virtual void insert_obj_into_db(const char *)
inserts an object into a specific collection in the database
Definition: collection.hh:99
bool contains_element(const T &element) const
asks about the containment of a specific element
bool is_empty() const
tells if the collection is empty or not
virtual void remove_element(const T &element)
The method inserts an element into the collection.
unsigned long cardinality() const
get number of elements
bool is_ordered() const
tells if the collection is ordered or not
r_Iterator< T > create_iterator()
create an iterator pointing at the first element in the collection
r_Iterator< T > create_removed_iterator()
create an iterator for removed objects
virtual void insert_obj_into_db()
insert myself into the database
The class represents a generic MDD in the sense that it is independent of the cell base type.
Definition: gmarray.hh:66
The template class r_Iterator defines the generic behavior for iteration.
Definition: iterator.hh:48
Through inheritance of this class, the type definer specifies that the subclass is capable of having ...
Definition: object.hh:62
r_Object(r_Transaction *transaction=NULL)
default constructor
The class r_Ref_Any is defined to support a reference to any type.
Definition: ref.hh:65
References of type r_Ref in many respects behave like C++ pointers but provide an additional mechanis...
Definition: ref.hh:198
This class the superclass for all types in the ODMG conformant representation of the RasDaMan type sy...
Definition: type.hh:51
element type of non r_Object list maintained by the transaction
Definition: genreftype.hh:39
Definition: collection.hh:117
CNode * next
Definition: collection.hh:118
T * elem
Definition: collection.hh:119