Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

Connection.h

Go to the documentation of this file.
00001 // /******************************************************************************\
00002 // *
00003 // * File:          Connection.h
00004 // * Creation date: May 17, 2001 13:11
00005 // * Author:        ClassBuilder
00006 // *                XXXX
00007 // * Purpose:       Declaration of class 'DOConnection'
00008 // *
00009 // * Modifications: @INSERT_MODIFICATIONS(* )
00010 // * May 25, 2001 15:21 WERS
00011 // *     Deleted method 'LastInsertId'
00012 // *     Updated return type of method 'LastInsertId'
00013 // * May 25, 2001 15:15 WERS
00014 // *     Added method 'LastInsertId'
00015 // *     Updated return type of method 'LastInsertId'
00016 // * May 18, 2001 10:12 WERS
00017 // *     Updated relation 'Connection(DOConnection) <>-->> Query(DOQuery)'
00018 // *     Updated member 'm_database'
00019 // *     Updated member 'm_username'
00020 // *     Updated member 'm_password'
00021 // *     Updated member 'm_hostname'
00022 // *     Updated member 'm_handle'
00023 // * May 17, 2001 15:19 WERS
00024 // *     Added member 'm_database'
00025 // * May 17, 2001 14:26 WERS
00026 // *     Deleted method 'GetHandle'
00027 // *     Added method 'GetHdl'
00028 // *     Updated member 'm_handle'
00029 // * May 17, 2001 14:24 WERS
00030 // *     Deleted method 'Disconnect'
00031 // *     Added relation 'Connection(DOConnection) <>-->> Query(DOQuery)'
00032 // * May 17, 2001 14:01 WERS
00033 // *     Deleted inheritance 'DOConnection'
00034 // *     Added member 'm_username'
00035 // *     Added member 'm_password'
00036 // *     Added member 'm_hostname'
00037 // *     Updated member 'm_handle'
00038 // * May 17, 2001 13:57 WERS
00039 // *     Added method 'GetHandle'
00040 // *     Added method 'Disconnect'
00041 // *     Added method 'Connect'
00042 // *     Added member 'm_handle'
00043 // * May 17, 2001 13:40 WERS
00044 // *     Added method 'DOConnection'
00045 // * May 17, 2001 13:11 WERS
00046 // *     Added method 'DestructorInclude'
00047 // *     Added method 'ConstructorInclude'
00048 // *     Added method '~DOConnection'
00049 // *     Added inheritance 'DOConnection'
00050 // *
00051 // *
00052 // \******************************************************************************/
00053 #ifndef _CONNECTION_H
00054 #define _CONNECTION_H
00055 
00056 //@START_USER1
00061 /* --------------------------------------------------------------
00062 Copyright (C) 2001 LifeLine Networks BV <soap2corba@lifeline.nl>
00063 
00064 This program is free software; you can redistribute it and/or
00065 modify it under the terms of the GNU General Public License
00066 as published by the Free Software Foundation; either
00067 version 2 of the License, or (at your option) any later
00068 version.
00069 
00070 This program is distributed in the hope that it will be useful,
00071 but WITHOUT ANY WARRANTY; without even the implied warranty of
00072 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00073 GNU General Public License for more details.
00074 
00075 You should have received a copy of the GNU General Public License
00076 along with this program; if not, write to the Free Software
00077 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00078 -------------------------------------------------------------- */
00079 //@END_USER1
00080 
00081 
00085 class DOConnection
00086 {
00087     // RELATION_MULTI_OWNED_ACTIVE(DOConnection, Connection, DOQuery, Query)
00088 public:
00089     DOQuery * _firstQuery;
00090     DOQuery * _lastQuery;
00091     int _countQuery;
00092 
00093 protected:
00094     void AddQueryFirst(DOQuery* item);
00095     void AddQueryLast(DOQuery* item);
00096     void AddQueryAfter(DOQuery* item, DOQuery* pos);
00097     void AddQueryBefore(DOQuery* item, DOQuery* pos);
00098     void RemoveQuery(DOQuery* item);
00099     void ReplaceQuery(DOQuery* item, DOQuery* newItem);
00100 
00101 public:
00102     void DeleteAllQuery();
00103     DOQuery* GetFirstQuery() const;
00104     DOQuery* GetLastQuery() const;
00105     DOQuery* GetNextQuery(DOQuery* pos) const;
00106     DOQuery* GetPrevQuery(DOQuery* pos) const;
00107     int GetQueryCount() const;
00108     void MoveQueryFirst(DOQuery* item);
00109     void MoveQueryLast(DOQuery* item);
00110     void MoveQueryAfter(DOQuery* item, DOQuery* pos);
00111     void MoveQueryBefore(DOQuery* item, DOQuery* pos);
00112     void SortQuery(int (*comp)(DOQuery*, DOQuery*));
00113     
00114     class  QueryIterator
00115     {
00116     private:
00117         DOQuery* _refQuery;
00118         DOQuery* _prevQuery;
00119         DOQuery* _nextQuery;
00120         const DOConnection* _iterConnection;
00121         
00122         QueryIterator* _prev;
00123         QueryIterator* _next;
00124         
00125         int (DOQuery::*_method)() const;
00126         
00127         static QueryIterator* _first;
00128         static QueryIterator* _last;
00129         
00130     public:
00131         QueryIterator(const DOConnection* iterConnection,
00132                          int (DOQuery::*method)() const = 0,
00133                          DOQuery* refQuery = 0);
00134         QueryIterator(const DOConnection& iterConnection,
00135                          int (DOQuery::*method)() const = 0,
00136                          DOQuery* refQuery = 0);
00137         QueryIterator(const QueryIterator& iterator,
00138                          int (DOQuery::*method)() const = 0);
00139         ~QueryIterator();
00140         
00141         QueryIterator& operator= (const QueryIterator& iterator)
00142         {
00143             _iterConnection = iterator._iterConnection;
00144             _refQuery = iterator._refQuery;
00145             _prevQuery = iterator._prevQuery;
00146             _nextQuery = iterator._nextQuery;
00147             _method = iterator._method;
00148             return *this;
00149         }
00150         DOQuery* operator++ ()
00151         {
00152             _nextQuery = _iterConnection->GetNextQuery(_nextQuery);
00153             if (_method != 0)
00154             {
00155                 while (_nextQuery && !(_nextQuery->*_method)())
00156                     _nextQuery = _iterConnection->GetNextQuery(_nextQuery);
00157             }
00158             _refQuery = _prevQuery = _nextQuery;
00159             return _refQuery;
00160         }
00161         DOQuery* operator-- ()
00162         {
00163             _prevQuery = _iterConnection->GetPrevQuery(_prevQuery);
00164             if (_method != 0)
00165             {
00166                 while (_prevQuery && !(_prevQuery->*_method)())
00167                     _prevQuery = _iterConnection->GetPrevQuery(_prevQuery);
00168             }
00169             _refQuery = _nextQuery = _prevQuery;
00170             return _refQuery;
00171         }
00172         operator DOQuery*() { return _refQuery; }
00173         DOQuery* operator-> () { return _refQuery; }
00174         DOQuery* Get() { return _refQuery; }
00175         void Reset() { _refQuery = _prevQuery = _nextQuery = (DOQuery*)0; }
00176         
00177         int IsLast() { return (_iterConnection->GetLastQuery() == _refQuery); }
00178         int IsFirst() { return (_iterConnection->GetFirstQuery() == _refQuery); }
00179         
00180         static void Check(DOQuery* itemQuery);
00181         static void Check(DOQuery* itemQuery, DOQuery* newItemQuery);
00182     };
00183 
00184 //@START_USER2
00185 //@END_USER2
00186 
00187 // Members
00188 private:
00189     MYSQL m_handle;
00190 
00191 protected:
00192 
00193 public:
00194     CString m_hostname;
00195     CString m_password;
00196     CString m_username;
00197     CString m_database;
00198 
00199 // Methods
00200 private:
00201     void ConstructorInclude();
00202     void DestructorInclude();
00203 
00204 protected:
00205 
00206 public:
00207     DOConnection();
00208     virtual ~DOConnection();
00209     virtual void Connect();
00210     MYSQL* GetHdl();
00211 };
00212 
00213 #endif
00214 
00215 
00216 #ifdef CB_INLINES
00217 #ifndef _CONNECTION_H_INLINES
00218 #define _CONNECTION_H_INLINES
00219 
00220 //@START_USER3
00221 //@END_USER3
00222 
00223 #endif
00224 #endif
00225 

This documentation is part of the "SOAP to CORBA bridge" project
Copyright © 2000 by Lifeline Networks bv.
All rights are reserved.