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 } // namespace RDM_CPP
33 
43 class PUBLIC_CLASS RDM_CPP::Cursor
44 {
45  public:
46  /* Handle more than one reference to the underlying cursor */
58  Cursor (void) throw ();
59 
71  Cursor (const Cursor &cursor) throw ();
72 
84  Cursor &operator= (const Cursor &cursor) throw ();
85 
97  ~Cursor ();
98 
103  RDM_TABLE_ID GetTableId (void) const;
104 
115  RDM_RETCODE GetReturnCode (void) const;
116 
128  uint64_t GetCount (void) const;
129 
144  RDM_LOCK_STATUS GetLockStatus (void) const;
145 
156  static RDM_TABLE_ID NoMoreTables (void) throw ()
157  {
158  return (RDM_TABLE_ID) 0;
159  }
160 
181  Cursor DeleteRow (void) const;
182 
203  Cursor UnlinkAndDeleteRow (void) const;
204 
205  /* Basic navigation for this cursor */
223  const Cursor &MoveToFirst (void) const
224  {
225  return this->_MoveToFirst ();
226  };
227 
250  const Cursor &MoveToNext (void) const
251  {
252  return this->_MoveToNext ();
253  };
254 
275  const Cursor &MoveToPrev (void) const
276  {
277  return this->_MoveToPrev ();
278  };
279 
297  const Cursor &MoveToLast (void) const
298  {
299  return this->_MoveToLast ();
300  };
301 
302  /* Operators instead of functions above */
323  const Cursor &operator++ (void) const
324  {
325  return MoveToNext ();
326  }
327 
349  const Cursor &operator-- (void) const
350  {
351  return MoveToPrev ();
352  }
353 
368  Cursor GetRows (void) const;
369 
388  Cursor GetSelf (void) const
389  {
390  return this->_GetSelf ();
391  };
392 
411  Cursor GetClone (void) const
412  {
413  return this->_GetClone ();
414  };
415 
427  static Cursor GetBeforeFirst (void) throw ();
428 
440  static Cursor GetAfterLast (void) throw ();
441 
454  bool IsBeforeFirst (void) const;
455 
471  void MoveToBeforeFirst (void) const;
472 
485  bool IsAfterLast (void) const;
486 
503  void MoveToAfterLast (void) const;
504 
528  RDM_CURSOR_STATUS GetStatus (void) const;
529 
587  bool IsBefore (const Cursor &cursor
588  ) const;
589 
647  bool IsBeforeAt (
648  const Cursor &cursor
649  ) const;
650 
708  bool IsAt (const Cursor &cursor
709  ) const;
710 
767  bool IsAfterAt (const Cursor &cursor
768  ) const;
769 
826  bool IsAfter (const Cursor &cursor
827  ) const;
828 
885  bool IsNotAt (const Cursor &cursor
886  ) const;
887 
888  /* Operators instead of functions above */
945  bool operator< (const Cursor &cursor
946  ) const
947  {
948  return IsBefore (cursor);
949  }
950 
1006  bool operator<= (
1007  const Cursor &cursor
1008  ) const
1009  {
1010  return IsBeforeAt (cursor);
1011  }
1012 
1069  bool operator== (
1070  const Cursor &cursor
1071  ) const
1072  {
1073  return IsAt (cursor);
1074  }
1075 
1132  bool operator>= (
1133  const Cursor &cursor
1134  ) const
1135  {
1136  return IsAfterAt (cursor);
1137  }
1138 
1195  bool operator> (const Cursor &cursor
1196  ) const
1197  {
1198  return IsAfter (cursor);
1199  }
1200 
1257  bool operator!= (
1258  const Cursor &cursor
1259  ) const
1260  {
1261  return IsNotAt (cursor);
1262  }
1263 
1278  Db GetDb (void);
1279 
1297  RDM_ROWID_T GetRowId () const;
1298 
1312  void GetRowStatus (RDM_ROW_STATUS_INFO &rowStat) const;
1313 
1343  void MoveToRowId (
1344  const RDM_ROWID_T
1345  rowId
1346  ) const;
1347 
1367  void AddMember (
1368  const Cursor &member
1370  ) const;
1371 
1389  void RemoveMember (void) const;
1390 
1404  Cursor &Release (void);
1405 
1406 #ifndef RDM_DOXYGEN
1407  protected:
1408  ICursor *m_icursor;
1409 
1410  const Cursor &_MoveToFirst (void) const;
1411  const Cursor &_MoveToNext (void) const;
1412  const Cursor &_MoveToLast (void) const;
1413  const Cursor &_MoveToPrev (void) const;
1414 
1415  Cursor _GetSelf (void) const;
1416  Cursor _GetClone (void) const;
1417 
1418  void VerifyTableId (RDM_TABLE_ID) const;
1419 
1420  Cursor &_AssignAndVerifyTableId (RDM_TABLE_ID, const Cursor &);
1421  Cursor (ICursor *) throw ();
1422  Cursor (const Cursor &, RDM_TABLE_ID);
1423 
1424  Cursor _GetOwnerRow (RDM_REF_ID) const;
1425  RDM_ROWID_T _GetOwnerRowId (RDM_REF_ID) const;
1426 
1427  Cursor _GetMemberRows (RDM_REF_ID) const;
1428  Cursor _GetSiblingRows (RDM_REF_ID, bool) const;
1429  Cursor _GetRowsByKeyAtPosition (RDM_KEY_ID keyId) const;
1430 
1431  bool _HasOwner (RDM_REF_ID refId) const;
1432  uint64_t _GetMemberCount (RDM_REF_ID) const;
1433  void _Connect (RDM_REF_ID, const Cursor &, bool) const;
1434  void UnlinkRow (RDM_REF_ID) const;
1435 
1436  void _MoveToKey (RDM_KEY_ID, const void *, size_t = 0) const;
1437  void _MoveToKey (RDM_KEY_ID, const RDM_SEARCH_KEY *) const;
1438 
1439  void _UpdateRow (const void *, size_t = 0) const;
1440  void _ReadRow (void *, size_t = 0, size_t * = NULL) const;
1441  void _UpdateColumn (RDM_COLUMN_ID, const void *, size_t = 0) const;
1442  void _ReadColumn (RDM_COLUMN_ID, void *, size_t = 0, size_t * = NULL) const;
1443  void _UpdateBlob (RDM_COLUMN_ID, uint64_t, const void *, size_t) const;
1444  void _ReadBlob (RDM_COLUMN_ID, uint64_t, void *, size_t, size_t * = NULL) const;
1445  void _SetBlobSize (RDM_COLUMN_ID, uint64_t) const;
1446  void _GetBlobSize (RDM_COLUMN_ID columnId, uint64_t *) const;
1447  void _ValidateICursor () const;
1448 
1449  private:
1450  const Cursor *operator& (void) const;
1451 #endif
1452  friend class Db;
1453 };
1454 #endif /* ! CURSOR_H_INCLUDED_ */
const Cursor & MoveToFirst(void) const
Navigate to the first row in the Cursor collection.
Definition: cpp-cursor.h:223
const Cursor & MoveToLast(void) const
Navigate to the last row in the Cursor collection.
Definition: cpp-cursor.h:297
The Cursor base class.
Definition: cpp-cursor.h:43
RDM_LOCK_STATUS
Enumeration for RDM table lock status.
Definition: rdmtypes.h:115
Header for the native RDM Runtime types.
The RDM Partial Key data structure.
Definition: rdmtypes.h:33
const Cursor & MoveToPrev(void) const
Navigate to the previous row in the Cursor collection.
Definition: cpp-cursor.h:275
uint32_t RDM_TABLE_ID
Definition: rdmtypes.h:27
The Db base class.
Definition: cpp-db.h:52
RDM Rows status info.
Definition: rdmtypes.h:285
RDM_RETCODE
RDM status and error return codes.
Cursor GetClone(void) const
Clone a cursor.
Definition: cpp-cursor.h:411
const Cursor & MoveToNext(void) const
Navigate to the next row in the Cursor collection.
Definition: cpp-cursor.h:250
uint32_t RDM_KEY_ID
Definition: rdmtypes.h:29
The RDM C++ Namespace.
Definition: cpp-cursor.h:27
RDM_CURSOR_STATUS
Enumeration for RDM cursor positions / statuses.
Definition: rdmtypes.h:164
Cursor GetSelf(void) const
Obtain a singleton Cursor for the source cursor&#39;s current row.
Definition: cpp-cursor.h:388
uint32_t RDM_COLUMN_ID
Definition: rdmtypes.h:28
static RDM_TABLE_ID NoMoreTables(void)
Mark the end of an array of table ids.
Definition: cpp-cursor.h:156
uint64_t RDM_ROWID_T
Definition: rdmrowidtypes.h:21
Header for row ID types.
uint32_t RDM_REF_ID
Definition: rdmtypes.h:30