// -*- c++ -*-
// Generated by gtkmmproc -- DO NOT MODIFY!
#ifndef _LIBGDAMM_DICTFIELD_H
#define _LIBGDAMM_DICTFIELD_H


#include <glibmm.h>

/* $Id: dictfield.hg,v 1.2 2006/11/08 00:07:37 murrayc Exp $ */
// -*- C++ -*- // this is for the .hg, I realize gensig puts one in

/* dictfield.h
 *
 * Copyright 2006 libgdamm Development Team
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or(at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the Free
 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include <libgdamm/object.h>
#include <libgdamm/xmlstorage.h>
#include <libgdamm/value.h>
#include <libgdamm/dicttype.h>


#ifndef DOXYGEN_SHOULD_SKIP_THIS
typedef struct _GdaDictField GdaDictField;
typedef struct _GdaDictFieldClass GdaDictFieldClass;
#endif /* DOXYGEN_SHOULD_SKIP_THIS */


namespace Gnome
{

namespace Gda
{ class DictField_Class; } // namespace Gda

} // namespace Gnome
namespace Gnome
{

namespace Gda
{

/** @addtogroup libgdammEnums Enums and Flags */

/**
 * @ingroup libgdammEnums
 * @par Bitwise operators:
 * <tt>%DictFieldAttribute operator|(DictFieldAttribute, DictFieldAttribute)</tt><br>
 * <tt>%DictFieldAttribute operator&(DictFieldAttribute, DictFieldAttribute)</tt><br>
 * <tt>%DictFieldAttribute operator^(DictFieldAttribute, DictFieldAttribute)</tt><br>
 * <tt>%DictFieldAttribute operator~(DictFieldAttribute)</tt><br>
 * <tt>%DictFieldAttribute& operator|=(DictFieldAttribute&, DictFieldAttribute)</tt><br>
 * <tt>%DictFieldAttribute& operator&=(DictFieldAttribute&, DictFieldAttribute)</tt><br>
 * <tt>%DictFieldAttribute& operator^=(DictFieldAttribute&, DictFieldAttribute)</tt><br>
 */
enum DictFieldAttribute
{
  AUTO_INCREMENT = 1 << 0
};

/** @ingroup libgdammEnums */
inline DictFieldAttribute operator|(DictFieldAttribute lhs, DictFieldAttribute rhs)
  { return static_cast<DictFieldAttribute>(static_cast<unsigned>(lhs) | static_cast<unsigned>(rhs)); }

/** @ingroup libgdammEnums */
inline DictFieldAttribute operator&(DictFieldAttribute lhs, DictFieldAttribute rhs)
  { return static_cast<DictFieldAttribute>(static_cast<unsigned>(lhs) & static_cast<unsigned>(rhs)); }

/** @ingroup libgdammEnums */
inline DictFieldAttribute operator^(DictFieldAttribute lhs, DictFieldAttribute rhs)
  { return static_cast<DictFieldAttribute>(static_cast<unsigned>(lhs) ^ static_cast<unsigned>(rhs)); }

/** @ingroup libgdammEnums */
inline DictFieldAttribute operator~(DictFieldAttribute flags)
  { return static_cast<DictFieldAttribute>(~static_cast<unsigned>(flags)); }

/** @ingroup libgdammEnums */
inline DictFieldAttribute& operator|=(DictFieldAttribute& lhs, DictFieldAttribute rhs)
  { return (lhs = static_cast<DictFieldAttribute>(static_cast<unsigned>(lhs) | static_cast<unsigned>(rhs))); }

/** @ingroup libgdammEnums */
inline DictFieldAttribute& operator&=(DictFieldAttribute& lhs, DictFieldAttribute rhs)
  { return (lhs = static_cast<DictFieldAttribute>(static_cast<unsigned>(lhs) & static_cast<unsigned>(rhs))); }

/** @ingroup libgdammEnums */
inline DictFieldAttribute& operator^=(DictFieldAttribute& lhs, DictFieldAttribute rhs)
  { return (lhs = static_cast<DictFieldAttribute>(static_cast<unsigned>(lhs) ^ static_cast<unsigned>(rhs))); }

} // namespace Gda

} // namespace Gnome


#ifndef DOXYGEN_SHOULD_SKIP_THIS
namespace Glib
{

template <>
class Value<Gnome::Gda::DictFieldAttribute> : public Glib::Value_Flags<Gnome::Gda::DictFieldAttribute>
{
public:
  static GType value_type() G_GNUC_CONST;
};

} // namespace Glib
#endif /* DOXYGEN_SHOULD_SKIP_THIS */


