Products Support Documentation Download
cpp-cursor.h
Go to the documentation of this file.
1 /* ----------------------------------------------------------------------------
2  * Raima Database Manager
3  *
4  * Copyright (c) 2011 Raima Inc., All rights reserved.
5  *
6  * Use of this software, whether in source code format, or in executable,
7  * binary object code form, is governed by the Birdstep LICENSE which
8  * is fully described in the LICENSE.TXT file, included within this
9  * distribution of files.
10  * ----------------------------------------------------------------------------
11  */
12 
17 #if !defined(CURSOR_H_INCLUDED_)
18 #define CURSOR_H_INCLUDED_
19 
20 #include "rdmtypes.h"
21 #include "rdmrowidtypes.h"
22 
23 #if !defined(__cplusplus)
24 #error cpp-cursor.h is only for C++ applications. Do not include it in C applications
25 #endif
26 
27 namespace RDM_CPP {
28 
29  class ICursor;
30  class Db;
31  class Cursor;
32 }
33 
43 class PUBLIC_CLASS RDM_CPP::Cursor {
44 public:
45  /* Handle more than one reference to the underlying cursor */
57  Cursor (void) throw ();
58 
70  Cursor (const Cursor& cursor) throw ();
71 
83  Cursor& operator = (const Cursor& cursor) throw ();
84 
96  ~Cursor ();
97 
102  RDM_TABLE_ID GetTableId (void) const;
103 
114  RDM_RETCODE GetReturnCode (void) const;
115 
127  uint64_t GetCount (void) const;
128 
143  RDM_LOCK_STATUS GetLockStatus (void) const;
144 
155  static RDM_TABLE_ID NoMoreTables (void) throw () {
156  return (RDM_TABLE_ID) 0;
157  }
158 
178  Cursor DeleteRow (void) const;
179 
199  Cursor UnlinkAndDeleteRow (void) const;
200 
201  /* Basic navigation for this cursor */
218  const Cursor& MoveToFirst (void) const { return this->_MoveToFirst (); };
219 
241  const Cursor& MoveToNext (void) const { return this->_MoveToNext (); };
242 
262  const Cursor& MoveToPrev (void) const { return this->_MoveToPrev (); };
263 
280  const Cursor& MoveToLast (void) const { return this->_MoveToLast (); };
281 
282  /* Operators instead of functions above */
302  const Cursor& operator ++ (void) const { return MoveToNext ();}
303 
324  const Cursor& operator -- (void) const { return MoveToPrev ();}
325 
340  Cursor GetRows (void) const;
341 
359  Cursor GetSelf (void) const { return this->_GetSelf (); };
360 
379  Cursor GetClone (void) const { return this->_GetClone (); };
380 
392  static Cursor GetBeforeFirst (void) throw ();
393 
405  static Cursor GetAfterLast (void) throw ();
406 
418  bool IsBeforeFirst (void) const;
419 
434  void MoveToBeforeFirst (void) const;
435 
447  bool IsAfterLast (void) const;
448 
464  void MoveToAfterLast (void) const;
465 
487  RDM_CURSOR_STATUS GetStatus (void) const;
488 
536  bool IsBefore (
537  const Cursor& cursor
538  ) const;
539 
588  bool IsBeforeAt (
589  const Cursor& cursor
590  ) const;
591 
640  bool IsAt (
641  const Cursor& cursor
642  ) const;
643 
691  bool IsAfterAt (
692  const Cursor& cursor
693  ) const;
694 
741  bool IsAfter (
742  const Cursor& cursor
743  ) const;
744 
791  bool IsNotAt (
792  const Cursor& cursor
793  ) const;
794 
795  /* Operators instead of functions above */
842  bool operator < (
843  const Cursor& cursor
844  ) const { return IsBefore (cursor);}
845 
892  bool operator <= (
893  const Cursor& cursor
894  ) const { return IsBeforeAt (cursor);}
895 
943  bool operator == (
944  const Cursor& cursor
945  ) const { return IsAt (cursor);}
946 
994  bool operator >= (
995  const Cursor& cursor
996  ) const { return IsAfterAt (cursor);}
997 
1045  bool operator > (
1046  const Cursor& cursor
1047  ) const { return IsAfter (cursor);}
1048 
1096  bool operator != (
1097  const Cursor& cursor
1098  ) const { return IsNotAt (cursor);}
1099 
1114  Db GetDb (void);
1115 
1132  RDM_ROWID_T GetRowId (
1133  ) const;
1134 
1148  void GetRowStatus (
1149  RDM_ROW_STATUS_INFO& rowStat
1150  ) const;
1151 
1180  void MoveToRowId (
1181  const RDM_ROWID_T rowId
1182  ) const;
1183 
1202  void AddMember (
1203  const Cursor& member
1204  ) const;
1205 
1222  void RemoveMember ( void ) const;
1223 
1237  Cursor& Release (void);
1238 
1239 #ifndef RDM_DOXYGEN
1240 protected:
1241  ICursor *m_icursor;
1242 
1243  const Cursor& _MoveToFirst (void) const;
1244  const Cursor& _MoveToNext (void) const;
1245  const Cursor& _MoveToLast (void) const;
1246  const Cursor& _MoveToPrev (void) const;
1247 
1248  Cursor _GetSelf (void) const;
1249  Cursor _GetClone (void) const;
1250 
1251  void VerifyTableId (RDM_TABLE_ID) const;
1252 
1253  Cursor& _AssignAndVerifyTableId (RDM_TABLE_ID, const Cursor&);
1254  Cursor (ICursor *) throw ();
1255  Cursor (const Cursor&, RDM_TABLE_ID);
1256 
1257  Cursor _GetOwnerRow (RDM_REF_ID) const;
1258  RDM_ROWID_T _GetOwnerRowId (RDM_REF_ID) const;
1259 
1260  Cursor _GetMemberRows (RDM_REF_ID) const;
1261  Cursor _GetSiblingRows (RDM_REF_ID, bool) const;
1262  Cursor _GetRowsByKeyAtPosition (RDM_KEY_ID keyId) const;
1263 
1264  bool _HasOwner (RDM_REF_ID refId) const;
1265  uint64_t _GetMemberCount (RDM_REF_ID) const;
1266  void _Connect (RDM_REF_ID, const Cursor&, bool) const;
1267  void UnlinkRow (RDM_REF_ID) const;
1268 
1269  void _MoveToKey (RDM_KEY_ID, const void *, size_t = 0) const;
1270  void _MoveToKey (RDM_KEY_ID, const RDM_SEARCH_KEY *) const;
1271 
1272  void _UpdateRow (const void *, size_t = 0) const;
1273  void _ReadRow (void *, size_t = 0, size_t * = NULL) const;
1274  void _UpdateColumn (RDM_COLUMN_ID, const void *, size_t = 0) const;
1275  void _ReadColumn (RDM_COLUMN_ID, void *, size_t = 0, size_t * = NULL) const;
1276  void _UpdateBlob (RDM_COLUMN_ID, uint64_t, const void *, size_t) const;
1277  void _ReadBlob (RDM_COLUMN_ID, uint64_t, void *, size_t, size_t * = NULL) const;
1278  void _SetBlobSize (RDM_COLUMN_ID, uint64_t) const;
1279  void _GetBlobSize (RDM_COLUMN_ID columnId, uint64_t *) const;
1280  void _ValidateICursor() const;
1281 
1282 private:
1283  const Cursor* operator & (void) const;
1284 #endif
1285  friend class Db;
1286 };
1287 #endif /* ! CURSOR_H_INCLUDED_ */
const Cursor & MoveToFirst(void) const
Navigate to the first row in the Cursor collection.
Definition: cpp-cursor.h:218
const Cursor & MoveToLast(void) const
Navigate to the last row in the Cursor collection.
Definition: cpp-cursor.h:280
The Cursor base class.
Definition: cpp-cursor.h:43
RDM_LOCK_STATUS
Enumeration for RDM table lock status.
Definition: rdmtypes.h:114
Header for the native RDM Runtime types.
The RDM Partial Key data structure.
Definition: rdmtypes.h:32
const Cursor & MoveToPrev(void) const
Navigate to the previous row in the Cursor collection.
Definition: cpp-cursor.h:262
uint32_t RDM_TABLE_ID
Definition: rdmtypes.h:26
The Db base class.
Definition: cpp-db.h:52
RDM Rows status info.
Definition: rdmtypes.h:257
RDM_RETCODE
RDM status and error return codes.
Cursor GetClone(void) const
Clone a cursor.
Definition: cpp-cursor.h:379
const Cursor & MoveToNext(void) const
Navigate to the next row in the Cursor collection.
Definition: cpp-cursor.h:241
uint32_t RDM_KEY_ID
Definition: rdmtypes.h:28
The RDM C++ Namespace.
Definition: cpp-cursor.h:27
RDM_CURSOR_STATUS
Enumeration for RDM cursor positions / statuses.
Definition: rdmtypes.h:153
Cursor GetSelf(void) const
Obtain a singleton Cursor for the source cursor&#39;s current row.
Definition: cpp-cursor.h:359
uint32_t RDM_COLUMN_ID
Definition: rdmtypes.h:27
static RDM_TABLE_ID NoMoreTables(void)
Mark the end of an array of table ids.
Definition: cpp-cursor.h:155
uint64_t RDM_ROWID_T
Definition: rdmrowidtypes.h:21
Header for row ID types.
uint32_t RDM_REF_ID
Definition: rdmtypes.h:29