New member function gnucomo_database::is_conected().
[gnucomo.git] / src / include / database.h
index 1a4763d..b96c0b3 100644 (file)
@@ -8,7 +8,7 @@
 ***********************
 **      FILE NAME      : database.h
 **      SYSTEM NAME    : 
-**      VERSION NUMBER : $Revision: 1.3 $
+**      VERSION NUMBER : $Revision: 1.7 $
 **
 **  DESCRIPTION      :  Classes to provide an abstract layer on the Gnucomo
 **                      database.
 ********************************
 **      ORIGINAL AUTHOR : Arjen Baart - arjen@andromeda.nl
 **      CREATION DATE   : Sep 10, 2002
-**      LAST UPDATE     : Nov 04, 2002
+**      LAST UPDATE     : Mar 28, 2003
 **      MODIFICATIONS   : 
 **************************************************************************/
 
 /*****************************
    $Log: database.h,v $
-   Revision 1.3  2002-11-09 08:04:27  arjen
+   Revision 1.7  2003-03-29 08:13:53  arjen
+   New member function gnucomo_database::is_conected().
+
+   Revision 1.6  2003/02/19 09:54:47  arjen
+   Print the query on cerr, along with the error message when
+   the query results in an error.
+
+   Revision 1.5  2003/02/05 09:33:17  arjen
+   gnucomo_database::new_notification() retruns the id number of the
+   newly created notification record.
+
+   Revision 1.4  2003/01/18 08:52:18  arjen
+   New C++ function: gnucomo_database::new_notification()
+
+   Revision 1.3  2002/11/09 08:04:27  arjen
    Added a reference to the GPL
 
    Revision 1.2  2002/11/04 10:13:36  arjen
@@ -38,7 +52,7 @@
 
 *****************************/
 
-/* static const char *RCSID = "$Id: database.h,v 1.3 2002-11-09 08:04:27 arjen Exp $"; */
+/* static const char *RCSID = "$Id: database.h,v 1.7 2003-03-29 08:13:53 arjen Exp $"; */
 
 #include <libpq++/pgdatabase.h>
 #include "gnucomo_config.h"
@@ -55,7 +69,7 @@
 //
 //  RELATIONS      :
 //  SEE ALSO       :
-//  LAST MODIFIED  : Sep 16, 2002
+//  LAST MODIFIED  : Mar 28, 2003
 ///////////////////////////////////////////////////////////////////////////
 */
 
@@ -74,6 +88,13 @@ public:
 
    gnucomo_database(gnucomo_config *c);  // Use the configuration to connect to the database
 
+   //  Error checking and handling.
+
+   bool is_connected()
+   {
+      return db != 0 && db->Status() == CONNECTION_OK;
+   }
+
    //  Low-level database access functions
 
    int Query(String qry)
@@ -88,6 +109,7 @@ public:
       else
       {
          std::cerr << "Database query error: " << db->ErrorMessage() << "\n";
+         std::cerr << "Query: " << qry << "\n";
          return -1;
       }
    }
@@ -100,5 +122,9 @@ public:
    //  Return the objectid of the host given its name.
 
    String find_host(const String hostname);
+
+   //  Create a new notification.
+
+   String new_notification(String objectid, String issue, String remark);
 };