namespace Gnome
{

namespace Gda
{


class Connection;

/** Represents a field in a table or a view in the database.
 * Unlike DataModelArray, this data model implementation stores the Row in a hash table. So it only retrieves from the 
 * database backend exactly the requested rows (while in DataModelArray you have to retrieve all the rows until the one 
 * requested).
 * 
 * @ingroup Dictionaries
 */

class DictField
: public Gda::Object,
  public XmlStorage
{
  
#ifndef DOXYGEN_SHOULD_SKIP_THIS

public:
  typedef DictField CppObjectType;
  typedef DictField_Class CppClassType;
  typedef GdaDictField BaseObjectType;
  typedef GdaDictFieldClass BaseClassType;

private:  friend class DictField_Class;
  static CppClassType dictfield_class_;

private:
  // noncopyable
  DictField(const DictField&);
  DictField& operator=(const DictField&);

protected:
  explicit DictField(const Glib::ConstructParams& construct_params);
  explicit DictField(GdaDictField* castitem);

#endif /* DOXYGEN_SHOULD_SKIP_THIS */

public:
  virtual ~DictField();

#ifndef DOXYGEN_SHOULD_SKIP_THIS
  static GType get_type()      G_GNUC_CONST;
  static GType get_base_type() G_GNUC_CONST;
#endif

  ///Provides access to the underlying C GObject.
  GdaDictField*       gobj()       { return reinterpret_cast<GdaDictField*>(gobject_); }

  ///Provides access to the underlying C GObject.
  const GdaDictField* gobj() const { return reinterpret_cast<GdaDictField*>(gobject_); }

  ///Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
  GdaDictField* gobj_copy();

private:

  
protected:

  explicit DictField(const Glib::RefPtr<Dict>& dict, const Glib::RefPtr<DictType>& type);

public:
  
  static Glib::RefPtr<DictField> create(const Glib::RefPtr<Dict>& dict, const Glib::RefPtr<DictType>& type);


  void set_length(int length);
  
  /** Get the length of a field.
   * @return The size of the corresponding data type has a fixed size, or -1.
   */
  int get_length() const;
  
  void set_scale(int length);
  
  /** Get the scale of a field.
   * @return The size of the corresponding data type has a fixed size, or -1.
   */
  int get_scale() const;

  
  /** Get all the constraints which impact the given field. Constraints are of several type:
   * NOT <tt>0</tt>, primary key, foreign key, check constrains
   * @return A new list of Gda::DictConstraint objects.
   */
  Glib::SListHandle< Glib::RefPtr<Connection> > get_constraints();
  
  /** Get all the constraints which impact the given field. Constraints are of several type:
   * NOT <tt>0</tt>, primary key, foreign key, check constrains
   * @return A new list of Gda::DictConstraint objects.
   */
  Glib::SListHandle< Glib::RefPtr<const Connection> > get_constraints() const;

  
  /** Sets (or replace) the default value for the field. WARNING: the default value's data type can be
   * different from the field's data type (this is the case for example if the default value is a 
   * function like Postgres's default value for the SERIAL data type).
   * @param value A Value value or <tt>0</tt>.
   */
  void set_default_value(const Value& value);
  Value get_default_value() const;
  

  /** Test if @a field can be <tt>0</tt> or not
   */
  bool is_null_allowed() const;
  
  /** Test if @a field is part of a primary key constraint
   */
  bool is_pkey_part() const;
  
  /** Test if @a field is alone a primary key constraint
   */
  bool is_pkey_alone() const;
  
  /** Test if @a field is part of a foreign key constraint
   */
  bool is_fkey_part() const;
  
  /** Get @a field's extra attributes. The @a attributes is an OR'ed value of all the possible
   * values in Gda::DictFieldAttribute.
   * @return The new attributes value.
   */
  bool is_fkey_alone() const;

  
  void set_attributes(DictFieldAttribute attributes);
  
  DictFieldAttribute get_attributes() const;

  //gtkmmproc error: table : property defs lookup failed.
  #ifdef GLIBMM_PROPERTIES_ENABLED
/** 
   *
   * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
   * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
   * the value of the property changes.
   */
  Glib::PropertyProxy<std::string> property_entry_plugin() ;
#endif //#GLIBMM_PROPERTIES_ENABLED

#ifdef GLIBMM_PROPERTIES_ENABLED
/** 
   *
   * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
   * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
   * the value of the property changes.
   */
  Glib::PropertyProxy_ReadOnly<std::string> property_entry_plugin() const;
#endif //#GLIBMM_PROPERTIES_ENABLED


  //There are no signals or vfuncs.


public:

public:
  //C++ methods used to invoke GTK+ virtual functions:
#ifdef GLIBMM_VFUNCS_ENABLED
#endif //GLIBMM_VFUNCS_ENABLED

protected:
  //GTK+ Virtual Functions (override these to change behaviour):
#ifdef GLIBMM_VFUNCS_ENABLED
#endif //GLIBMM_VFUNCS_ENABLED

  //Default Signal Handlers::
#ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
#endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED


};

} // namespace Gda
} // namespace Gnome


namespace Glib
{
  /** A Glib::wrap() method for this object.
   * 
   * @param object The C instance.
   * @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref.
   * @result A C++ instance that wraps this C instance.
   *
   * @relates Gnome::Gda::DictField
   */
  Glib::RefPtr<Gnome::Gda::DictField> wrap(GdaDictField* object, bool take_copy = false);
}


#endif /* _LIBGDAMM_DICTFIELD_H */

