Public Member Functions

Wt::Dbo::Dbo< C > Class Template Reference
[Database Objects (Dbo)]

A base class for database objects. More...

#include <Wt/Dbo/Dbo>

List of all members.

Public Member Functions

 Dbo ()
 Constructor.
dbo_traits< C >::IdType id () const
 Returns the database id.
Sessionsession () const
 Returns the session.

Detailed Description

template<class C>
class Wt::Dbo::Dbo< C >

A base class for database objects.

The only requirement for a class to be be persisted is to have a persist() method. In some cases however, it may be convenient to be able to access database information of an object, such as its database id and its session, from the object itself.

By deriving your database class directly or indirectly from this class, you can have access to its id() and session(). This will increase the size of your object with one pointer.

The following example shows a skeleton for a database object which has access to its own id and session information:

 class Cat : public Wt::Dbo::Dbo {
 public:
   template <class Action>
   void persist(Action& a) { }
 };

Compare this to the skeleton for a minimum valid database class:

 class Cat {
 public:
   template <class Action>
   void persist(Action& a) { }
 };

Member Function Documentation

template<class C >
dbo_traits< C >::IdType Wt::Dbo::Dbo< C >::id (  ) const

Returns the database id.

Returns the database id of this object, or Wt::Dbo::dbo_traits<C>::invalidId() if the object is associated with a session or not yet stored in the database.

template<class C >
Session * Wt::Dbo::Dbo< C >::session (  ) const

Returns the session.

Returns the session to which this object belongs, or 0 if the object is not associated with a session.

 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator

Generated on Fri Feb 4 2011 for the C++ Web Toolkit (Wt) by doxygen 1.7.2