Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

Fl_Data_Source.h

00001 /*
00002  * $Id: Fl_Data_Source.h,v 1.22 2003/07/03 20:36:35 laza2000 Exp $
00003  *
00004  * Extended Fast Light Toolkit (EFLTK)
00005  * Copyright (C) 2002-2003 by EDE-Team
00006  * WWW: http://www.sourceforge.net/projects/ede
00007  *
00008  * Fast Light Toolkit (FLTK)
00009  * Copyright (C) 1998-2003 by Bill Spitzak and others.
00010  * WWW: http://www.fltk.org
00011  *
00012  * This library is distributed under the GNU LIBRARY GENERAL PUBLIC LICENSE
00013  * version 2. See COPYING for details.
00014  *
00015  * Author : Alexey Parshin
00016  * Email  : alexey@fltk.net
00017  *
00018  * Please report all bugs and problems to "efltk-bugs@fltk.net"
00019  *
00020  */
00021 
00022 #ifndef _FL_DATA_SOURCE_H_
00023 #define _FL_DATA_SOURCE_H_
00024 
00025 #include "Fl_Variant.h"
00026 #include "Fl_Data_Fields.h"
00027 
00028 class Fl_Group;
00029 
00031 class FL_API Fl_Data_Source {
00032     friend class Fl_Group;
00033 public:
00034     // ctor, dtor
00035     Fl_Data_Source(Fl_Group *group) { m_parent = group; }
00036     virtual ~Fl_Data_Source() {}
00037 
00038     void parent(Fl_Group *p) { m_parent = p; }
00039     Fl_Group *parent() { return m_parent; }
00040 
00041     // access to the field by name
00042     virtual const Fl_Variant& operator [] (const char *field_name) const = 0;
00043     virtual Fl_Variant&       operator [] (const char *field_name) = 0;
00044 
00045      // how many rows do we have ds?
00046     virtual unsigned          record_count() const = 0;
00047 
00048     // how many fields do we have in the current record?
00049     virtual unsigned          field_count() const = 0;
00050     virtual int               field_index(const char *) const { return -1; }
00051 
00052     // access to the field by number, 0..field_count()-1
00053     virtual const Fl_Variant& operator [] (int) const = 0;
00054     virtual Fl_Variant&       operator [] (int) = 0;
00055 
00056     virtual const Fl_Data_Field& field (int field_index) const = 0;
00057     virtual Fl_Data_Field&       field (int field_index) = 0;
00058     virtual void             *user_data() const { return 0L; } 
00059 
00060     virtual bool              read_field(const char *fname,Fl_Variant& value) = 0;
00061     virtual bool              write_field(const char *fname,const Fl_Variant& fvalue) = 0;
00062 
00063     // dataset navigation
00064     virtual bool              open()  { return false; }
00065     virtual bool              close() { return false; }
00066     virtual bool              first() { return false; }
00067     virtual bool              next()  { return false; }
00068     virtual bool              prior() { return false; }
00069     virtual bool              last()  { return false; }
00070     virtual bool              find(Fl_Variant position) { return false; }
00071     virtual bool              eof() const  { return false; }
00072 
00073     // load data into widgets
00074     bool load();
00075     // unload data from widgets
00076     bool save();
00077 
00078 protected:
00079     // these methods should be implemented in derived class
00080     virtual bool              load_data() = 0;
00081     virtual bool              save_data() = 0;
00082     Fl_Group* m_parent;
00083 };
00084 
00085 #endif

Generated on Thu Jul 31 15:33:43 2003 for eFLTK by doxygen1.2.15