00001 // 00002 // File: include/odbcpp/handle.h 00003 // Object: Base class for the different handles 00004 // Project: http://www.m2osw.com/odbcpp 00005 // Author: alexis_wilke@sourceforge.net 00006 // 00007 // Copyright (C) 2008 Made to Order Software Corp. 00008 // 00009 // This program is free software: you can redistribute it and/or modify 00010 // it under the terms of the GNU General Public License as published by 00011 // the Free Software Foundation, either version 3 of the License, or 00012 // (at your option) any later version. 00013 // 00014 // This program is distributed in the hope that it will be useful, 00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 // GNU General Public License for more details. 00018 // 00019 // You should have received a copy of the GNU General Public License 00020 // along with this program. If not, see <http://www.gnu.org/licenses/> 00021 // or <http://gpl3.m2osw.com/>. 00022 // 00023 00024 #ifndef ODBCPP_HANDLE 00025 #define ODBCPP_HANDLE 00026 00027 #include "exception.h" 00028 #include "object.h" 00029 00030 namespace odbcpp 00031 { 00032 00033 class handle : public object 00034 { 00035 public: 00036 handle(SQLSMALLINT handle_type); 00037 ~handle(); 00038 00039 SQLRETURN check(SQLRETURN return_code, handle *parent = 0) const; 00040 00041 SQLHANDLE get_handle() const { return f_handle; } 00042 SQLSMALLINT get_handle_type() const { return f_handle_type; } 00043 const diagnostic& get_diagnostic() const { return f_diag; } 00044 00045 protected: 00046 SQLHANDLE f_handle; 00047 const SQLSMALLINT f_handle_type; 00048 00049 private: 00051 handle(const handle& hdl) : f_handle(SQL_NULL_HANDLE), f_handle_type(SQL_HANDLE_ENV) {} 00053 handle& operator = (const handle& hdl) { return *this; } 00054 00055 mutable diagnostic f_diag; 00056 }; 00057 00058 00059 00060 } // namespace odbcpp 00061 00062 #endif // #ifndef ODBCPP_HANDLE