2 /**************************************************************************
3 ** (c) Copyright 2002, Andromeda Technology & Automation
4 ** This is free software; you can redistribute it and/or modify it under the
5 ** terms of the GNU General Public License, see the file COPYING.
6 ***************************************************************************
7 ** MODULE INFORMATION *
8 ***********************
9 ** FILE NAME : database.h
11 ** VERSION NUMBER : $Revision: 1.4 $
13 ** DESCRIPTION : Classes to provide an abstract layer on the Gnucomo
19 ***************************************************************************
20 ** ADMINISTRATIVE INFORMATION *
21 ********************************
22 ** ORIGINAL AUTHOR : Arjen Baart - arjen@andromeda.nl
23 ** CREATION DATE : Sep 10, 2002
24 ** LAST UPDATE : Jan 17, 2003
26 **************************************************************************/
28 /*****************************
30 Revision 1.4 2003-01-18 08:52:18 arjen
31 New C++ function: gnucomo_database::new_notification()
33 Revision 1.3 2002/11/09 08:04:27 arjen
34 Added a reference to the GPL
36 Revision 1.2 2002/11/04 10:13:36 arjen
37 Use proper namespace for iostream classes
39 Revision 1.1 2002/10/05 10:25:49 arjen
40 Creation of gcm_input and a first approach to a web interface
42 *****************************/
44 /* static const char *RCSID = "$Id: database.h,v 1.4 2003-01-18 08:52:18 arjen Exp $"; */
46 #include <libpq++/pgdatabase.h>
47 #include "gnucomo_config.h"
50 ///////////////////////////////////////////////////////////////////////////
51 // NAME : gnucomo_database
52 // BASECLASS : configuration
55 // METHODS : Database - Obtain the database access string
61 // LAST MODIFIED : Jan 17, 2003
62 ///////////////////////////////////////////////////////////////////////////
65 class gnucomo_database
78 gnucomo_database(gnucomo_config *c); // Use the configuration to connect to the database
80 // Low-level database access functions
84 ExecStatusType result;
86 result = db->Exec(qry);
87 if (result == PGRES_TUPLES_OK || result == PGRES_COMMAND_OK)
93 std::cerr << "Database query error: " << db->ErrorMessage() << "\n";
98 String Field(int tuple, const char *fieldname)
100 return String(db->GetValue(tuple, fieldname));
103 // Return the objectid of the host given its name.
105 String find_host(const String hostname);
107 // Create a new notification.
109 void new_notification(String objectid, String issue, String remark);