Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

pqxxobject::field_base Class Reference

Database field base class. More...

#include <field_base.h>

Inheritance diagram for pqxxobject::field_base:

Object pqxxobject::field< T > pqxxobject::ptr_field< T > List of all members.

Public Member Functions

 field_base ()
 The constructor.

 field_base (const std::string &column_name)
 The constructor.

 field_base (const field_base &rhs)
 The copy constructor.

virtual ~field_base ()
 The destructor.

field_baseoperator= (const field_base &rhs)
 Overloaded assignment operator.

const std::string & get_column_name () const
 Get the column name this field belongs to.

void set_column_name (const std::string &column)
 Set the column name this field belongs to.

virtual bool is_null () const=0
 Check if the contained value is NULL.

virtual bool is_not_null () const=0
 Check if the contained value is not NULL.

SigC::Signal0< void > & signal_changed ()
 Signal emitted on value change.


Protected Attributes

std::string m_column_name
 The column name.

SigC::Signal0< void > m_signal_changed
 The changed signal.


Detailed Description

Database field base class.

This class is used to represent a single field in a row of a table. This is a single value belonging to a column in a row, rather than the whole column. Like a database field, the value may be NULL. If set to NULL, it is important not to call any of the object member functions, or access the object itself (this would dereference a NULL pointer).

The class has some similarity with std::auto_ptr, but the copying semantics are different: on copy, the value is copied, which may involve memory allocation. There is no transfer of pointer ownership. Contained objects must posess a copy constructor.

As well as storing value, the class has the ability to emit signals when the field value is changed. Listeners (e.g. user interface widgets) may connect to the signal and will receive notification of changes as they occur.

Definition at line 68 of file field_base.h.


Constructor & Destructor Documentation

field_base::field_base  ) 
 

The constructor.

Definition at line 43 of file field_base.cc.

field_base::field_base const std::string &  column_name  ) 
 

The constructor.

Parameters:
column the name of the table column the field belongs to.

Definition at line 49 of file field_base.cc.

field_base::field_base const field_base rhs  ) 
 

The copy constructor.

Definition at line 56 of file field_base.cc.

field_base::~field_base  )  [virtual]
 

The destructor.

Definition at line 62 of file field_base.cc.


Member Function Documentation

const std::string & field_base::get_column_name  )  const
 

Get the column name this field belongs to.

Returns:
the column name.

Definition at line 76 of file field_base.cc.

References m_column_name.

Referenced by pqxxobject::update_query::remove(), and pqxxobject::insert_query::remove().

virtual bool pqxxobject::field_base::is_not_null  )  const [pure virtual]
 

Check if the contained value is not NULL.

Returns:
true if not NULL, otherwise false.

Implemented in pqxxobject::field< T >, and pqxxobject::ptr_field< T >.

virtual bool pqxxobject::field_base::is_null  )  const [pure virtual]
 

Check if the contained value is NULL.

Returns:
true if NULL, otherwise false.

Implemented in pqxxobject::field< T >, and pqxxobject::ptr_field< T >.

field_base & field_base::operator= const field_base rhs  ) 
 

Overloaded assignment operator.

The field column name is not copied by the assignment. This is because differently-named columns could potentially be assigned to one another.

Definition at line 67 of file field_base.cc.

void field_base::set_column_name const std::string &  column  ) 
 

Set the column name this field belongs to.

Parameters:
column the column name.

Definition at line 82 of file field_base.cc.

References m_column_name.

SigC::Signal0< void > & field_base::signal_changed  ) 
 

Signal emitted on value change.

Returns:
the signal.
For example:
field<int> col; someclass listener; col.signal_changed().connect ( SigC::slot(listener, &someclass::on_col_changed() );
i.e. a class method (listener.on_col_changed()) will be called when the value is changed.

Definition at line 89 of file field_base.cc.

References m_signal_changed.


Member Data Documentation

std::string pqxxobject::field_base::m_column_name [protected]
 

The column name.

Definition at line 137 of file field_base.h.

Referenced by get_column_name(), and set_column_name().

SigC::Signal0<void> pqxxobject::field_base::m_signal_changed [protected]
 

The changed signal.

Definition at line 140 of file field_base.h.

Referenced by signal_changed().


The documentation for this class was generated from the following files:
Generated on Sat May 22 18:34:00 2004 for pqxxobject API Reference by doxygen 1.3.6-20040222