00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef FXDATABASEQUERY_H
00024 #define FXDATABASEQUERY_H
00025
00026 #ifndef FXBASEOBJECT_H
00027 #include "FXBaseObject.h"
00028 #endif
00029 namespace FXEX {
00030 class FXDatabaseInterface;
00031
00032
00033
00034
00035 class FXAPI FXDatabaseQuery : public FXBaseObject {
00036 FXDECLARE_ABSTRACT(FXDatabaseQuery)
00037
00038 typedef struct {
00039 FXObject *tgt;
00040 FXSelector msg;
00041 FXString fldName;
00042 FXint fldPos;
00043 } FXfldTarget;
00044
00045 typedef FXArray<FXfldTarget> FXfldTargetList;
00046
00047 protected:
00048 FXString query;
00049 FXDatabaseInterface *database;
00050 FXDatabaseFieldList fields;
00051 FXrsState state;
00052 FXfldTargetList fldTargets;
00053 FXbool readOnly;
00054
00055
00056 FXDatabaseQuery(FXDatabaseInterface *dbi, FXObject *tgt=NULL, FXSelector sel=0);
00057
00058 FXDatabaseQuery();
00059 void checkState(FXrsState should_be) const;
00060 void checkOpen(FXbool open) const;
00061 void checkEditable(FXbool editable) const;
00062 void broadcastMessage(FXdbEvType ev, void *data = NULL);
00063 virtual void notifyMove(FXuint currentPos);
00064 FXint findFldTarget(FXObject *tgt);
00065 FXbool bindTarget(FXint pos);
00066 FXbool unbindTarget(FXint pos);
00067 void initTarget(FXint tgt);
00068 virtual void deleteFields();
00069 public:
00070 enum {
00071 ID_DISCONNECT = FXBaseObject::ID_LAST,
00072 ID_CONNECT,
00073 ID_DESTROY,
00074 ID_LAST
00075 };
00076
00077 public:
00078 long onDisconnect(FXObject *, FXSelector, void *);
00079 long onConnect(FXObject *, FXSelector, void *);
00080 long onDestroy(FXObject *, FXSelector, void *);
00081 long onFree(FXObject *, FXSelector, void *);
00082
00083 public:
00084
00085 FXDatabaseInterface* getDatabase() const { return database; }
00086
00087
00088 FXString getQuery() const { checkOpen(TRUE); return query; }
00089
00090
00091 void addFldTarget(FXObject *tgt, FXSelector msg, const FXString &fld);
00092 void addFldTarget(FXObject *tgt, FXSelector msg, FXint fld);
00093 void removeFldTarget(FXObject *tgt);
00094 FXrsState getState() const { return state; }
00095 FXbool isOpen() const;
00096 FXbool isEditable() const;
00097
00098
00099
00100 virtual void Open(const FXString &query, FXbool readOnly=TRUE);
00101 virtual void Close();
00102 virtual void addNew();
00103 virtual void Edit();
00104 virtual void Delete();
00105
00106 virtual void Update();
00107 virtual void CancelUpdate();
00108 virtual void Free();
00109
00110
00111 virtual void Requery() = '\0';
00112 virtual FXbool moveFirst() = '\0';
00113 virtual FXbool moveNext() = '\0';
00114 virtual FXbool movePrevious() = '\0';
00115 virtual FXbool moveLast() = '\0';
00116 virtual FXbool moveTo(FXuint where) = '\0';
00117 virtual FXbool moveOf(FXint displacement) = '\0';
00118
00119
00120 virtual FXuint currentPos() = '\0';
00121
00122
00123 virtual FXuint recordCount() = '\0';
00124
00125
00126 FXint fieldCount();
00127 FXDatabaseField &operator[](FXint pos);
00128
00129
00130 virtual void save(FXStream& store) const;
00131 virtual void load(FXStream& store);
00132
00133
00134 virtual ~FXDatabaseQuery();
00135 };
00136
00137 typedef FXObjectListOf<FXDatabaseQuery> FXDatabaseQueryList;
00138
00139 }
00140 #endif // FXDATABASEQUERY_H