datamodel.h

Go to the documentation of this file.
00001 // -*- c++ -*-
00002 // Generated by gtkmmproc -- DO NOT MODIFY!
00003 #ifndef _LIBGDAMM_DATAMODEL_H
00004 #define _LIBGDAMM_DATAMODEL_H
00005 
00006 
00007 #include <glibmm.h>
00008 
00009 /* $Id: datamodel.hg,v 1.32 2006/12/15 15:02:27 murrayc Exp $ */
00010 // -*- C++ -*- // this is for the .hg, I realize gensig puts one in
00011 
00012 /* datamodel.h
00013  *
00014  * Copyright 2003 libgdamm Development Team
00015  *
00016  * This library is free software; you can redistribute it and/or
00017  * modify it under the terms of the GNU Library General Public
00018  * License as published by the Free Software Foundation; either
00019  * version 2 of the License, or (at your option) any later version.
00020  *
00021  * This library is distributed in the hope that it will be useful,
00022  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00023  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00024  * Library General Public License for more details.
00025  *
00026  * You should have received a copy of the GNU Library General Public
00027  * License along with this library; if not, write to the Free
00028  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00029  */
00030 
00031 #include <glibmm/object.h>
00032 #include <libgdamm/command.h>
00033 #include <libgdamm/row.h>
00034 #include <libgdamm/column.h>
00035 #include <libgdamm/parameterlist.h>
00036 #include <libgdamm/datamodeliter.h>
00037 //#include <libgdamm/serverprovider.h>
00038 #include <libgda/gda-data-model.h>
00039 
00040 
00041 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00042 typedef struct _GdaDataModel GdaDataModel;
00043 typedef struct _GdaDataModelClass GdaDataModelClass;
00044 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
00045 
00046 
00047 namespace Gnome
00048 {
00049 
00050 namespace Gda
00051 { class DataModel_Class; } // namespace Gda
00052 
00053 } // namespace Gnome
00054 namespace Gnome
00055 {
00056 
00057 namespace Gda
00058 {
00059 
00060 class Row;
00061 class ServerProvider;
00062 
00076 enum DataModelAccessFlags
00077 {
00078   DATA_MODEL_ACCESS_RANDOM = 1 << 0,
00079   DATA_MODEL_ACCESS_CURSOR_FORWARD = 1 << 1,
00080   DATA_MODEL_ACCESS_CURSOR_BACKWARD = 1 << 2,
00081   DATA_MODEL_ACCESS_INSERT = 1 << 3,
00082   DATA_MODEL_ACCESS_UPDATE = 1 << 4,
00083   DATA_MODEL_ACCESS_DELETE = 1 << 5,
00084   DATA_MODEL_ACCESS_WRITE = 0x8
00085 };
00086 
00088 inline DataModelAccessFlags operator|(DataModelAccessFlags lhs, DataModelAccessFlags rhs)
00089   { return static_cast<DataModelAccessFlags>(static_cast<unsigned>(lhs) | static_cast<unsigned>(rhs)); }
00090 
00092 inline DataModelAccessFlags operator&(DataModelAccessFlags lhs, DataModelAccessFlags rhs)
00093   { return static_cast<DataModelAccessFlags>(static_cast<unsigned>(lhs) & static_cast<unsigned>(rhs)); }
00094 
00096 inline DataModelAccessFlags operator^(DataModelAccessFlags lhs, DataModelAccessFlags rhs)
00097   { return static_cast<DataModelAccessFlags>(static_cast<unsigned>(lhs) ^ static_cast<unsigned>(rhs)); }
00098 
00100 inline DataModelAccessFlags operator~(DataModelAccessFlags flags)
00101   { return static_cast<DataModelAccessFlags>(~static_cast<unsigned>(flags)); }
00102 
00104 inline DataModelAccessFlags& operator|=(DataModelAccessFlags& lhs, DataModelAccessFlags rhs)
00105   { return (lhs = static_cast<DataModelAccessFlags>(static_cast<unsigned>(lhs) | static_cast<unsigned>(rhs))); }
00106 
00108 inline DataModelAccessFlags& operator&=(DataModelAccessFlags& lhs, DataModelAccessFlags rhs)
00109   { return (lhs = static_cast<DataModelAccessFlags>(static_cast<unsigned>(lhs) & static_cast<unsigned>(rhs))); }
00110 
00112 inline DataModelAccessFlags& operator^=(DataModelAccessFlags& lhs, DataModelAccessFlags rhs)
00113   { return (lhs = static_cast<DataModelAccessFlags>(static_cast<unsigned>(lhs) ^ static_cast<unsigned>(rhs))); }
00114 
00115 } // namespace Gda
00116 
00117 } // namespace Gnome
00118 
00119 
00120 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00121 namespace Glib
00122 {
00123 
00124 template <>
00125 class Value<Gnome::Gda::DataModelAccessFlags> : public Glib::Value_Flags<Gnome::Gda::DataModelAccessFlags>
00126 {
00127 public:
00128   static GType value_type() G_GNUC_CONST;
00129 };
00130 
00131 } // namespace Glib
00132 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
00133 
00134 
00135 namespace Gnome
00136 {
00137 
00138 namespace Gda
00139 {
00140 
00144 enum DataModelHint
00145 {
00146   DATA_MODEL_HINT_START_BATCH_UPDATE,
00147   DATA_MODEL_HINT_END_BATCH_UPDATE,
00148   DATA_MODEL_HINT_REFRESH
00149 };
00150 
00151 } // namespace Gda
00152 
00153 } // namespace Gnome
00154 
00155 
00156 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00157 namespace Glib
00158 {
00159 
00160 template <>
00161 class Value<Gnome::Gda::DataModelHint> : public Glib::Value_Enum<Gnome::Gda::DataModelHint>
00162 {
00163 public:
00164   static GType value_type() G_GNUC_CONST;
00165 };
00166 
00167 } // namespace Glib
00168 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
00169 
00170 
00171 namespace Gnome
00172 {
00173 
00174 namespace Gda
00175 {
00176 
00180 enum DataModelIOFormat
00181 {
00182   DATA_MODEL_IO_DATA_ARRAY_XML,
00183   DATA_MODEL_IO_TEXT_SEPARATED
00184 };
00185 
00186 } // namespace Gda
00187 
00188 } // namespace Gnome
00189 
00190 
00191 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00192 namespace Glib
00193 {
00194 
00195 template <>
00196 class Value<Gnome::Gda::DataModelIOFormat> : public Glib::Value_Enum<Gnome::Gda::DataModelIOFormat>
00197 {
00198 public:
00199   static GType value_type() G_GNUC_CONST;
00200 };
00201 
00202 } // namespace Glib
00203 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
00204 
00205 
00206 namespace Gnome
00207 {
00208 
00209 namespace Gda
00210 {
00211 
00212 
00243 class DataModel : public Glib::Interface
00244 {
00245   
00246 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00247 
00248 public:
00249   typedef DataModel CppObjectType;
00250   typedef DataModel_Class CppClassType;
00251   typedef GdaDataModel BaseObjectType;
00252   typedef GdaDataModelClass BaseClassType;
00253 
00254 private:
00255   friend class DataModel_Class;
00256   static CppClassType datamodel_class_;
00257 
00258   // noncopyable
00259   DataModel(const DataModel&);
00260   DataModel& operator=(const DataModel&);
00261 
00262 protected:
00263   DataModel(); // you must derive from this class
00264   explicit DataModel(GdaDataModel* castitem);
00265 
00266 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
00267 
00268 public:
00269   virtual ~DataModel();
00270 
00271   static void add_interface(GType gtype_implementer);
00272 
00273 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00274   static GType get_type()      G_GNUC_CONST;
00275   static GType get_base_type() G_GNUC_CONST;
00276 #endif
00277 
00279   GdaDataModel*       gobj()       { return reinterpret_cast<GdaDataModel*>(gobject_); }
00280 
00282   const GdaDataModel* gobj() const { return reinterpret_cast<GdaDataModel*>(gobject_); }
00283 
00284 private:
00285 
00286 public:
00287 
00288   
00293   void freeze();  
00294   
00297   void thaw();
00298 
00299   
00303   int get_n_rows() const;
00304   
00308   int get_n_columns() const;
00309 
00310   
00321   Glib::RefPtr<Column> describe_column(int col);
00322   
00333   Glib::RefPtr<const Column> describe_column(int col) const;
00334   
00339   int get_column_index(const Glib::ustring& name) const;
00340   
00345   Glib::ustring get_column_title(int col) const;
00346   
00351   void set_column_title(int col, const Glib::ustring& title);
00352   //TODO:_WRAP_METHOD(int get_column_position(const Glib::ustring& title) const, gda_data_model_get_column_position)
00353 
00354   //We use a custom conversion here, because we need to copy the value:
00355   //#m4 __CONVERSION(`GValue*',`Value',`Glib::wrap($3, true /* take_copy=true */)')
00356   //#m4 __CONVERSION(`const GValue*',`Value',`Glib::wrap(const_cast<GValue*>($3), true /* take_copy */)')
00357  
00358   Value get_value_at(int col, int row) const;
00359   
00360 
00361   Value get_value_at(const Glib::ustring& column_name, int row) const;
00362   
00363 
00372   ValueAttribute get_attributes_at(int col, int row);
00373 
00374   
00384   Glib::RefPtr<DataModelIter> create_iter();
00385    
00386   //Ignore private functions:
00387   
00388 
00396 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00397   bool set_value_at(int col, int row, const Value& value);
00398 #else
00399   bool set_value_at(int col, int row, const Value& value, std::auto_ptr<Glib::Error>& error);
00400 #endif //GLIBMM_EXCEPTIONS_ENABLED
00401 
00402   //TODO: _WRAP_METHOD(bool gda_data_model_set_values(int row, GList *values), gda_data_model_set_values, errthrow)
00403 
00404   
00408   bool is_updatable() const;
00409   
00413   DataModelAccessFlags get_access_flags() const;
00414 
00415    
00424 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00425   int append_values(const ValueList& values);
00426 #else
00427   int append_values(const ValueList& values, std::auto_ptr<Glib::Error>& error);
00428 #endif //GLIBMM_EXCEPTIONS_ENABLED
00429 
00430 
00435 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00436   bool append_row();
00437 #else
00438   bool append_row(std::auto_ptr<Glib::Error>& error);
00439 #endif //GLIBMM_EXCEPTIONS_ENABLED
00440 
00441   
00447 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00448   bool remove_row(int row);
00449 #else
00450   bool remove_row(int row, std::auto_ptr<Glib::Error>& error);
00451 #endif //GLIBMM_EXCEPTIONS_ENABLED
00452 
00453 
00454   //TODO: _WRAP_METHOD(int get_row_from_values(GSList *values, int *cols_index), gda_data_model_get_row_from_values)
00455 
00456   
00462   void send_hint(DataModelHint hint, const Value& hint_value);
00463 
00464   //TODO: _WRAP_METHOD(Glib::ustring export_to_string(DataModelIOFormat format, const int *cols, int nb_cols, const Glib::RefPtr<const ParameterList>& options), gda_data_model_export_to_string)
00465 //TODO: Hand-code this to use an Array for the cols and rows, using less parameters:
00466   //_WRAP_METHOD(bool export_to_file(DataModelIOFormat format, const std::string& file, const gint* cols, int nb_cols, const gint* rows, int nb_rows, const Glib::RefPtr<const ParameterList>& options), gda_data_model_export_to_file, errthrow)
00467 
00468   //TODO: _WRAP_METHOD(bool import_from_model(Glib::RefPtr<DataModel> from,  GHashTable *cols_trans), gda_data_model_import_from_model, errthrow)
00469   
00477 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00478   bool import_from_string(const Glib::ustring& string, GHashTable *cols_trans, const Glib::RefPtr<const ParameterList>& options);
00479 #else
00480   bool import_from_string(const Glib::ustring& string, GHashTable * cols_trans, const Glib::RefPtr<const ParameterList>& options, std::auto_ptr<Glib::Error>& error);
00481 #endif //GLIBMM_EXCEPTIONS_ENABLED
00482 
00483   
00491 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00492   bool import_from_file(const std::string& file, GHashTable *cols_trans, const Glib::RefPtr<const ParameterList>& options);
00493 #else
00494   bool import_from_file(const std::string& file, GHashTable * cols_trans, const Glib::RefPtr<const ParameterList>& options, std::auto_ptr<Glib::Error>& error);
00495 #endif //GLIBMM_EXCEPTIONS_ENABLED
00496 
00497 
00498 //TODO: Implement.
00499   Glib::ustring to_xml(const Glib::ArrayHandle<int>& cols, const Glib::StringArrayHandle& names) const;
00500   ;
00501 
00502   //TODO: Wrap these if we want to depend on libxml++, though they seem silly. murrayc.
00503   
00504   //_WRAP_METHOD(xmlNodePtr to_xml(const GLib::ustring& name), gda_data_model_to_xml_node)
00505   //_WRAP_METHOD(bool add_data(xmlNodePtr node), gda_data_model_add_data_from_xml_node)
00506 
00507   
00511   void dump(FILE* to_stream) const;
00512   
00516   Glib::ustring dump_as_string() const;
00517 
00518   //These are from gda-datamodel-extra.h:
00519   //TODO: Are these meant to be public API?
00520   
00527   void signal_emit_changed();
00528   
00532   void row_inserted(int row);
00533   
00537   void row_updated(int row);
00538   
00542   void row_removed(int row);
00543 
00544   
00545   bool move_iter_at_row_default(const Glib::RefPtr<DataModelIter>& iter, int row);
00546   
00547   bool move_iter_next_default(const Glib::RefPtr<DataModelIter>& iter);
00548   
00549   bool move_iter_prev_default(const Glib::RefPtr<DataModelIter>& iter);
00550 
00551    
00559 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00560   bool set_values(int row, const ValueList& values);
00561 #else
00562   bool set_values(int row, const ValueList& values, std::auto_ptr<Glib::Error>& error);
00563 #endif //GLIBMM_EXCEPTIONS_ENABLED
00564 ;
00565 
00566         /* TODO: Is this correct here. Seems to be in the wrong header */
00567   
00572 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00573   Glib::RefPtr<DataModel> copy() const;
00574 #else
00575   Glib::RefPtr<DataModel> copy(std::auto_ptr<Glib::Error>& error) const;
00576 #endif //GLIBMM_EXCEPTIONS_ENABLED
00577 
00578 
00579   //These are in a private header. Ignore them:
00580   
00581 
00587   Glib::SignalProxy1< void,int > signal_row_inserted();
00588 
00589   
00595   Glib::SignalProxy1< void,int > signal_row_updated();
00596 
00597   
00603   Glib::SignalProxy1< void,int > signal_row_removed();
00604 
00605 
00606 protected:
00607 
00608   //We don't wrap the vfuncs because they are only useful for creating new backends,
00609   //and they have a high code-size and per-object memory cost.
00610 
00611 
00612 public:
00613 
00614 public:
00615   //C++ methods used to invoke GTK+ virtual functions:
00616 #ifdef GLIBMM_VFUNCS_ENABLED
00617 #endif //GLIBMM_VFUNCS_ENABLED
00618 
00619 protected:
00620   //GTK+ Virtual Functions (override these to change behaviour):
00621 #ifdef GLIBMM_VFUNCS_ENABLED
00622 #endif //GLIBMM_VFUNCS_ENABLED
00623 
00624   //Default Signal Handlers::
00625 #ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
00626   virtual void on_row_inserted(int row);
00627   virtual void on_row_updated(int row);
00628   virtual void on_row_removed(int row);
00629 #endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
00630 
00631 
00632 };
00633 
00634 } // namespace Gda
00635 } // namespace Gnome
00636 
00637 
00638 namespace Glib
00639 {
00645   Glib::RefPtr<Gnome::Gda::DataModel> wrap(GdaDataModel* object, bool take_copy = false);
00646 
00647 } // namespace Glib
00648 
00649 
00650 #endif /* _LIBGDAMM_DATAMODEL_H */
00651 

Generated on Sat Feb 10 20:06:25 2007 for libgdamm by  doxygen 1.4.7