query.h

Go to the documentation of this file.
00001 // -*- c++ -*-
00002 // Generated by gtkmmproc -- DO NOT MODIFY!
00003 #ifndef _LIBGDAMM_QUERY_H
00004 #define _LIBGDAMM_QUERY_H
00005 
00006 
00007 #include <glibmm.h>
00008 
00009 // -*- C++ -*- // this is for the .hg, I realize gensig puts one in
00010 
00011 /* query.h
00012  *
00013  * Copyright 2003 libgdamm Development Team
00014  *
00015  * This library is free software; you can redistribute it and/or
00016  * modify it under the terms of the GNU Library General Public
00017  * License as published by the Free Software Foundation; either
00018  * version 2 of the License, or (at your option) any later version.
00019  *
00020  * This library is distributed in the hope that it will be useful,
00021  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00022  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00023  * Library General Public License for more details.
00024  *
00025  * You should have received a copy of the GNU Library General Public
00026  * License along with this library; if not, write to the Free
00027  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00028  */
00029 
00030 #include <glibmm/object.h>
00031 #include <libgdamm/dict.h>
00032 #include <libgdamm/datamodel.h>
00033 
00034 #include <libgdamm/xmlstorage.h>
00035 #include <libgdamm/referer.h>
00036 #include <libgdamm/renderer.h>
00037 #include <libgdamm/entity.h>
00038 #include <libgdamm/queryobject.h>
00039 
00040 #include <libgdamm/queryfield.h>
00041 #include <libgdamm/querytarget.h>
00042 #include <libgdamm/querycondition.h>
00043 
00044 
00045 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00046 typedef struct _GdaQuery GdaQuery;
00047 typedef struct _GdaQueryClass GdaQueryClass;
00048 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
00049 
00050 
00051 namespace Gnome
00052 {
00053 
00054 namespace Gda
00055 { class Query_Class; } // namespace Gda
00056 
00057 } // namespace Gnome
00058 namespace Gnome
00059 {
00060 
00061 namespace Gda
00062 {
00063 
00069 enum QueryType
00070 {
00071   QUERY_TYPE_SELECT,
00072   QUERY_TYPE_INSERT,
00073   QUERY_TYPE_UPDATE,
00074   QUERY_TYPE_DELETE,
00075   QUERY_TYPE_UNION,
00076   QUERY_TYPE_INTERSECT,
00077   QUERY_TYPE_EXCEPT,
00078   QUERY_TYPE_NON_PARSED_SQL
00079 };
00080 
00081 } // namespace Gda
00082 
00083 } // namespace Gnome
00084 
00085 
00086 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00087 namespace Glib
00088 {
00089 
00090 template <>
00091 class Value<Gnome::Gda::QueryType> : public Glib::Value_Enum<Gnome::Gda::QueryType>
00092 {
00093 public:
00094   static GType value_type() G_GNUC_CONST;
00095 };
00096 
00097 } // namespace Glib
00098 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
00099 
00100 
00101 namespace Gnome
00102 {
00103 
00104 namespace Gda
00105 {
00106 
00118 enum QueryFieldState
00119 {
00120   ENTITY_FIELD_VISIBLE = 1 << 0,
00121   ENTITY_FIELD_INVISIBLE = 1 << 1,
00122   ENTITY_FIELD_ANY = 0x1
00123 };
00124 
00126 inline QueryFieldState operator|(QueryFieldState lhs, QueryFieldState rhs)
00127   { return static_cast<QueryFieldState>(static_cast<unsigned>(lhs) | static_cast<unsigned>(rhs)); }
00128 
00130 inline QueryFieldState operator&(QueryFieldState lhs, QueryFieldState rhs)
00131   { return static_cast<QueryFieldState>(static_cast<unsigned>(lhs) & static_cast<unsigned>(rhs)); }
00132 
00134 inline QueryFieldState operator^(QueryFieldState lhs, QueryFieldState rhs)
00135   { return static_cast<QueryFieldState>(static_cast<unsigned>(lhs) ^ static_cast<unsigned>(rhs)); }
00136 
00138 inline QueryFieldState operator~(QueryFieldState flags)
00139   { return static_cast<QueryFieldState>(~static_cast<unsigned>(flags)); }
00140 
00142 inline QueryFieldState& operator|=(QueryFieldState& lhs, QueryFieldState rhs)
00143   { return (lhs = static_cast<QueryFieldState>(static_cast<unsigned>(lhs) | static_cast<unsigned>(rhs))); }
00144 
00146 inline QueryFieldState& operator&=(QueryFieldState& lhs, QueryFieldState rhs)
00147   { return (lhs = static_cast<QueryFieldState>(static_cast<unsigned>(lhs) & static_cast<unsigned>(rhs))); }
00148 
00150 inline QueryFieldState& operator^=(QueryFieldState& lhs, QueryFieldState rhs)
00151   { return (lhs = static_cast<QueryFieldState>(static_cast<unsigned>(lhs) ^ static_cast<unsigned>(rhs))); }
00152 
00153 } // namespace Gda
00154 
00155 } // namespace Gnome
00156 
00157 
00158 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00159 namespace Glib
00160 {
00161 
00162 template <>
00163 class Value<Gnome::Gda::QueryFieldState> : public Glib::Value_Flags<Gnome::Gda::QueryFieldState>
00164 {
00165 public:
00166   static GType value_type() G_GNUC_CONST;
00167 };
00168 
00169 } // namespace Glib
00170 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
00171 
00172 
00173 namespace Gnome
00174 {
00175 
00176 namespace Gda
00177 {
00178 
00179 
00185 class Query
00186  : public QueryObject,
00187    public XmlStorage,
00188    public Referer,
00189    public Renderer,
00190    public Entity
00191 {
00192   
00193 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00194 
00195 public:
00196   typedef Query CppObjectType;
00197   typedef Query_Class CppClassType;
00198   typedef GdaQuery BaseObjectType;
00199   typedef GdaQueryClass BaseClassType;
00200 
00201 private:  friend class Query_Class;
00202   static CppClassType query_class_;
00203 
00204 private:
00205   // noncopyable
00206   Query(const Query&);
00207   Query& operator=(const Query&);
00208 
00209 protected:
00210   explicit Query(const Glib::ConstructParams& construct_params);
00211   explicit Query(GdaQuery* castitem);
00212 
00213 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
00214 
00215 public:
00216   virtual ~Query();
00217 
00218 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00219   static GType get_type()      G_GNUC_CONST;
00220   static GType get_base_type() G_GNUC_CONST;
00221 #endif
00222 
00224   GdaQuery*       gobj()       { return reinterpret_cast<GdaQuery*>(gobject_); }
00225 
00227   const GdaQuery* gobj() const { return reinterpret_cast<GdaQuery*>(gobject_); }
00228 
00230   GdaQuery* gobj_copy();
00231 
00232 private:
00233 
00234 
00235 protected:
00236   explicit Query(const Glib::RefPtr<Dict>& dict);
00237   Query(const Glib::RefPtr<Dict>& dict, QueryType type);
00238 
00239 public:
00240   
00241   static Glib::RefPtr<Query> create(const Glib::RefPtr<Dict>& dict);
00242 
00243   
00244   static Glib::RefPtr<Query> create(const Glib::RefPtr<Dict>& dict, QueryType type);
00245 
00246 
00247   // TODO: How to wrap GHashTable in g*mm? armin.
00248   
00249 
00250   // Not wrapped because it only calls gda_query_set_sql_text(). However,
00251   // gda_query_set_sql_text() might throw an exception and if this was a
00252   // constructor, it would prevent the object from being constructed, but in
00253   // C a new object is returned. This is why the caller should call
00254   // gda_query_set_sql_text her/himself.
00255   
00256 
00260   void set_query_type(QueryType type);
00261   
00265   QueryType get_query_type() const;
00266   
00270   Glib::ustring get_query_type_string() const;
00271   
00275   bool is_select_query() const;
00276   
00280   bool is_insert_query() const;
00281   
00285   bool is_update_query() const;
00286   
00290   bool is_delete_query() const;
00291   
00296   bool is_modify_query() const;
00297 
00298   
00309 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00310   void set_sql_text(const Glib::ustring& sql);
00311 #else
00312   void set_sql_text(const Glib::ustring& sql, std::auto_ptr<Glib::Error>& error);
00313 #endif //GLIBMM_EXCEPTIONS_ENABLED
00314 
00315   
00324   Glib::ustring get_sql_text() const;
00325 
00326    
00330   Glib::SListHandle<Glib::RefPtr<Parameter> > get_parameters();
00331 
00332   
00338   Glib::RefPtr<ParameterList> get_parameter_list();
00339   
00345   Glib::RefPtr<const ParameterList> get_parameter_list() const;
00346 
00347 //TODO: Add a suitable default value for the bool - look at the docs to choose a value?
00348   
00359 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00360   Glib::RefPtr<Object> execute(const Glib::RefPtr<ParameterList>& params, bool iter_model_only_requested = false);
00361 #else
00362   Glib::RefPtr<Object> execute(const Glib::RefPtr<ParameterList>& params, bool iter_model_only_requested, std::auto_ptr<Glib::Error>& error);
00363 #endif //GLIBMM_EXCEPTIONS_ENABLED
00364 
00365   //I don't think that an exectute() function should be const. We can add it later if necessary. murrayc: _WRAP_METHOD(Glib::RefPtr<const Object> execute(const Glib::RefPtr<ParameterList>& params, bool iter_model_only_requested) const, gda_query_execute, errthrow, constversion)
00366   
00370   Glib::RefPtr<Query> get_parent_query();
00371   
00375   Glib::RefPtr<const Query> get_parent_query() const;
00376 
00377    
00381   Glib::SListHandle<Glib::RefPtr<Query> > get_sub_queries();
00382   
00387   void add_param_source(const Glib::RefPtr<DataModel>& param_source);
00388   
00393   void del_param_source(const Glib::RefPtr<DataModel>& param_source);
00394 
00395    
00399   Glib::SListHandle<Glib::RefPtr<const Query> > get_param_sources() const;
00400 
00401   
00406   void add_sub_query(const Glib::RefPtr<Query>& sub_query);
00407   
00411   void del_sub_query(const Glib::RefPtr<Query>& sub_query);
00412 
00413   
00428 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00429   bool add_target(const Glib::RefPtr<QueryTarget>& target);
00430 #else
00431   bool add_target(const Glib::RefPtr<QueryTarget>& target, std::auto_ptr<Glib::Error>& error);
00432 #endif //GLIBMM_EXCEPTIONS_ENABLED
00433 
00434   
00439   void del_target(const Glib::RefPtr<QueryTarget>& target);
00440 
00441   // TODO: I am not quite sure what the correct ownership is here and whether
00442   // we have to unref the objects in the list. armin.
00443    
00444 
00448   Glib::SListHandle<Glib::RefPtr<QueryTarget> > get_targets();
00449   
00453   Glib::SListHandle<Glib::RefPtr<const QueryTarget> > get_targets() const;
00454 
00455   
00461   Glib::RefPtr<QueryTarget> get_target_by_xml_id(const Glib::ustring& xml_id);
00462   
00468   Glib::RefPtr<const QueryTarget> get_target_by_xml_id(const Glib::ustring& xml_id) const;
00469   
00475   Glib::RefPtr<QueryTarget> get_target_by_alias(const Glib::ustring& alias_or_name);
00476   
00482   Glib::RefPtr<const QueryTarget> get_target_by_alias(const Glib::ustring& alias_or_name) const;
00483 
00484   // TODO: I am not quite usre what the correct ownership is here and
00485   // whether we have to unref the objects in the list. armin.
00486    
00487 
00496   Glib::SListHandle<Glib::RefPtr<QueryField> > get_target_pkfields(const Glib::RefPtr<QueryTarget>& target);
00497   
00506   Glib::SListHandle<Glib::RefPtr<const QueryField> > get_target_pkfields(const Glib::RefPtr<QueryTarget>& target) const;
00507 
00508   // TODO: Wrap join API
00509 
00510   
00514   Glib::RefPtr<QueryCondition> get_condition();
00515   
00519   Glib::RefPtr<const QueryCondition> get_condition() const;
00520   
00527   void set_condition(const Glib::RefPtr<QueryCondition>& cond);
00528 
00529   
00536   void set_order_by_field(const Glib::RefPtr<QueryField>& field, int order = 0, bool ascendant = true);
00537   int get_order_by_field(const Glib::RefPtr<QueryField>& field) const;
00538   int get_order_by_field(const Glib::RefPtr<QueryField>& field, bool& ascendant) const;
00539 
00540   
00547 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00548   Glib::RefPtr<QueryField> add_field_from_sql(const Glib::ustring& field);
00549 #else
00550   Glib::RefPtr<QueryField> add_field_from_sql(const Glib::ustring& field, std::auto_ptr<Glib::Error>& error);
00551 #endif //GLIBMM_EXCEPTIONS_ENABLED
00552 
00553   
00558   Glib::SListHandle<Glib::RefPtr<QueryField> > get_all_fields();
00559   
00564   Glib::SListHandle<Glib::RefPtr<const QueryField> > get_all_fields() const;
00565   
00569   Glib::RefPtr<QueryField> get_field_by_sql_naming(const Glib::ustring& sql_name);
00570   
00574   Glib::RefPtr<const QueryField> get_field_by_sql_naming(const Glib::ustring& sql_name) const;
00575   
00576   Glib::RefPtr<QueryField> get_field_by_param_name(const Glib::ustring& param_name);
00577   
00578   Glib::RefPtr<const QueryField> get_field_by_param_name(const Glib::ustring& param_name) const;
00579   
00589   Glib::RefPtr<QueryField> get_field_by_ref_field(const Glib::RefPtr<QueryTarget>& target, const Glib::RefPtr<EntityField>& field, QueryFieldState field_state);
00590   
00600   Glib::RefPtr<const QueryField> get_field_by_ref_field(const Glib::RefPtr<QueryTarget>& target, const Glib::RefPtr<EntityField>& field, QueryFieldState field_state) const;
00601   
00605   Glib::RefPtr<QueryField> get_first_field_for_target(const Glib::RefPtr<QueryTarget>& target);
00606   
00610   Glib::RefPtr<const QueryField> get_first_field_for_target(const Glib::RefPtr<QueryTarget>& target) const;
00611 
00612   
00621   Glib::SListHandle<Glib::RefPtr<QueryField> > expand_all_field(const Glib::RefPtr<QueryTarget>& target);
00622   
00626   void order_fields_using_join_conds();
00627   
00633   Glib::SListHandle<Glib::RefPtr<QueryField> > get_fields_by_target(const Glib::RefPtr<QueryTarget>& target, bool visible_fields_only = true);
00634   
00640   Glib::SListHandle<Glib::RefPtr<const QueryField> > get_fields_by_target(const Glib::RefPtr<QueryTarget>& target, bool visible_fields_only = true) const;
00641 
00642 
00643 public:
00644 
00645 public:
00646   //C++ methods used to invoke GTK+ virtual functions:
00647 #ifdef GLIBMM_VFUNCS_ENABLED
00648 #endif //GLIBMM_VFUNCS_ENABLED
00649 
00650 protected:
00651   //GTK+ Virtual Functions (override these to change behaviour):
00652 #ifdef GLIBMM_VFUNCS_ENABLED
00653 #endif //GLIBMM_VFUNCS_ENABLED
00654 
00655   //Default Signal Handlers::
00656 #ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
00657 #endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
00658 
00659 
00660 };
00661 
00662 } // namespace Gda
00663 } // namespace Gnome
00664 
00665 
00666 namespace Glib
00667 {
00673   Glib::RefPtr<Gnome::Gda::Query> wrap(GdaQuery* object, bool take_copy = false);
00674 }
00675 
00676 
00677 #endif /* _LIBGDAMM_QUERY_H */
00678 

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