OOFILE  1.9
oofrecs.h
Go to the documentation of this file.
1 #ifndef H_OOFRECS
2 #define H_OOFRECS
3 
4 // OOFILE record-oriented abstract backend implementation
5 // COPYRIGHT 1996 A.D. Software, All rights reserved
6 
7 #ifndef H_OOFQUERY
8  #include "oofquery.h"
9 #endif
10 #ifndef H_OOF2
11  #include "oof2.h"
12 #endif
13 #ifndef H_OOF4
14  #include "oof4.h"
15 #endif
16 
17 #ifndef OOF_FIRST_SYNTHETIC_RECORD_OFFSET
18 
23  #define OOF_FIRST_SYNTHETIC_RECORD_OFFSET (ULONG_MAX - 9216)
24 #endif
25 
31 
32 
33 
39 public:
40 // use default copy ctor
41 // data storage
42  unsigned long mOffset, mLength;
43 };
44 
45 
52 public:
56 
57  void finishMap(unsigned short numFields);
58 
59  void markDirty(unsigned short);
60  bool isDirty(unsigned short) const;
61  bool anyDirty() const;
62  void reset();
63 
64 private:
65 // data storage
66  unsigned short mNumFields;
67  bool* mDirtyMap; // NOT YET IMPLEMENTED - use bitfield
68 };
69 
70 
77 {
78 public:
79  enum {kNotFound=ULONG_MAX};
80 
83 
84 
85 private:
86  OOF_recordCache(const OOF_recordCache&) { assert(0); };
87 public:
89 
90  void append(OOF_recordBufferedContext* adoptingContext);
91  void deleteRecord(unsigned long recOffset);
92  void deleteAll();
93  unsigned long containsContext(const OOF_recordBufferedContext*) const;
94  unsigned long containsOffset(unsigned long recOffset) const;
95  unsigned long firstFree() const;
97  OOF_recordBufferedContext* item(unsigned long);
98  void setItem(unsigned long, OOF_recordBufferedContext* adoptingContext);
99  void reuseDeletedItem(unsigned long, OOF_recordBufferedContext* adoptingContext);
100  unsigned long count() const;
101  unsigned long countNew() const;
102  unsigned long countOccupied() const;
103  bool anyDeleted() const;
104 
105 protected:
106 // data storage
108  unsigned short mDeletedCells;
109 };
110 
111 
112 
118 public:
120 };
122 
123 
131 {
132 public:
136  virtual ~OOF_recordBufferedContext();
137 
138  void copyFrom(const OOF_recordBufferedContext*);
139  virtual void copyFrom(const OOF_recordBufferedContext&);
141  unsigned long currentOffset() const;
142  operator unsigned long() const;
143  bool operator==(unsigned long) const;
144  bool operator==(const OOF_recordBufferedContext&) const;
145  bool isNew() const;
146 
147  char* buffer() const;
148 
149 protected:
150  void AllocBuffer();
151 
152 // data storage
154  unsigned long mCurrLoadedRecOffset;
155  unsigned long mRecBufLen;
156  char *mBuffer; // owned
159 
161 };
163 
164 
174 #ifdef OOF_DEBUG
175 , public oofSingleListener
176 #endif
177 {
178 // default constructor, or passing in zero items skips allocating storage
179 public:
181  OOF_recordSelection(unsigned long numSlots, dbTable* prototypicalTable);
182  OOF_recordSelection(const EselectionState, unsigned long numSlots, dbTable* prototypicalTable);
183  OOF_recordSelection(unsigned long numSlots, unsigned int expansionChunk, dbTable* prototypicalTable);
185  virtual ~OOF_recordSelection();
186 
187  virtual OOF_Selection* clone() const;
188  void describeState(std::ostream& os) const;
189  void describeRecsRep(std::ostream&) const;
190 
192 
193 #ifdef OOF_DEBUG
194 // so we know if prototypical table goes away
195  virtual bool receiveMsg(OOFmsgT msg, unsigned long senderDefined);
196 #endif
197 
200 
201  virtual void setSortOrder(dbSorter* adoptSorter);
202  virtual dbSorter* sorter() const;
203 
204  unsigned long* allocSelection(unsigned long numSlots);
205  unsigned long* allocConsumedSelection(unsigned long numSlots);
206  void expandToInclude(unsigned long numSlots);
207  void adopt(OOF_recordSelection&);
208  void copyContents(const OOF_recordSelection&);
209  void aboutToDirtySelection();
210 
212 
213  virtual void difference_with(const OOF_Selection*);
214  virtual void intersection_with(const OOF_Selection*);
215  virtual void intersection_with(oidT);
216  virtual void union_with(const OOF_Selection*);
217  virtual void union_with_no_overlap(const OOF_Selection*);
218  virtual void union_with(oidT);
219  virtual void invert();
221 
223 
226  void union_with(const OOF_recordSelection&);
229 
231 
232  EselectionState state() const;
233  unsigned long oneRecOffset() const;
234  virtual bool isEmpty() const;
235  virtual bool isAllRecs() const;
236  virtual bool contains(oidT) const;
237  virtual bool find(oidT item, unsigned long& foundAt) const;
238  virtual const dbTable* prototypicalTable() const;
240 
242 
243  void selectNone();
244  void selectOneRec(unsigned long);
245  void selectSome();
246  void selectAll();
248 
250 
251  unsigned long& operator[](unsigned long);
252  unsigned long& operator[](long);
253  unsigned long& operator()();
254  unsigned long value(unsigned long) const;
255  void append(oidT);
256  unsigned long appendNewRecord(bool appendIt);
257  void deleteCurrent();
258  void deleteItem(unsigned long index);
259  void updateCurrent(unsigned long);
260  unsigned long iter() const;
261  unsigned long current() const;
262 
263 
265 
266  void start();
267  bool more() const;
268  void prev();
269  void next();
270  virtual unsigned long count() const;
271  void gotoRecord(unsigned long);
273 
274 private:
275  void DropSelection();
276 
277 // data storage
278 private:
279  OOF_recordSelectionRep *mRep;
280  unsigned long mInternalIter;
281  unsigned long mNextFakeNewRecOffset;
282  dbTable* mPrototypicalTable;
283 };
284 
285 
296 protected:
297 
299 
305  typedef struct { OOF_wctype thewc;
306  char* thechars;
307  } WC;
309 
310 // constructors
313 // void operator=(const OOF_simpleRecordBackend&) {assert(0);};
314 
315  public:
316  virtual ~OOF_simpleRecordBackend();
317 
319  virtual void buildSchema(bool rebuilding=false);
320 
321  virtual void describeState(std::ostream&) const;
322  virtual void setFileExtensions(const char* /*dataExt*/, const char* /*indexExt*/) {};
323 
325 
326  virtual oidT currentOID();
327  virtual oidT oidOfRecord(unsigned long);
329 
331 
332  virtual unsigned long recordNumber() const;
333  virtual unsigned long recordNumberOfOID(oidT inOID);
334  virtual void selectAll();
335  virtual void selectNone();
336 
337  virtual void invert();
338  virtual void difference_with(const OOF_tableBackend*);
339  virtual void intersection_with(const OOF_tableBackend*);
340  virtual void union_with(const OOF_tableBackend*);
341  virtual void union_with_no_overlap(const OOF_tableBackend*);
342  virtual void difference_with(const dbSelection&);
343  virtual void intersection_with(const dbSelection&);
344  virtual void union_with(const dbSelection&);
345  virtual void union_with_no_overlap(const dbSelection&);
347 
348  virtual void ignoreDuplicateRecords();
349  virtual void noticeDuplicateRecords();
350 
352 
353  virtual bool search(const dbQueryClause* qClause);
354  virtual unsigned long recordNumberMatching(const dbQueryClause* qClause, bool* outFoundIt=0) const;
355  virtual bool checkDuplicate(const dbQueryClause*);
356  virtual bool searchSelection(const dbQueryClause*);
357  virtual bool searchEqual(const dbField*, const char*, bool matchEntireKey=true);
358  virtual bool searchEqual(const dbField*, const void*);
359  virtual bool searchSelContainsAnyDelimited(const dbField* schField, const char *schStr, char delim);
360  virtual bool searchSelContainsAnyOf(const dbField* schField, const char **schStrs, unsigned long count);
361  virtual bool searchSelContainsAllDelimited(const dbField* schField, const char *schStr, char delim);
362  virtual bool searchSelContainsAllOf(const dbField* schField, const char **schStrs, unsigned long count);
363  virtual bool loadRelatedContextJoiningFromTo(const dbField*, const dbField*);
365 
366 
368 
369  virtual bool readBool(const dbField*) const;
370  virtual short readShort(const dbField*) const;
371  virtual long readLong(const dbField*) const;
372  virtual double readDouble(const dbField*) const;
373  virtual const char* readChars(const dbField*) const;
374  virtual oofString readString(const dbField*) const;
375 
376  virtual void writeBool(bool, const dbField*);
377  virtual void writeShort(short, const dbField*);
378  virtual void writeLong(long, const dbField*);
379  virtual void writeDouble(double, const dbField*);
380  virtual void writeChars(const char*, long numChars, long maxLen, const dbField*, long startIndex=0);
381  virtual void writeBytes(const char* inBuf, long inLen, const dbField* inField);
382  virtual char* getByteWriteAddress(unsigned long, const dbField*);
384 
386 
387  virtual bool atFirst() const;
388  virtual bool atLast() const;
389  virtual bool atRelative(unsigned long) const;
390  virtual void prev();
391  virtual bool more() const;
392  virtual unsigned long count() const;
393  void gotoBOF();
395 
397 
398  virtual void newRecord();
399  virtual void saveRecord();
400  virtual void unloadRecord();
401  virtual void unloadCache();
402  virtual void revertRecord();
403  virtual void pack();
405 
407 
408  virtual void setSortOrder(dbSorter* adoptSorter);
409  virtual dbSorter* sorter() const;
410  virtual void sortSelectionNow(fieldNumT);
411  virtual void sortSelectionInverseNow(fieldNumT);
412  virtual void sortSelectionNow(const dbSorter*);
414 
415  virtual bool reloadRecord();
416  virtual bool isRecordLoaded() const;
417 
418  virtual void setBlobLength(fieldNumT, unsigned long len);
419 
421 
422  virtual unsigned long fieldDataLen(const dbField*) const;
423  virtual bool fieldIsDirty(fieldNumT) const;
424  virtual bool isNewRecord() const;
425  virtual unsigned int numIndexes() const;
426  virtual unsigned int numFiles() const;
427  virtual unsigned long blobPointerReferenceSize() const;
428  virtual bool allSelected() const;
429  virtual bool contains(oidT) const;
431 
432  virtual bool addOIDtoSelection(oidT);
433  virtual void dropRecordFromSelection(unsigned long);
434 
436 
437  virtual dbSelection currentSelection() const;
438  virtual dbSelection makeEmptySelection() const;
439  virtual void setSelection(const dbSelection&);
440  virtual void setSelection(const OOF_Selection*);
442 
444 
445  virtual bool selectJustOID(oidT);
446  virtual void selectJustCurrent();
448 
450 
451  virtual void lockRecord();
452  virtual void unlockRecord();
454 
456 
457  virtual void beginTransaction(short tMode);
458  virtual void abortTransaction(short rMode);
459  virtual void commitTransaction(short rMode);
461 
463  void describeInvariant(std::ostream&) const;
464 
465 protected:
466  void* GetFieldWriteDest(const dbField*);
467  void* GetFieldReadFrom(fieldNumT) const;
468 
469  bool Invariant(const char* optionalComment=0) const;
471 
472  unsigned long state() const;
473 
475  virtual void BuildBackendtables(bool rebuilding)=0;
476 
477  unsigned long PadFieldWidthForAlignment(const dbField* fld) const;
478  unsigned int FieldAlignsTo(const dbField*) const;
479 
480  virtual void CachingContextChange();
481  virtual void ContextChange();
483  bool IgnoringDuplicateRecords() const;
484  virtual void SaveContext()=0;
485 
486 
487  unsigned long BlobLenFromBuffer(const dbField*, const char* theirBuffer) const;
488  unsigned long BlobPosFromBuffer(const dbField* fld, const char* theirBuffer) const;
489  unsigned long BlobLenFromBuffer(fieldNumT, const char* theirBuffer) const;
490  unsigned long BlobPosFromBuffer(fieldNumT, const char* theirBuffer) const;
491  void SetBlobLenInBuffer(fieldNumT, unsigned long len, const char* theirBuffer) const;
492  void SetBlobPosInBuffer(fieldNumT, unsigned long pos, const char* theirBuffer) const;
493  virtual void LoadRecordAtOffset(unsigned long offset)=0;
494  bool MaybeLoadRecordFromCache(unsigned long offset);
495  bool CommonSimpleDelete();
496  bool GotoRecordForAllUnindexed(unsigned long relativeNum);
497 
501 #ifdef OOF_DebugDumpBlobState
502  virtual void describeBlobs() const;
503 #endif
504  void ResetBlobs();
505 
507 
508  virtual bool SearchBinaryFieldToLiteral(const dbQueryBinary*);
509  virtual bool SearchTrinaryFieldToLiterals(const dbQueryTrinary*);
510  virtual bool SearchCombineSubclauses(const dbQueryBinaryCombo*, bool searchSel);
513 
515 
516  bool SearchEqualNonIndexed(const dbField*, const char*, bool matchEntireKey=true);
517  bool SearchEqualNonIndexed(const dbField*, const void*);
518  bool SearchWordNonIndexed(const dbField*, const char*, bool startsWith=false);
519  bool SearchNotEqualNonIndexed(const dbField*, const char*, bool matchEntireKey=true);
520  bool SearchNotEqualNonIndexed(const dbField*, const void*);
521  bool SearchBetweenNonIndexed(const dbField*, const char*, const char*);
522  bool SearchBetweenNonIndexed(const dbField*, const void*, const void*);
523  bool SearchOutsideNonIndexed(const dbField*, const char*, const char*);
524  bool SearchOutsideNonIndexed(const dbField*, const void*, const void*);
529 
531 
532  bool SearchEqualNonIndexedWildcard(const dbField* schField, const char* schStr, bool matchEntireKey=true);
533  bool SearchNotEqualNonIndexedWildcard(const dbField* schField, const char* schStr, bool matchEntireKey=true);
535 
537 
538  void SortSelectionNow(const dbUlong* theFld);
539  void SortSelectionNow(const dbLong* theFld);
540  void SortSelectionNow(const dbUshort* theFld);
541  void SortSelectionNow(const dbShort* theFld);
542  void SortSelectionNow(const dbReal* theFld);
543  void SortSelectionNow(const dbChar* theFld);
544  void SortSelectionNow(const dbText* theFld);
545  void SortSelectionNow(const dbField* theFld, unsigned long fixedBinaryLength);
546 
547  void SortSelectionInverseNow(const dbUlong* theFld);
548  void SortSelectionInverseNow(const dbLong* theFld);
549  void SortSelectionInverseNow(const dbUshort* theFld);
550  void SortSelectionInverseNow(const dbShort* theFld);
551  void SortSelectionInverseNow(const dbReal* theFld);
552  void SortSelectionInverseNow(const dbChar* theFld);
553  void SortSelectionInverseNow(const dbText* theFld);
554  void SortSelectionInverseNow(const dbField* theFld, unsigned long fixedBinaryLength);
555 
556  void SubSort(const dbSorter *theSorter, const unsigned long level, unsigned long *theData, const unsigned long count);
558 
559 // data storage
561  OOF_recordFieldEntry *mFieldBufMap; // owned semi-static member passed onto sub-collections
562  unsigned int* mFieldBufMapRefCount; // owned semi-static member passed onto sub-collections
564 
565 
569 
570 #ifdef OOF_INVARIANT_DUMP_NAME
571  void InvariantDump(const char* optionalComment=0) const;
572 
573  #ifndef _Macintosh
574  // use Macsbug built-in debugger on Mac so we get stack traces as well
575  // optional statics
576  static oofDirectory sInvariantDumpDir;
577  static ofstream sInvariantDump;
578  #endif
579 
580 #endif
581 
582 
584 };
585 
593 private:
594 // construction
595  OOF_recordSelRecsRep(unsigned long numSlots=0, unsigned int expandBySlots=10);
596  // use default copy ctor
597  virtual ~OOF_recordSelRecsRep() {};
598 
599  friend class OOF_recordSelectionRep;
600 };
601 
602 
617 private:
618  enum {kDefExpansionChunk=10};
619 // construction
620  OOF_recordSelectionRep(unsigned long numSlots=0, unsigned int expandBySlots=10);
621  OOF_recordSelectionRep(const EselectionState, unsigned long numSlots=0);
624  virtual ~OOF_recordSelectionRep();
625 
626  virtual void setSortOrder(dbSorter* adoptSorter);
627  virtual dbSorter* sorter() const;
628 
629  void AboutToDirtySelection();
630  unsigned long* ExposeArray();
631  void MarkAsUsed(unsigned long);
632  void CopyContents(const OOF_recordSelectionRep* rhs);
633  void DropSelection();
634  unsigned long* AllocSelection(unsigned long numSlots);
635  unsigned long* AllocConsumedSelection(unsigned long numSlots);
636  void ExpandToInclude(unsigned long indexToCover);
637 
638  void SelectionChanged();
639 
640 // access operators
641  unsigned long& item(unsigned long index);
642  unsigned long value(unsigned long index) const;
643  void Append(unsigned long n);
644  void SetItemOffset(unsigned long index, unsigned long);
645  void DeleteItem(unsigned long index);
646 
647 // change state
648  void SelectNone();
649  void SelectOneRec(unsigned long rec);
650  void SelectAll();
651  void SelectSome();
652 
653 // reflective operators
654  unsigned long Count() const;
655  bool IsMember(unsigned long item) const;
656  bool Find(unsigned long item, unsigned long& foundAt) const;
657  bool Invariant() const;
658 
659 // data storage
660  unsigned long mCurrSingleRecOffset;
661  EselectionState mState;
662  OOF_recordSelRecsRep* mRecsRep; // owned and shared COW
663  dbSorter* mSorter; // owned
664 
665  friend class OOF_recordSelection;
666 };
667 
668 
678 public:
680 // use default copy ctor
681  virtual ~OOF_recordCacheCopier();
682 
683  virtual bool receiveMsg(OOFmsgT msg, unsigned long senderDefined);
684 protected:
685 // data storage
689 };
690 
691 
692 
693 // -------------------------------------------------------
694 // O O F _ r e c o r d B u f f e r e d C o n t e x t
695 // -------------------------------------------------------
696 inline bool
698 {
699  return (mRecordState==eNew);
700 }
701 
702 
703 inline void
705 {
706  copyFrom(*rhs);
707 }
708 
709 
710 inline
711 OOF_recordBufferedContext::operator unsigned long() const
712 {
713  return mCurrLoadedRecOffset;
714 }
715 
716 
717 inline unsigned long
719 {
720  return mCurrLoadedRecOffset;
721 }
722 
723 
724 inline bool
725 OOF_recordBufferedContext::operator==(unsigned long inOffset) const
726 {
727  return (mCurrLoadedRecOffset==inOffset);
728 }
729 
730 
731 inline char*
733 {
734  return mBuffer;
735 }
736 
737 // -------------------------------------------------------
738 // O O F _ s i m p l e R e c o r d B a c k e n d
739 // -------------------------------------------------------
740 
741 inline unsigned long
742 OOF_simpleRecordBackend::BlobLenFromBuffer(const dbField* fld, const char* theirBuffer) const
743 {
744  return BlobLenFromBuffer(fld->fieldNumber(), theirBuffer);
745 }
746 
747 
748 inline unsigned long
749 OOF_simpleRecordBackend::BlobPosFromBuffer(const dbField* fld, const char* theirBuffer) const
750 {
751  return BlobPosFromBuffer(fld->fieldNumber(), theirBuffer);
752 }
753 
754 
755 inline void
757 {
759 }
760 
761 
762 inline bool
764 {
766 }
767 
768 
769 
770 // -------------------------------------------------------
771 // O O F _ d i r t y F i e l d M a p
772 // -------------------------------------------------------
773 inline void
775 {
776  assert(n<mNumFields);
777  mDirtyMap[n] = true;
778 }
779 
780 
781 inline bool
782 OOF_dirtyFieldMap::isDirty(unsigned short n) const
783 {
784  assert(n<mNumFields);
785  return mDirtyMap[n];
786 }
787 
788 
789 
790 // -------------------------------------------------------
791 // O O F _ r e c o r d C a c h e
792 // -------------------------------------------------------
793 inline unsigned long
795 {
796  return mBuffers.count();
797 }
798 
799 
800 inline unsigned long
802 {
803  return mBuffers.count() - mDeletedCells;
804 }
805 
806 
807 inline bool
809 {
810  return mDeletedCells > 0;
811 }
812 
813 
814 // -------------------------------------------------------
815 // O O F _ r e c o r d S e l e c t i o n R e p
816 // -------------------------------------------------------
817 
818 inline unsigned long*
819 OOF_recordSelectionRep::ExposeArray()
820 {
821  assert(mRecsRep);
822  return mRecsRep->mBits;
823 }
824 
825 
826 inline void
827 OOF_recordSelectionRep::MarkAsUsed(unsigned long numUsedAtFront)
828 {
829  assert(mRecsRep);
830  mRecsRep->mNextFreeEntry = numUsedAtFront;
831 }
832 
833 
834 inline void
835 OOF_recordSelectionRep::SelectionChanged()
836 {
837  if (mSorter)
838  mSorter->selectionChanged();
839 }
840 
841 
842 // -------------------------------------------------------
843 // O O F _ r e c o r d S e l e c t i o n
844 // -------------------------------------------------------
847 {
848  return mRep->mState;
849 }
850 
851 
852 inline unsigned long
854 {
855  return mRep->Count();
856 }
857 
858 
859 inline bool
861 {
862  bool ret = false;
863  if (item)
864  ret = mRep->IsMember(item);
865  return ret;
866 }
867 
868 
869 inline bool
870 OOF_recordSelection::find(oidT item, unsigned long& foundAt) const
871 {
872  bool ret = false;
873  if (item)
874  ret = mRep->Find(item, foundAt);
875  return ret;
876 }
877 
878 
879 inline void
881 {
882  mInternalIter = 0;
883 }
884 
885 
886 inline bool
888 {
889  assert(state() != allRecs);
890  return mInternalIter < count(); // yes, this is more an "in range" than a "more"
891 }
892 
893 
894 inline void
896 {
897  assert(mInternalIter>0);
898  mInternalIter--;
899 }
900 
901 
902 inline void
904 {
905  mInternalIter++;
906 }
907 
908 
909 inline bool
911 {
912  return state()==empty;
913 }
914 
915 
916 inline bool
918 {
919  return state()==allRecs;
920 }
921 
922 
923 inline unsigned long
925 {
926  return mRep->mCurrSingleRecOffset;
927 }
928 
929 
930 inline unsigned long
931 OOF_recordSelection::current() const // can return 0 if allRecs state
932 {
933  unsigned long ret=0;
934  if (mRep && (mInternalIter < count()) )
935  ret = mRep->value(mInternalIter);
936  return ret;
937 }
938 
939 
940 inline unsigned long&
941 OOF_recordSelection::operator()() // writable current value
942 {
943  assert(mRep);
944  assert(mInternalIter < count()); // guards against iter off end & allRecs state
945  return mRep->item(mInternalIter);
946 }
947 
948 
949 inline unsigned long&
951 {
952  assert(index>=0);
953  assert(mRep);
954  return mRep->item ((unsigned int) index);
955 }
956 
957 
958 inline unsigned long&
960 {
961  assert(mRep);
962  return mRep->item(index);
963 }
964 
965 
966 inline unsigned long
967 OOF_recordSelection::value(unsigned long index) const
968 {
969  assert(mRep);
970  return mRep->value(index);
971 }
972 
973 
974 inline unsigned long
976 {
977  return mInternalIter;
978 }
979 
980 
981 inline void
983 {
984  mInternalIter=index;
985  assert( (state()==allRecs) || (mInternalIter < count()) );
986 }
987 
988 
989 inline void
991 {
992  mRep->SelectNone();
993 }
994 
995 
996 inline void
998 {
999  mInternalIter = 0;
1000  mRep->SelectOneRec(rec);
1001 }
1002 
1003 
1004 inline void
1006 {
1007  mRep->SelectAll();
1008 }
1009 
1010 
1011 inline void
1013 {
1014  assert(mRep->Count() > 0); // we have some sub-optimal code in SearchBetween that gets a selection of one rec
1015  mRep->SelectSome();
1016 }
1017 
1018 
1019 inline void
1021 {
1022  if(oid) // bit of a hack to catch mistakes upline, and possible user mistakes
1023  mRep->Append(oid);
1024 }
1025 
1026 
1027 inline unsigned long*
1028 OOF_recordSelection::allocSelection(unsigned long numSlots)
1029 {
1030  return mRep->AllocSelection(numSlots);
1031 }
1032 
1033 
1034 inline void
1035 OOF_recordSelection::expandToInclude(unsigned long indexToCover)
1036 {
1037  mRep->ExpandToInclude(indexToCover);
1038 }
1039 
1040 
1041 inline void
1043 {
1044  mRep->AboutToDirtySelection();
1045 }
1046 
1047 
1048 inline unsigned long*
1050 {
1051  return mRep->AllocConsumedSelection(numSlots);
1052 }
1053 
1054 
1055 
1056 inline void
1058 {
1059  mRep->CopyContents(rhs.mRep);
1060 }
1061 
1062 
1063 inline void
1065 {
1066  mNextFakeNewRecOffset = OOF_FIRST_SYNTHETIC_RECORD_OFFSET;
1067 
1068 }
1069 
1070 #endif
1071 
1072 
unsigned int * mFieldBufMapRefCount
Definition: oofrecs.h:562
void describeState(std::ostream &os) const
Definition: oofrec4.cpp:943
void copyFrom(const OOF_recordBufferedContext *)
Definition: oofrecs.h:704
void copyContents(const OOF_recordSelection &)
Definition: oofrecs.h:1057
void SubSort(const dbSorter *theSorter, const unsigned long level, unsigned long *theData, const unsigned long count)
Now we're sorting at the recursive level of partitioning in a nested sort !
Definition: oofrec2.cpp:602
void reuseDeletedItem(unsigned long, OOF_recordBufferedContext *adoptingContext)
Definition: oofrec4.cpp:149
virtual dbSelection currentSelection() const
Definition: oofrec1.cpp:1311
virtual bool readBool(const dbField *) const
Assumes bools stored as unsigned short, 0==false.
Definition: oofrec1.cpp:544
unsigned long containsContext(const OOF_recordBufferedContext *) const
Definition: oofrec4.cpp:210
virtual void setSortOrder(dbSorter *adoptSorter)
Definition: oofrec4.cpp:822
virtual void selectAll()
Definition: oofrec1.cpp:1353
OOF_ExpandableLongArray * mBlobFieldNums
Definition: oofrecs.h:566
void finishMap(unsigned short numFields)
Definition: oofrec1.cpp:1498
Persistent field used to store a double.
Definition: oof4.h:521
virtual unsigned long blobPointerReferenceSize() const
Definition: oofrec1.cpp:1408
void deleteItem(unsigned long index)
Definition: oofrec4.cpp:870
unsigned short mNumFiles
Definition: oofrecs.h:563
virtual ~OOF_recordBufferedContext()
Definition: oofrec4.cpp:54
virtual dbSorter * sorter() const
Definition: oofrec4.cpp:829
unsigned long mLength
Definition: oofrecs.h:42
OOF_ExpandableLongArray * mBlobFieldBodies
Definition: oofrecs.h:157
virtual bool isAllRecs() const
Definition: oofrecs.h:917
unsigned long countOccupied() const
Definition: oofrecs.h:801
void resetFakeNewRecordOffSet()
Definition: oofrecs.h:1064
virtual void unloadCache()
Definition: oofrec1.cpp:853
virtual unsigned int numIndexes() const
Definition: oofrec1.cpp:1387
bool SearchWordNonIndexed(const dbField *, const char *, bool startsWith=false)
Definition: oofrec3.cpp:237
virtual void prev()
Definition: oofrec1.cpp:372
fieldNumT fieldNumber() const
Definition: oof3.h:754
Used by OOF_simpleRecordBackend::saveRecord to save single cache item.
Definition: oofrecs.h:677
void adopt(OOF_recordSelection &)
Definition: oofrec4.cpp:836
virtual OOF_Selection * clone() const
Definition: oofrec4.cpp:788
void * GetFieldReadFrom(fieldNumT) const
Definition: oofrec1.cpp:750
virtual unsigned long recordNumberOfOID(oidT inOID)
Implement dbTable::recordNumberOfOID.
Definition: oofrec1.cpp:1053
virtual void setSelection(const dbSelection &)
Definition: oofrec1.cpp:1326
Binary query combining two sub-queries.
Definition: oofquery.h:203
virtual oofString readString(const dbField *) const
Copy field data into a string.
Definition: oofrec1.cpp:627
virtual void invert()
Definition: oofrec2.cpp:1841
unsigned long firstFree() const
Definition: oofrec4.cpp:175
virtual bool contains(oidT) const
Definition: oofrecs.h:860
virtual bool searchSelContainsAnyDelimited(const dbField *schField, const char *schStr, char delim)
Definition: oofrec3.cpp:1350
virtual bool SearchTrinaryFieldToLiterals(const dbQueryTrinary *)
Definition: oofrec3.cpp:1753
virtual void beginTransaction(short tMode)
Definition: oofrec3.cpp:1808
bool SearchEqualNonIndexed(const dbField *, const char *, bool matchEntireKey=true)
Definition: oofrec3.cpp:196
virtual unsigned long count() const
Definition: oofrec1.cpp:404
void append(OOF_recordBufferedContext *adoptingContext)
Definition: oofrec4.cpp:135
unsigned long * mBits
Definition: oofarray.h:61
Simplest internal representation of a record's contents and context in dbTable.
Definition: oofrecs.h:130
void selectionChanged()
Definition: oof1.cpp:3007
Highest level used to assemble queries.
Definition: oofquery.h:46
unsigned long mOffset
Definition: oofrecs.h:42
OOF_dirtyFieldMap mDirtyMap
Definition: oofrecs.h:158
bool isDirty(unsigned short) const
Definition: oofrecs.h:782
bool GotoRecordForAllUnindexed(unsigned long relativeNum)
Definition: oofrec1.cpp:761
bool SearchBetweenNonIndexed(const dbField *, const char *, const char *)
Definition: oofrec3.cpp:783
virtual bool checkDuplicate(const dbQueryClause *)
Definition: oofrec3.cpp:110
virtual void pack()
Definition: oofrec1.cpp:1380
Envelope class to contain an abstract selection apart from its dbTable.
Definition: oof1.h:316
virtual bool isRecordLoaded() const
Definition: oofrec1.cpp:1279
virtual void SaveContext()=0
bool more() const
Definition: oofrecs.h:887
OOF_recordSelection & operator=(const OOF_recordSelection &)
Definition: oofrec4.cpp:720
virtual void intersection_with(const OOF_tableBackend *)
Definition: oofrec2.cpp:1765
virtual void union_with_no_overlap(const OOF_tableBackend *)
Definition: oofrec2.cpp:1816
virtual bool searchSelContainsAllOf(const dbField *schField, const char **schStrs, unsigned long count)
Definition: oofrec3.cpp:1390
abstract base for public interface to selections.
Definition: oof2.h:107
void deleteRecord(unsigned long recOffset)
Definition: oofrec4.cpp:159
OOF_recordBufferedContext * item(unsigned long)
Definition: oofrec4.cpp:203
virtual bool atLast() const
Definition: oofrec1.cpp:340
virtual void writeChars(const char *, long numChars, long maxLen, const dbField *, long startIndex=0)
Definition: oofrec1.cpp:699
unsigned short mDeletedCells
Definition: oofrecs.h:108
unsigned long BlobPosFromBuffer(const dbField *fld, const char *theirBuffer) const
Definition: oofrecs.h:749
OOF_recordSelection mSelection
Definition: oofrecs.h:560
unsigned long count() const
Definition: oofarray.h:126
Special limited oofReceiver which will only ever listen to one oofBroadcaster at a time...
Definition: oofmsg.h:133
void CacheDirtyCurrentRecord()
Definition: oofrec1.cpp:935
void append(oidT)
Definition: oofrecs.h:1020
Common trinary query for field, eg: People.Salary.between(50000, 90000); Very similar to dbQueryBinar...
Definition: oofquery.h:263
virtual bool CanUseIndex(const dbField *, dbQueryClause::BinaryQueryOps=dbQueryClause::equals) const
Definition: oofrec1.cpp:1401
unsigned short mNumIndexes
Definition: oofrecs.h:563
virtual const dbTable * prototypicalTable() const
Definition: oofrec4.cpp:959
virtual bool loadRelatedContextJoiningFromTo(const dbField *, const dbField *)
Implements relationships via searching.
Definition: oofrec3.cpp:1470
bool MaybeLoadRecordFromCache(unsigned long offset)
Definition: oofrec1.cpp:1014
virtual ~OOF_recordSelection()
Definition: oofrec4.cpp:780
virtual bool allSelected() const
Definition: oofrec1.cpp:326
virtual unsigned int numFiles() const
Definition: oofrec1.cpp:1394
virtual OOF_tableBackend * clone(dbTable::selSharingT, dbTable *) const =0
abstract base for handling record contexts
Definition: oof2.h:37
void SortSelectionInverseNow(const dbUlong *theFld)
Definition: oofrec2.cpp:1473
unsigned long PadFieldWidthForAlignment(const dbField *fld) const
Definition: oofrec1.cpp:101
virtual bool SearchSelectionBinaryFieldToLiteral(const dbQueryBinary *)
Definition: oofrec3.cpp:1542
unsigned long currentOffset() const
Definition: oofrecs.h:718
virtual void sortSelectionInverseNow(fieldNumT)
Definition: oofrec2.cpp:1131
virtual void commitTransaction(short rMode)
Definition: oofrec3.cpp:1815
unsigned long oneRecOffset() const
Definition: oofrecs.h:924
Mixin for reference counted classes which you want to auto-delete when their count falls to zero...
Definition: oof1.h:82
virtual bool SearchCombineSubclauses(const dbQueryBinaryCombo *, bool searchSel)
Definition: oofrec3.cpp:1709
virtual void noticeDuplicateRecords()
Definition: oofrec1.cpp:319
virtual void union_with(const OOF_tableBackend *)
Definition: oofrec2.cpp:1791
void DonateBlobBodiesTo(OOF_recordBufferedContext *)
Definition: oofrec1.cpp:214
virtual bool isNewRecord() const
Definition: oofrec1.cpp:1286
virtual bool receiveMsg(OOFmsgT msg, unsigned long senderDefined)
The default receiveMsg behaviour is to delete yourself when the broadcaster closes.
Definition: oofrec1.cpp:1450
void copyFrom(const OOF_recordSelection &, dbTable::selSharingT)
Definition: oofrec4.cpp:744
Persistent field used to store an unsigned short.
Definition: oof4.h:317
unsigned long mNextFreeEntry
Definition: oofarray.h:63
virtual void union_with_no_overlap(const OOF_Selection *)
Definition: oofrec2.cpp:2337
void describeInvariant(std::ostream &) const
debugging
Definition: oofrec3.cpp:2025
virtual void setBlobLength(fieldNumT, unsigned long len)
Definition: oofrec1.cpp:269
unsigned int FieldAlignsTo(const dbField *) const
Definition: oofrec1.cpp:123
virtual void saveRecord()
Save current main record and any cached dirty records.
Definition: oofrec1.cpp:788
Main implementation parent for backends following the record-oriented model.
Definition: oofrecs.h:295
Common binary query for field, eg: People.Salary > 90000.
Definition: oofquery.h:165
bool SearchComparativeNonIndexed(const dbField *, const char *, dbQueryClause::BinaryQueryOps)
Definition: oofrec3.cpp:1032
virtual bool addOIDtoSelection(oidT)
Definition: oofrec1.cpp:1204
virtual void LoadRecordAtOffset(unsigned long offset)=0
virtual long readLong(const dbField *) const
Definition: oofrec1.cpp:582
bool IgnoringDuplicateRecords() const
Definition: oofrecs.h:763
virtual bool search(const dbQueryClause *qClause)
Definition: oofrec3.cpp:43
void aboutToDirtySelection()
Definition: oofrecs.h:1042
virtual void CachingContextChange()
Definition: oofrec1.cpp:919
bool SearchSelectionTrinaryFieldToLiterals(const dbQueryTrinary *)
Definition: oofrec3.cpp:1602
unsigned long iter() const
current position in selection
Definition: oofrecs.h:975
bool anyDeleted() const
Definition: oofrecs.h:808
unsigned short mOverheadLeadingBytes
Definition: oofrecs.h:563
unsigned long count() const
Definition: oofrecs.h:794
virtual unsigned long count() const
Definition: oofrecs.h:853
oofString InvariantDescription() const
Definition: oofrec3.cpp:2034
virtual dbSorter * sorter() const
Definition: oofrec1.cpp:1304
Wildcard type for parsing string literals when querying database.
Definition: oofrecs.h:305
virtual void setFileExtensions(const char *, const char *)
Definition: oofrecs.h:322
Selection of records in context of a single dbTable instance.
Definition: oofrecs.h:173
virtual short readShort(const dbField *) const
Definition: oofrec1.cpp:563
unsigned long oidT
type we pass around pretending we have a real OID.
Definition: oof1.h:229
virtual void writeLong(long, const dbField *)
Definition: oofrec1.cpp:673
unsigned long containsOffset(unsigned long recOffset) const
Definition: oofrec4.cpp:225
Abstract interface to database backend.
Definition: oof1.h:1047
bool SearchNotEqualNonIndexedWildcard(const dbField *schField, const char *schStr, bool matchEntireKey=true)
Definition: oofrec3.cpp:500
virtual void difference_with(const OOF_Selection *)
Definition: oofrec2.cpp:2045
unsigned long & operator()()
Definition: oofrecs.h:941
virtual bool isEmpty() const
Definition: oofrecs.h:910
OOF_recordBufferedContext * orphanBuffer(unsigned long)
Definition: oofrec4.cpp:254
Store RAM-resident cache of records, eg: OOF_simpleRecordBackend::mDirtyRecordCache.
Definition: oofrecs.h:76
virtual void unlockRecord()
Definition: oofrec3.cpp:1802
char * buffer() const
Definition: oofrecs.h:732
OOF_ExpandableLongArray mBuffers
Definition: oofrecs.h:107
#define OOF_FIRST_SYNTHETIC_RECORD_OFFSET
value for new records that are being cached, typically related records.
Definition: oofrecs.h:23
virtual void writeBool(bool, const dbField *)
Encode bool as short to be decoded by readBool.
Definition: oofrec1.cpp:640
virtual bool contains(oidT) const
Definition: oofrec1.cpp:1219
virtual bool searchSelection(const dbQueryClause *)
Definition: oofrec3.cpp:117
void SetBlobLenInBuffer(fieldNumT, unsigned long len, const char *theirBuffer) const
Definition: oofrec1.cpp:254
virtual void writeDouble(double, const dbField *)
Definition: oofrec1.cpp:688
OOF_recordFieldEntry * mFieldBufMap
Definition: oofrecs.h:561
void deleteAll()
Definition: oofrec4.cpp:190
unsigned long BlobLenFromBuffer(const dbField *, const char *theirBuffer) const
Definition: oofrecs.h:742
virtual void union_with(const OOF_Selection *)
Definition: oofrec2.cpp:2181
Persistent field used to store a fixed-length string.
Definition: oof3.h:255
virtual oidT currentOID()
Definition: oofrec1.cpp:430
Specify sort order by one more fields.
Definition: oof1.h:1277
virtual ~OOF_recordCacheCopier()
Definition: oofrec1.cpp:1439
just exists to give several classes access to the enum without qualification.
Definition: oofrecs.h:117
void selectOneRec(unsigned long)
Definition: oofrecs.h:997
bool SearchOutsideNonIndexed(const dbField *, const char *, const char *)
Definition: oofrec3.cpp:813
OOF_recordCacheCopier(oofBroadcaster *listensTo, OOF_recordCache *adoptsCache, OOF_simpleRecordBackend *inBackend, OOF_recordBufferedContext *)
Definition: oofrec1.cpp:1430
virtual bool reloadRecord()
Definition: oofrec1.cpp:867
virtual void setSortOrder(dbSorter *adoptSorter)
Definition: oofrec1.cpp:1293
virtual unsigned long fieldDataLen(const dbField *) const
Definition: oofrec1.cpp:472
virtual bool atRelative(unsigned long) const
Definition: oofrec1.cpp:347
OOF_recordBufferedContext * mSavedContext
Definition: oofrecs.h:688
virtual void buildSchema(bool rebuilding=false)
Definition: oofrec1.cpp:154
virtual char * getByteWriteAddress(unsigned long, const dbField *)
Definition: oofrec1.cpp:740
virtual void BuildBackendtables(bool rebuilding)=0
backend construction
Array of longs which expands automatically as you write to cells.
Definition: oofarray.h:21
virtual void revertRecord()
Definition: oofrec1.cpp:887
virtual void ignoreDuplicateRecords()
Definition: oofrec1.cpp:312
Describe entries in schema like OOF_simpleRecordBackend::mFieldBufMap.
Definition: oofrecs.h:38
ERecordState mRecordState
Definition: oofrecs.h:153
Declare query classes.
virtual bool searchSelContainsAnyOf(const dbField *schField, const char **schStrs, unsigned long count)
Definition: oofrec3.cpp:1317
void AdoptBuffer(OOF_recordBufferedContext *)
Definition: oofrec1.cpp:170
virtual bool SearchBinaryFieldToLiteral(const dbQueryBinary *)
Definition: oofrec3.cpp:1645
unsigned short fieldNumT
Definition: oof1.h:276
Base class for persistent tables.
Definition: oof1.h:452
void SortSelectionNow(const dbUlong *theFld)
Definition: oofrec2.cpp:1200
OOF_recordCache * mDirtyRecordCache
Definition: oofrecs.h:567
Portable highly capable string class.
Definition: oofstr.h:101
unsigned long * allocConsumedSelection(unsigned long numSlots)
Definition: oofrecs.h:1049
Describe a subset of fields in a table which are dirty.
Definition: oofrecs.h:51
OOF_recordCache * mCache
Definition: oofrecs.h:686
unsigned long mRecBufLen
Definition: oofrecs.h:155
virtual void unloadRecord()
Definition: oofrec1.cpp:828
virtual bool searchSelContainsAllDelimited(const dbField *schField, const char *schStr, char delim)
Definition: oofrec3.cpp:1422
virtual void describeState(std::ostream &) const
Definition: oofrec1.cpp:1416
virtual bool find(oidT item, unsigned long &foundAt) const
Definition: oofrecs.h:870
Persistent field used to store a short.
Definition: oof4.h:272
OOF_recordSelection(dbTable *prototypicalTable)
Definition: oofrec4.cpp:653
virtual void writeShort(short, const dbField *)
Definition: oofrec1.cpp:658
Lowest level in 3-layer abstraction of selection.
Definition: oofrecs.h:592
unsigned long appendNewRecord(bool appendIt)
returns new synthetic record number
Definition: oofrec4.cpp:914
virtual void intersection_with(const OOF_Selection *)
Definition: oofrec2.cpp:2038
virtual void lockRecord()
Definition: oofrec3.cpp:1795
virtual bool atFirst() const
Definition: oofrec1.cpp:333
bool SearchEqualNonIndexedWildcard(const dbField *schField, const char *schStr, bool matchEntireKey=true)
Definition: oofrec3.cpp:326
OOF_simpleRecordBackend * mBackend
Definition: oofrecs.h:687
unsigned long mCurrLoadedRecOffset
Definition: oofrecs.h:154
Generic broadcaster for messaging.
Definition: oofmsg.h:76
Provides cross-platform directory specification and iteration.
Definition: ooffiles.h:235
bool operator==(unsigned long) const
Definition: oofrecs.h:725
virtual void abortTransaction(short rMode)
Definition: oofrec3.cpp:1822
Persistent field used to store a variable length string.
Definition: oof3.h:459
virtual void newRecord()
Sets up a new record ready to enter data On exit the state is: Selection state is aboutToDirty Select...
Definition: oofrec1.cpp:965
virtual void ContextChange()
Definition: oofrec1.cpp:906
virtual bool selectJustOID(oidT)
Definition: oofrec1.cpp:1246
void describeRecsRep(std::ostream &) const
Definition: oofrec4.cpp:813
void * GetFieldWriteDest(const dbField *)
Definition: oofrec1.cpp:519
unsigned long countNew() const
Definition: oofrec4.cpp:239
virtual void selectJustCurrent()
Definition: oofrec1.cpp:1269
virtual unsigned long recordNumberMatching(const dbQueryClause *qClause, bool *outFoundIt=0) const
Definition: oofrec1.cpp:1098
virtual void difference_with(const OOF_tableBackend *)
Definition: oofrec2.cpp:1740
virtual void dropRecordFromSelection(unsigned long)
Definition: oofrec1.cpp:1227
void setItem(unsigned long, OOF_recordBufferedContext *adoptingContext)
Definition: oofrec4.cpp:142
std::ostream & operator<<(std::ostream &, const oofE_Base &)
OOF_simpleRecordBackend(dbTable *)
Definition: oofrec1.cpp:34
virtual unsigned long recordNumber() const
Definition: oofrec1.cpp:1036
virtual void writeBytes(const char *inBuf, long inLen, const dbField *inField)
Definition: oofrec1.cpp:723
virtual bool fieldIsDirty(fieldNumT) const
Definition: oofrec1.cpp:511
virtual bool searchEqual(const dbField *, const char *, bool matchEntireKey=true)
Definition: oofrec3.cpp:186
unsigned long OOFmsgT
Definition: oofmsg.h:31
unsigned long current() const
value of current item
Definition: oofrecs.h:931
virtual void sortSelectionNow(fieldNumT)
Definition: oofrec2.cpp:1069
unsigned long value(unsigned long) const
Definition: oofrecs.h:967
virtual ~OOF_simpleRecordBackend()
Definition: oofrec1.cpp:85
selSharingT
Definition: oof1.h:463
bool isNew() const
Definition: oofrecs.h:697
void gotoRecord(unsigned long)
Definition: oofrecs.h:982
bool Invariant(const char *optionalComment=0) const
Check combination of member variables defining Invariant state.
Definition: oofrec3.cpp:1837
#define OOFILE_EXPORT
Prefix for OOFILE database & general classes to enable optional DLL linking.
Definition: oof0.h:187
EselectionState state() const
Definition: oofrecs.h:846
virtual oidT oidOfRecord(unsigned long)
Definition: oofrec1.cpp:441
void updateCurrent(unsigned long)
Definition: oofrec4.cpp:935
const OOF_recordBufferedContext & operator=(const OOF_recordBufferedContext &)
Definition: oofrec4.cpp:85
virtual void invert()
Definition: oofrec2.cpp:2432
bool anyDirty() const
Definition: oofrec1.cpp:1508
void markDirty(unsigned short)
Definition: oofrecs.h:774
Persistent field used to store an unsigned long.
Definition: oof4.h:475
virtual bool more() const
Definition: oofrec1.cpp:354
virtual const char * readChars(const dbField *) const
Definition: oofrec1.cpp:619
unsigned long state() const
Definition: oofrec3.cpp:1904
void expandToInclude(unsigned long numSlots)
Definition: oofrecs.h:1035
unsigned long * allocSelection(unsigned long numSlots)
Definition: oofrecs.h:1028
Base class for persistent fields in dbTable's.
Definition: oof3.h:63
void SetBlobPosInBuffer(fieldNumT, unsigned long pos, const char *theirBuffer) const
Definition: oofrec1.cpp:261
virtual dbSelection makeEmptySelection() const
Definition: oofrec1.cpp:1319
unsigned long & operator[](unsigned long)
Definition: oofrecs.h:959
virtual void selectNone()
Definition: oofrec1.cpp:1367
bool SearchNotEqualNonIndexed(const dbField *, const char *, bool matchEntireKey=true)
Definition: oofrec3.cpp:288
Middle level in 3-layer abstraction of selection.
Definition: oofrecs.h:616
virtual double readDouble(const dbField *) const
Definition: oofrec1.cpp:601
Persistent field used to store a long.
Definition: oof4.h:433